17
17
18
18
#define MAX_MESSAGES 1000
19
19
#define MAX_QUEUE 20
20
- #define MAX_MESSAGE_CATEGORIES 20
21
20
22
21
struct message_data_t {
23
22
city_message messages[MAX_MESSAGES];
@@ -49,8 +48,8 @@ struct message_data_t {
49
48
uint16_t pop25000 : 1 ;
50
49
} population_shown;
51
50
52
- int message_count[MAX_MESSAGE_CATEGORIES ];
53
- int message_delay[MAX_MESSAGE_CATEGORIES ];
51
+ int message_count[MESSAGE_CAT_SIZE ];
52
+ int message_delay[MESSAGE_CAT_SIZE ];
54
53
55
54
time_millis last_sound_time[MESSAGE_CAT_RIOT_COLLAPSE + 1 ];
56
55
@@ -79,7 +78,7 @@ void city_message_init_scenario(void) {
79
78
data.total_messages = 0 ;
80
79
data.current_message_id = 0 ;
81
80
82
- for (int i = 0 ; i < MAX_MESSAGE_CATEGORIES ; i++) {
81
+ for (int i = 0 ; i < MESSAGE_CAT_SIZE ; i++) {
83
82
data.message_count [i] = 0 ;
84
83
data.message_delay [i] = 0 ;
85
84
}
@@ -225,7 +224,7 @@ void city_message_post_full(bool use_popup, int template_id, int event_id, int p
225
224
should_play_sound = true ;
226
225
}
227
226
228
- static void city_message_post_common (bool use_popup, int message_id, int param1, int param2, int god, int bg_img) {
227
+ static void city_message_post_common (bool use_popup, int message_id, int param1, int param2, int god, int bg_img, city_message_options *opts ) {
229
228
auto &data = g_message_data;
230
229
231
230
int id = new_message_id ();
@@ -249,7 +248,8 @@ static void city_message_post_common(bool use_popup, int message_id, int param1,
249
248
msg->param2 = param2;
250
249
msg->sequence = data.next_message_sequence ++;
251
250
msg->god = god;
252
- msg->background_img = bg_img;
251
+ msg->hide_img = (opts && opts->hide_img );
252
+ msg->background_img = (opts && (opts->force_img >= 0 )) ? opts->force_img : bg_img;
253
253
254
254
int text_id = city_message_get_text_id (message_id);
255
255
int lang_msg_type = lang_get_message (text_id)->message_type ;
@@ -271,30 +271,33 @@ static void city_message_post_common(bool use_popup, int message_id, int param1,
271
271
}
272
272
273
273
void city_message_god_post (int god, bool use_popup, int message_id, int param1, int param2) {
274
- city_message_post_common (use_popup, message_id, param1, param2, god, 0 );
274
+ city_message_post_common (use_popup, message_id, param1, param2, god, 0 , nullptr );
275
275
}
276
276
277
277
void city_message_population_post (bool use_popup, int message_id, int param1, int param2) {
278
278
int img_id = image_id_from_group (GROUP_PANEL_GODS_DIALOGDRAW) + 16 ;
279
- city_message_post_common (use_popup, message_id, param1, param2, GOD_UNKNOWN, img_id);
279
+ city_message_post_common (use_popup, message_id, param1, param2, GOD_UNKNOWN, img_id, nullptr );
280
280
}
281
281
282
- void city_message_post (bool use_popup, int message_id, int param1, int param2) {
283
- city_message_post_common (use_popup, message_id, param1, param2, GOD_UNKNOWN, 0 );
282
+ void city_message_post (bool use_popup, int message_id, int param1, int param2, city_message_options *opts ) {
283
+ city_message_post_common (use_popup, message_id, param1, param2, GOD_UNKNOWN, 0 , opts );
284
284
}
285
285
286
- void city_message_post_with_popup_delay (int category, int message_type, int param1, short param2) {
286
+ void city_message_post_with_popup_delay (e_mesage_category category, int message_type, int param1, short param2, city_message_options *opts ) {
287
287
auto & data = g_message_data;
288
288
int use_popup = false ;
289
+
289
290
if (data.message_delay [category] <= 0 ) {
290
291
use_popup = true ;
291
292
data.message_delay [category] = 12 ;
292
293
}
293
- city_message_post (use_popup, message_type, param1, param2);
294
+ use_popup |= (opts && opts->force_popup );
295
+
296
+ city_message_post (use_popup, message_type, param1, param2, opts);
294
297
data.message_count [category]++;
295
298
}
296
299
297
- void city_message_post_with_message_delay (int category, int use_popup, int message_type, int delay) {
300
+ void city_message_post_with_message_delay (e_mesage_category category, int use_popup, int message_type, int delay) {
298
301
auto & data = g_message_data;
299
302
if (category == MESSAGE_CAT_FISHING_BLOCKED || category == MESSAGE_CAT_NO_WORKING_DOCK) {
300
303
// bug in the original game: delays for 'fishing blocked' and 'no working dock'
@@ -414,22 +417,22 @@ int city_message_get_advisor(int message_type) {
414
417
}
415
418
}
416
419
417
- void city_message_reset_category_count (int category) {
420
+ void city_message_reset_category_count (e_mesage_category category) {
418
421
auto & data = g_message_data;
419
422
data.message_count [category] = 0 ;
420
423
}
421
- void city_message_increase_category_count (int category) {
424
+ void city_message_increase_category_count (e_mesage_category category) {
422
425
auto & data = g_message_data;
423
426
data.message_count [category]++;
424
427
}
425
- int city_message_get_category_count (int category) {
428
+ int city_message_get_category_count (e_mesage_category category) {
426
429
auto & data = g_message_data;
427
430
return data.message_count [category];
428
431
}
429
432
430
433
void city_message_decrease_delays (void ) {
431
434
auto & data = g_message_data;
432
- for (int i = 0 ; i < MAX_MESSAGE_CATEGORIES ; i++) {
435
+ for (int i = 0 ; i < MESSAGE_CAT_SIZE ; i++) {
433
436
if (data.message_delay [i] > 0 )
434
437
data.message_delay [i]--;
435
438
}
@@ -587,7 +590,8 @@ io_buffer* iob_messages = new io_buffer([](io_buffer* iob, size_t version) {
587
590
iob->bind (BIND_SIGNATURE_INT16, &msg->eventmsg_phrase_id );
588
591
iob->bind (BIND_SIGNATURE_INT16, &msg->req_city_past ); // enum?
589
592
iob->bind (BIND_SIGNATURE_INT16, &msg->unk_09 ); // 00 00
590
- iob->bind (BIND_SIGNATURE_INT16, &msg->unk_10 ); // 00 00
593
+ iob->bind (BIND_SIGNATURE_UINT8, &msg->unk_10 ); // 00 00
594
+ iob->bind (BIND_SIGNATURE_UINT8, &msg->hide_img ); // 00 00
591
595
592
596
iob->bind (BIND_SIGNATURE_INT16, &msg->req_amount_past );
593
597
iob->bind (BIND_SIGNATURE_INT16, &msg->req_resource_past );
@@ -613,11 +617,11 @@ io_buffer* iob_message_extra = new io_buffer([](io_buffer* iob, size_t version)
613
617
iob->bind (BIND_SIGNATURE_UINT16, &data.reserved_5 );
614
618
iob->bind (BIND_SIGNATURE_UINT8, &data.reserved_6 );
615
619
616
- for (int i = 0 ; i < MAX_MESSAGE_CATEGORIES ; i++) {
620
+ for (int i = 0 ; i < MESSAGE_CAT_SIZE ; i++) {
617
621
iob->bind (BIND_SIGNATURE_INT32, &data.message_count [i]);
618
622
}
619
623
620
- for (int i = 0 ; i < MAX_MESSAGE_CATEGORIES ; i++) {
624
+ for (int i = 0 ; i < MESSAGE_CAT_SIZE ; i++) {
621
625
iob->bind (BIND_SIGNATURE_INT32, &data.message_delay [i]);
622
626
}
623
627
});
0 commit comments