1717
1818#define MAX_MESSAGES 1000
1919#define MAX_QUEUE 20
20- #define MAX_MESSAGE_CATEGORIES 20
2120
2221struct message_data_t {
2322 city_message messages[MAX_MESSAGES ];
@@ -49,8 +48,8 @@ struct message_data_t {
4948 uint16_t pop25000 : 1 ;
5049 } population_shown;
5150
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 ];
5453
5554 time_millis last_sound_time[MESSAGE_CAT_RIOT_COLLAPSE + 1 ];
5655
@@ -79,7 +78,7 @@ void city_message_init_scenario(void) {
7978 data.total_messages = 0 ;
8079 data.current_message_id = 0 ;
8180
82- for (int i = 0 ; i < MAX_MESSAGE_CATEGORIES ; i++) {
81+ for (int i = 0 ; i < MESSAGE_CAT_SIZE ; i++) {
8382 data.message_count [i] = 0 ;
8483 data.message_delay [i] = 0 ;
8584 }
@@ -225,7 +224,7 @@ void city_message_post_full(bool use_popup, int template_id, int event_id, int p
225224 should_play_sound = true ;
226225}
227226
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 ) {
229228 auto &data = g_message_data;
230229
231230 int id = new_message_id ();
@@ -249,7 +248,8 @@ static void city_message_post_common(bool use_popup, int message_id, int param1,
249248 msg->param2 = param2;
250249 msg->sequence = data.next_message_sequence ++;
251250 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;
253253
254254 int text_id = city_message_get_text_id (message_id);
255255 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,
271271}
272272
273273void 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 );
275275}
276276
277277void city_message_population_post (bool use_popup, int message_id, int param1, int param2) {
278278 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 );
280280}
281281
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 );
284284}
285285
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 ) {
287287 auto & data = g_message_data;
288288 int use_popup = false ;
289+
289290 if (data.message_delay [category] <= 0 ) {
290291 use_popup = true ;
291292 data.message_delay [category] = 12 ;
292293 }
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);
294297 data.message_count [category]++;
295298}
296299
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) {
298301 auto & data = g_message_data;
299302 if (category == MESSAGE_CAT_FISHING_BLOCKED || category == MESSAGE_CAT_NO_WORKING_DOCK ) {
300303 // 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) {
414417 }
415418}
416419
417- void city_message_reset_category_count (int category) {
420+ void city_message_reset_category_count (e_mesage_category category) {
418421 auto & data = g_message_data;
419422 data.message_count [category] = 0 ;
420423}
421- void city_message_increase_category_count (int category) {
424+ void city_message_increase_category_count (e_mesage_category category) {
422425 auto & data = g_message_data;
423426 data.message_count [category]++;
424427}
425- int city_message_get_category_count (int category) {
428+ int city_message_get_category_count (e_mesage_category category) {
426429 auto & data = g_message_data;
427430 return data.message_count [category];
428431}
429432
430433void city_message_decrease_delays (void ) {
431434 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++) {
433436 if (data.message_delay [i] > 0 )
434437 data.message_delay [i]--;
435438 }
@@ -587,7 +590,8 @@ io_buffer* iob_messages = new io_buffer([](io_buffer* iob, size_t version) {
587590 iob->bind (BIND_SIGNATURE_INT16 , &msg->eventmsg_phrase_id );
588591 iob->bind (BIND_SIGNATURE_INT16 , &msg->req_city_past ); // enum?
589592 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
591595
592596 iob->bind (BIND_SIGNATURE_INT16 , &msg->req_amount_past );
593597 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)
613617 iob->bind (BIND_SIGNATURE_UINT16 , &data.reserved_5 );
614618 iob->bind (BIND_SIGNATURE_UINT8 , &data.reserved_6 );
615619
616- for (int i = 0 ; i < MAX_MESSAGE_CATEGORIES ; i++) {
620+ for (int i = 0 ; i < MESSAGE_CAT_SIZE ; i++) {
617621 iob->bind (BIND_SIGNATURE_INT32 , &data.message_count [i]);
618622 }
619623
620- for (int i = 0 ; i < MAX_MESSAGE_CATEGORIES ; i++) {
624+ for (int i = 0 ; i < MESSAGE_CAT_SIZE ; i++) {
621625 iob->bind (BIND_SIGNATURE_INT32 , &data.message_delay [i]);
622626 }
623627});
0 commit comments