| 3144 | #define MOTD_HEIGHT 256 |
| 3145 | |
| 3146 | int ShowMessageOfTheDay(void) { |
| 3147 | static char szlastmotd[MAX_MOTD_LEN]; |
| 3148 | static char sznewmotd[MAX_MOTD_LEN]; |
| 3149 | int motdlen = MAX_MOTD_LEN; |
| 3150 | int res; |
| 3151 | int rval = 0; |
| 3152 | static void *main_wnd; |
| 3153 | void *close_hs; |
| 3154 | |
| 3155 | int last_motd_version = 0; |
| 3156 | |
| 3157 | DLLDatabaseReadInt("MOTDVersion", &last_motd_version); |
| 3158 | |
| 3159 | if (Motd_version == last_motd_version) { |
| 3160 | // MOTD is old.... |
| 3161 | DLLmprintf(0, "MOTD is old, skipping\n"); |
| 3162 | return 1; |
| 3163 | } |
| 3164 | |
| 3165 | DLLDatabaseWriteInt("MOTDVersion", Motd_version); |
| 3166 | |
| 3167 | void *close_on_text = DLLCreateNewUITextItem(TXT_PXO_CLOSE, UICOL_HOTSPOT_HI); |
| 3168 | void *close_off_text = DLLCreateNewUITextItem(TXT_PXO_CLOSE, UICOL_HOTSPOT_LO); |
| 3169 | void *motd_text = DLLCreateNewUITextItem("PXO Message of the day", UICOL_WINDOW_TITLE); |
| 3170 | |
| 3171 | main_wnd = DLLNewUIGameWindowCreate(0, 0, MOTD_WIDTH, MOTD_HEIGHT, UIF_PROCESS_ALL | UIF_CENTER | NUWF_TITLELARGE); |
| 3172 | |
| 3173 | void *console_item = DLLUIConsoleGadgetCreate(main_wnd, 15, 20, 30, 0, 40, 20, 0); |
| 3174 | void *title = DLLTextCreate(main_wnd, motd_text, 0, 7, UIF_CENTER); |
| 3175 | |
| 3176 | close_hs = DLLHotSpotCreate(main_wnd, UID_OK, KEY_ENTER, close_off_text, close_on_text, 60, MOTD_HEIGHT - 60, 60, 20, |
| 3177 | UIF_CENTER); |
| 3178 | |
| 3179 | DLLDatabaseRead("LastMOTD", szlastmotd, &motdlen); |
| 3180 | |
| 3181 | DLLmprintf(0, "Getting message of the day...\n"); |
| 3182 | DLLCreateSplashScreen(TXT_PXO_CONNECTING, 1); |
| 3183 | int mcode = GetD3MOTD(sznewmotd, MAX_MOTD_LEN); |
| 3184 | do { |
| 3185 | mcode = GetD3MOTD(nullptr, 0); |
| 3186 | res = DLLPollUI(); |
| 3187 | if (res == 99) { |
| 3188 | GetD3MOTDCancel(); |
| 3189 | DLLCloseSplashScreen(); |
| 3190 | goto close_motd; |
| 3191 | } |
| 3192 | DLLDescentDefer(); |
| 3193 | } while (mcode == 0); |
| 3194 | |
| 3195 | DLLCloseSplashScreen(); |
| 3196 | |
| 3197 | if (mcode == 1) { |
| 3198 | DLLmprintf(0, "Message of the day: %s\n", sznewmotd); |
| 3199 | if (strcmp(szlastmotd, sznewmotd) != 0) { |
| 3200 | DLLNewUIGameWindowOpen(main_wnd); |
| 3201 | DLLUIConsoleGadgetputs(console_item, sznewmotd); |
| 3202 | DLLDatabaseWrite("LastMOTD", sznewmotd, strlen(sznewmotd) + 1); |
| 3203 | do { |
no test coverage detected