T_void GuildUIGetSelectedGame( T_word16 *p_mapNumber, T_gameGroupID *p_groupID, T_word16 *p_quest) { T_word16 i, index ; T_gameDescriptionStruct *p_game ; T_doubleLinkListElement element ; DebugRoutine("GuildUIGetSelectedGame") ; /* Just the appropriate text line on the list. */ index = TxtboxGetSelectionNumber(G_displayBoxes[GUILD_GAME_LIST]) ; element = DoubleLinkListGetFirst(G_gameList) ; for (i=0; i<index; i++) { element = DoubleLinkListElementGetNext(element) ; } if (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { p_game = (T_gameDescriptionStruct *) DoubleLinkListElementGetData(element) ; *p_mapNumber = p_game->mapNumber ; *p_groupID = p_game->groupID ; *p_quest = p_game->questNumber; } else { /* Element not found? Return zero. */ *p_mapNumber = 0 ; *p_groupID = *DirectTalkGetNullBlankUniqueAddress() ; *p_quest = 0 ; } DebugEnd() ; }
/* LES: 06/12/96 */ T_void ClientReceiveSyncPacket( T_packetEitherShortOrLong *p_packet) { T_syncPacket *p_sync ; T_syncronizePacket *p_syncro ; T_gameGroupID groupID ; DebugRoutine("ClientReceiveSyncPacket") ; if (ClientIsActive()) { p_sync = (T_syncPacket *)(p_packet->data) ; /* See if this is the correct group. */ groupID = ClientSyncGetGameGroupID() ; //printf("Us--- %02X:%02X:%02X:%02X:%02X:%02X\n", groupID.address[0],groupID.address[1],groupID.address[2],groupID.address[3],groupID.address[4],groupID.address[5]) ; //printf("Them- %02X:%02X:%02X:%02X:%02X:%02X\n", p_sync->groupID.address[0],p_sync->groupID.address[1],p_sync->groupID.address[2],p_sync->groupID.address[3],p_sync->groupID.address[4],p_sync->groupID.address[5]) ; if (!(CompareGameGroupIDs(p_sync->groupID, *DirectTalkGetNullBlankUniqueAddress()))) { if (CompareGameGroupIDs(p_sync->groupID, groupID)) { p_syncro = (T_syncronizePacket *)(p_sync->syncData) ; //puts("process") ; ClientSyncPacketProcess(p_syncro) ; } } } DebugEnd() ; }
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(); }
/* 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(); }
/** * PeopleHereUpdatePlayer is called per player self ID received. * This routine updates the list and takes appropriate actions. The * player may be moving from room to room or other actions. * * @param p_playerID -- New player information * *<!-----------------------------------------------------------------------*/ T_void PeopleHereUpdatePlayer(T_playerIDSelf *p_playerID) { T_playerIDSelf *p_find; T_playerIDLocation location; T_gameGroupID ourGroupID; char playerLabel[MAX_CHAT_NAME_STRING]; char chatNotification[MAX_CHAT_NAME_STRING]; DebugRoutine("PeopleHereUpdatePlayer"); DebugCheck(p_playerID != NULL); DebugCheck(G_init == TRUE); /* What is our address again? */ ourGroupID = ClientSyncGetGameGroupID(); /* See what our location is. If there is not a match, */ /* we don't care about that location. */ location = IGetOurLocation(); /* First, try finding the player doing the action. */ p_find = IFindByName(p_playerID->name); /* If not found, try creating the player. Must have arrived. */ if (p_find == NULL) p_find = ICreatePlayerID(p_playerID); /* If either work, go ahead and update the status. */ if (p_find) { //Set up player ID string GetPlayerLabel(p_find, playerLabel); /* Check if the location is changing */ if (p_find->location != p_playerID->location) { /* There is a difference, either coming or going. */ /* Is the player entering or exiting? */ if (p_playerID->location == location) { /* Entering */ /* Do an action based on our location. */ switch (location) { case PLAYER_ID_LOCATION_NOWHERE: /* We both are nowhere. nothing happens. */ break; case PLAYER_ID_LOCATION_TOWN: /* Update the town list. */ TownAddPerson(playerLabel); break; case PLAYER_ID_LOCATION_GUILD: /* Action is taken care of below. */ break; case PLAYER_ID_LOCATION_GAME: /* Player is elsewhere. do nothing. */ break; default: /* What? */ DebugCheck(FALSE); break; } } else { /* Exiting */ /* Do an action based on our location. */ switch (location) { case PLAYER_ID_LOCATION_NOWHERE: /* We both are nowhere. nothing happens. */ break; case PLAYER_ID_LOCATION_TOWN: //If player has left town for the guild if (p_find->location == PLAYER_ID_LOCATION_TOWN && p_playerID->location == PLAYER_ID_LOCATION_NOWHERE) { //Notify chatbox sprintf(chatNotification, "^001%s LEFT THE GAME", p_playerID->name); TownUIAddMessage(NULL, chatNotification); } /* Update the town list. */ TownRemovePerson(playerLabel); break; case PLAYER_ID_LOCATION_GUILD: /* Action is taken care of below. */ break; case PLAYER_ID_LOCATION_GAME: /* Player is elsewhere. do nothing. */ break; default: /* What? */ DebugCheck(FALSE); break; } } } // Was there a change of state? if (p_find->state != p_playerID->state) { /* Do guild related events */ if (location == PLAYER_ID_LOCATION_GUILD) { if (!((PeopleHereGetOurState() == PLAYER_ID_STATE_CREATING_GAME) || (PeopleHereGetOurState() == PLAYER_ID_STATE_JOINING_GAME))) { if (p_playerID->state == PLAYER_ID_STATE_CREATING_GAME) { GuildUIAddGame(p_playerID->adventure, p_playerID->groupID, p_playerID->quest); PeopleHereGeneratePeopleInGame(p_playerID->groupID); } else if (p_find->state == PLAYER_ID_STATE_CREATING_GAME) { GuildUIRemoveGame(p_playerID->adventure, p_playerID->groupID); PeopleHereGeneratePeopleInGame( *DirectTalkGetNullBlankUniqueAddress()); } } else { /* Detected that a game is removed. */ if (p_find->state == PLAYER_ID_STATE_CREATING_GAME) { /* Is it our game? */ if (CompareGameGroupIDs(p_find->groupID, ourGroupID)) { /* Act like we pressed the cancel join button. */ GuildUICancelJoinGame(NULL); } } } } } // Are they in the guild and going to our game? if (location == PLAYER_ID_LOCATION_GUILD) { /* Update the list of players if relevant to this group. */ if ((CompareGameGroupIDs(p_find->groupID, ourGroupID)) || (CompareGameGroupIDs(p_playerID->groupID, ourGroupID))) // Yes, in our game now PeopleHereGeneratePeopleInGame(ourGroupID); } /* Only process the state if it changes. */ /* Record the state in all cases. */ p_find->state = p_playerID->state; /* Store the location. */ p_find->location = p_playerID->location; /* Store the new groupID */ p_find->groupID = p_playerID->groupID; if (location == PLAYER_ID_LOCATION_GUILD) { /* Update the list of players if relevant to this group. */ PeopleHereGeneratePeopleInGame(ClientSyncGetGameGroupID()); } } 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_byte8 *DirectTalkGetDestination(T_void) { return (T_byte8 *)DirectTalkGetNullBlankUniqueAddress() ; }
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() ; }