static T_void HardFormExit(T_buttonID buttonID) { DebugRoutine("HardFormExit"); /* Tell others that I'm no longer creating a game. */ PeopleHereSetOurState(PLAYER_ID_STATE_NONE); /* Send out a message that this is what we are doing. */ ClientSendPlayerIDSelf(); PeopleHereSetOurAdventure(0); ClientSyncSetGameGroupID(*DirectTalkGetNullBlankUniqueAddress()); /* Send out a message that this is what we are doing. */ ClientSendPlayerIDSelf(); ButtonDelete(G_closeButton); G_closeButton = NULL; if (TownUIIsOpen()) { ClientSetNextPlace(0, 0); } else { ClientSetNextPlace(HARDFORM_GOTO_PLACE_OFFSET + HARD_FORM_TOWN, 0); } DebugEnd(); }
/** * After requesting to join, this is the response handler. * * @param unqiueAddress -- unique address of person requesting to join * @param groupID -- ID of group being requested to join * @param adventure -- Number of adventure being requested to join * @param response -- Response to attempted join * * @return Current 16-bit adventure id. * *<!-----------------------------------------------------------------------*/ T_void PeopleHereRespondToJoin( T_directTalkUniqueAddress uniqueAddress, T_gameGroupID groupID, T_word16 adventure, E_respondJoin response) { T_directTalkUniqueAddress ourAddress; DebugRoutine("PeopleHereRespondToJoin"); /* Make sure this refers to us. */ DirectTalkGetUniqueAddress(&ourAddress); if (memcmp(&ourAddress, &uniqueAddress, sizeof(ourAddress)) == 0) { /* Yep, thats us. */ switch (response) { case GAME_RESPOND_JOIN_OK: /* Tell others that I'm trying to join in the game. */ PeopleHereSetOurState(PLAYER_ID_STATE_JOINING_GAME); PeopleHereSetOurAdventure(adventure); ClientSyncSetGameGroupID(groupID); /* we are in. */ GuildUIConfirmJoinGame(); /* Send out a message that this is what we are doing. */ ClientSendPlayerIDSelf(); PeopleHereGeneratePeopleInGame(groupID); break; case GAME_RESPOND_JOIN_FULL: PeopleHereSetOurState(PLAYER_ID_STATE_NONE); MessageAdd("Game is already full."); break; case GAME_RESPOND_JOIN_CANCELED: PeopleHereSetOurState(PLAYER_ID_STATE_NONE); MessageAdd("Game was cancelled."); break; default: DebugCheck(FALSE); break; } } else { /* Not us. Just ignore. */ } DebugEnd(); }
/* should request a game creation from server */ static T_void GuildUICreateGame (T_buttonID buttonID) { DebugRoutine ("GuildUICreateGame"); /* fake it */ // GuildUIConfirmCreateGame(); /* real it */ /* Tell others that I'm creating a game. */ PeopleHereSetOurState(PLAYER_ID_STATE_CREATING_GAME) ; PeopleHereSetOurAdventure(GuildUIGetSelectedAdventure()) ; ClientSyncSetGameGroupID(PeopleHereGetUniqueGroupID()) ; /* Send out a message that this is what we are doing. */ ClientSendPlayerIDSelf() ; GuildUIConfirmCreateGame(); DebugEnd(); }
/* should notify the server that the created game has been canceled */ static T_void GuildUICancelCreateGame (T_buttonID buttonID) { DebugRoutine ("GuildUICancelCreateGame"); /* Go back to nowhere. */ /* Tell others that I'm no longer creating a game. */ PeopleHereSetOurState(PLAYER_ID_STATE_NONE) ; /* Send out a message that this is what we are doing. */ ClientSendPlayerIDSelf() ; PeopleHereSetOurAdventure(0) ; ClientSyncSetGameGroupID(*DirectTalkGetNullBlankUniqueAddress()) ; /* Send out a message that this is what we are doing. */ ClientSendPlayerIDSelf() ; /* reset display */ GuildUIReset(); DebugEnd(); }
T_void GuildUIStart (T_word32 formNum) { T_word16 i; const T_word16 arrowCoordX[4]= { 97, 97, 200, 200}; const T_word16 upArrowCoordY[4]= { 28, 77, 28, 77 }; const T_word16 dnArrowCoordY[4]= { 67, 117, 67, 117}; const T_word16 scrollBarY[4]= { 38, 87, 38, 87 }; const T_word16 dispWindowX1[4]= { 6, 6, 109, 109}; const T_word16 dispWindowY1[4]= { 28, 77, 28, 77 }; const T_word16 dispWindowX2[4]= { 95, 95, 198, 198}; const T_word16 dispWindowY2[4]= { 75, 125, 75, 125}; const E_TxtboxMode dispWindowMode[4]={Txtbox_MODE_SELECTION_BOX, Txtbox_MODE_VIEW_SCROLL_FORM, Txtbox_MODE_SELECTION_BOX, Txtbox_MODE_VIEW_SCROLL_FORM}; const E_TxtboxJustify dispWindowJustify[4]={Txtbox_JUSTIFY_LEFT, Txtbox_JUSTIFY_LEFT, Txtbox_JUSTIFY_CENTER, Txtbox_JUSTIFY_CENTER}; DebugRoutine ("GuildUIStart"); /* load backdrop */ G_backgroundPic=GraphicCreate (4,3,"UI/GUILD/GLDBACK"); for (i=GUILD_GAME_LIST;i<=GUILD_MAPS_DESC;i++) { /* set up display textboxes */ /* scroll bars and control arrows */ G_displayBoxes[i]=TxtboxCreate (dispWindowX1[i], dispWindowY1[i], dispWindowX2[i], dispWindowY2[i], "FontTiny", 0, 0, FALSE, dispWindowJustify[i], dispWindowMode[i], NULL); TxtboxSetData (G_displayBoxes[i]," "); G_upButtons[i]=ButtonCreate (arrowCoordX[i], upArrowCoordY[i], "UI/COMMON/UPARROW", FALSE, 0, NULL, GuildUIUpDisplay); ButtonSetData (G_upButtons[i],i); G_dnButtons[i]=ButtonCreate (arrowCoordX[i], dnArrowCoordY[i], "UI/COMMON/DNARROW", FALSE, 0, NULL, GuildUIDnDisplay); ButtonSetData (G_dnButtons[i],i); if (i%2==0) { G_scrollBars[i]=GraphicCreate (arrowCoordX[i], scrollBarY[i], "UI/GUILD/SB1"); } else { G_scrollBars[i]=GraphicCreate (arrowCoordX[i], scrollBarY[i], "UI/GUILD/SB1"); } TxtboxSetScrollBarObjIDs(G_displayBoxes[i],G_upButtons[i],G_dnButtons[i],G_scrollBars[i]); } /* set up control buttons */ G_joinButton=ButtonCreate (6, 127, "UI/GUILD/JOIN", FALSE, KeyDual(KEY_SCAN_CODE_J,KEY_SCAN_CODE_ALT), NULL, GuildUIJoinGame); G_createButton=ButtonCreate (109, 127, "UI/GUILD/CREATE", FALSE, KeyDual(KEY_SCAN_CODE_C,KEY_SCAN_CODE_ALT), NULL, GuildUICreateGame); /* build map list */ GuildUIBuildMapList(); /* initialize game/player listings */ G_gameList=DoubleLinkListCreate(); G_playerList=DoubleLinkListCreate(); /* set up control callbacks */ TxtboxSetCallback (G_displayBoxes[GUILD_MAPS_LIST],GuildDisplayMapInfo); TxtboxSetCallback (G_displayBoxes[GUILD_GAME_LIST],GuildDisplayGameInfo); /* notify server to send a list of active games */ GuildUIRequestGameList(); /* update graphics */ GraphicUpdateAllGraphics(); /* Set up what we are out. */ ClientSyncSetGameGroupID(*DirectTalkGetNullBlankUniqueAddress()) ; PeopleHereSetOurAdventure(0) ; PeopleHereSetOurState(PLAYER_ID_STATE_NONE) ; /* Ask for people to show themselves. */ PeopleHereReset() ; /* add journal help page if necessary */ if (StatsPlayerHasNotePage(30)==FALSE && StatsPlayerHasNotePage(0)==TRUE) { StatsAddPlayerNotePage(30); } DebugEnd(); }
T_void ClientReceiveGameStartPacket( T_packetEitherShortOrLong *p_packet) { T_gameStartPacket *p_start ; T_word16 i ; T_directTalkUniqueAddress ourAddress ; T_gameGroupID groupID ; T_word16 levelStatus = LEVEL_STATUS_STARTED; DebugRoutine("ClientReceiveGameStartPacket") ; //puts("ClientReceiveGameStartPacket") ; p_start = (T_gameStartPacket *)(p_packet->data) ; /* Set up the time offset. */ MapSetDayOffset(p_start->timeOfDay) ; /* Only consider the packet if we are in the same group. */ //printf("-- %d %d\n", ClientSyncGetGameGroupID(), p_start->groupID) ; groupID = ClientSyncGetGameGroupID() ; if (CompareGameGroupIDs(groupID, p_start->groupID)) { DirectTalkGetUniqueAddress(&ourAddress) ; /* See if we are in the list. */ for (i=0; i<p_start->numPlayers; i++) { if (memcmp(&ourAddress, &p_start->players[i], sizeof(ourAddress)) == 0) break ; } //Level complete packet if (p_start->firstLevel == LEVEL_STATUS_LEVEL_CODE_COMPLETE || p_start->firstLevel == LEVEL_STATUS_LEVEL_CODE_SUCCESS) { G_CompletedPlayers++; if (p_start->firstLevel == LEVEL_STATUS_LEVEL_CODE_SUCCESS) G_SuccessPlayers++; //if we got complete packets from everyone if (G_CompletedPlayers == p_start->numPlayers) { levelStatus = LEVEL_STATUS_COMPLETE; if (G_SuccessPlayers > 0) levelStatus |= LEVEL_STATUS_SUCCESS; TownUIFinishedQuest(levelStatus, p_start->numPlayers, StatsGetCurrentQuestNumber()); //once all players respond, quit the game ClientSyncSetGameGroupID(*DirectTalkGetNullBlankUniqueAddress()); PeopleHereSetOurAdventure(0); PeopleHereSetOurState(PLAYER_ID_STATE_NONE); } } /* Did we find a match? */ else if (i != p_start->numPlayers) { //Reset number of players completed G_CompletedPlayers = 0; G_SuccessPlayers = 0; //puts("Matched") ; /* Yes, we are on the list in the ith position. */ /* Set up the game setup and go. */ ClientSyncSetNumberPlayers(p_start->numPlayers); ClientSetLoginId(i); /* Set up the next jump */ ClientSetNextPlace(p_start->firstLevel, 0); ClientSetAdventureNumber(p_start->adventure); ClientSyncInitPlayersHere(); /* Clear all the messages */ MessageClear(); /* Copy all the player address over to the peophere module. */ for (i = 0; i < p_start->numPlayers; i++) { PeopleHereSetUniqueAddr(i, (&p_start->players[i])); } } else { //puts("Not Matched") ; /* Make sure we are still in the guild and if so drop us. */ if ((PeopleHereGetOurLocation() == PLAYER_ID_LOCATION_GUILD) && (PeopleHereGetOurState() == PLAYER_ID_STATE_JOINING_GAME)) { /* Cancel that game we were joining, it left without us. */ GuildUICancelJoinGame(NULL); /* Nope, we got excluded. */ MessageAdd("Game started without you."); } } } DebugEnd() ; }