MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / BuddyBotDownloadData

Function BuddyBotDownloadData

Descent3/buddymenu.cpp:373–439  ·  view source on GitHub ↗

downloads data for the buddybot on return: if 1, process data if 0, abort if -1, no guidebot

Source from the content-addressed store, hash-verified

371// if 0, abort
372// if -1, no guidebot
373int BuddyBotDownloadData(void) {
374 if ((!(Game_mode & GM_MULTI)) || (Netgame.local_role != LR_CLIENT)) {
375 // no need to download data, we already have access to it
376 // fill in Guidebot_menu_data and leave
377 object *b_obj = ObjGet(Buddy_handle[Player_object->id]);
378 ASSERT(b_obj);
379
380 gb_com command;
381 command.action = COM_GET_MENU;
382 command.ptr = (void *)&Guidebot_menu_data;
383
384 AINotify(b_obj, AIN_USER_DEFINED, (void *)&command);
385
386 if (Guidebot_menu_data.num_commands == 0) {
387 AddHUDMessage(TXT_NOGUIDEBOT);
388 return -1;
389 }
390
391 return 1;
392 }
393
394 // we are a client in a multiplayer game, we must request from the server
395 Guidebot_data_download_status = 0; // processesing
396 MultiAskforGuidebotMenu();
397
398 // now we must 'process' until Guidebot_data_download_status no longer is 0
399 newuiTiledWindow hwnd;
400 newuiSheet *sheet;
401 hwnd.Create(TXT_GUIDEBOT, 0, 0, 288, 128);
402 sheet = hwnd.GetSheet();
403 sheet->NewGroup(NULL, 5, 10);
404 sheet->AddText(TXT_ACCESSGUIDEBOT);
405 sheet->NewGroup(NULL, 40, 30);
406 sheet->AddText(TXT_ESCTOCANCEL);
407 hwnd.AddAcceleratorKey(KEY_ESC, UID_CANCEL);
408
409 hwnd.Open();
410 while (Guidebot_data_download_status == 0) {
411 int res = hwnd.DoUI();
412
413 switch (res) {
414 case UID_OK:
415 case UID_CANCEL:
416 case NEWUIRES_FORCEQUIT:
417 if (Guidebot_data_download_status == 1) {
418 // we recieved data
419 Multi_bail_ui_menu = false;
420 } else {
421 Guidebot_data_download_status = -1;
422 }
423 break;
424 default:
425 break;
426 }
427 }
428 hwnd.Close();
429 hwnd.Destroy();
430

Callers 1

BuddyDisplayFunction · 0.85

Calls 13

ObjGetFunction · 0.85
AINotifyFunction · 0.85
AddHUDMessageFunction · 0.85
MultiAskforGuidebotMenuFunction · 0.85
GetSheetMethod · 0.80
NewGroupMethod · 0.80
AddTextMethod · 0.80
AddAcceleratorKeyMethod · 0.80
CreateMethod · 0.45
OpenMethod · 0.45
DoUIMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected