/* displays information about an open game */ static T_void GuildDisplayGameInfo (T_TxtboxID TxtboxID) { T_sword16 selection; T_doubleLinkListElement element; T_gameDescriptionStruct *p_game; T_mapDescriptionStruct *p_map; T_gameDescriptionStruct blank = { 0, 0 } ; DebugRoutine ("GuildDisplayGameInfo"); selection=TxtboxGetSelectionNumber(TxtboxID); element=DoubleLinkListGetFirst (G_gameList); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { /* compare this game entry to the selection number */ if (selection==0) { /* this is the one - */ p_game=(T_gameDescriptionStruct *)DoubleLinkListElementGetData(element); /* find map */ element=DoubleLinkListGetFirst (G_mapList); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { p_map=(T_mapDescriptionStruct *)DoubleLinkListElementGetData(element); if (p_map->mapIndex==p_game->mapNumber) { /* display this one */ TxtboxCursSetRow (G_displayBoxes[GUILD_MAPS_LIST],selection); TxtboxSetData (G_displayBoxes[GUILD_MAPS_DESC],p_map->description); break; } element=DoubleLinkListElementGetNext(element); selection++; } break; } element=DoubleLinkListElementGetNext(element); selection--; } /* request player list for this game from server here */ if (element != DOUBLE_LINK_LIST_ELEMENT_BAD) GuildUIRequestPlayerListForOpenGame(p_game); else GuildUIRequestPlayerListForOpenGame(&blank) ; DebugEnd(); }
/* removes a player name from the list of players for the selected game */ T_void GuildUIRemovePlayer (T_byte8 *playerName) { T_doubleLinkListElement element; T_byte8 *name; T_word32 size; DebugRoutine ("GuildUIRemovePlayer"); size=TxtboxCanFit(G_displayBoxes[GUILD_GAME_DESC],playerName); element=DoubleLinkListGetFirst(G_playerList); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { name=(T_byte8 *)DoubleLinkListElementGetData(element); if (strncmp(name,playerName,size)==0) { /* remove element */ MemFree(name); DoubleLinkListRemoveElement(element); break; } element=DoubleLinkListElementGetNext(element); } GuildUIDrawPlayerList(); DebugEnd(); }
/* removes a game from the list of active 'open' games */ T_void GuildUIRemoveGame (T_word16 mapNumber, T_gameGroupID groupID) { T_gameDescriptionStruct *p_game; T_doubleLinkListElement element,nextElement; DebugRoutine ("GuildUIRemoveGame"); element=DoubleLinkListGetFirst(G_gameList); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { nextElement=DoubleLinkListElementGetNext(element); p_game=(T_gameDescriptionStruct *)DoubleLinkListElementGetData(element); if ((p_game->mapNumber==mapNumber) && (CompareGameGroupIDs(p_game->groupID, groupID))) { /* remove this one */ MemFree(p_game); DoubleLinkListRemoveElement(element); break; } element=nextElement; } /* Only redraw the list if we are not joining or creating a game. */ if (PeopleHereGetOurState() == 0) GuildUIDrawGameList(); DebugEnd(); }
/* to our current player */ static E_Boolean GuildUIPlayerCanVisitMap (T_word16 which) { T_doubleLinkListElement element; E_Boolean canGo=FALSE; T_word16 count=0; T_mapDescriptionStruct *p_mapDesc; DebugRoutine ("GuildUIPlayerCanVisitMap"); element=DoubleLinkListGetFirst (G_mapList); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { if (count==which) { /* check this map */ p_mapDesc=(T_mapDescriptionStruct *)DoubleLinkListElementGetData(element); if (p_mapDesc->mapKey==0) canGo=TRUE; else if (StatsPlayerHasNotePage(p_mapDesc->mapKey)) canGo=TRUE; break; } count++; element=DoubleLinkListElementGetNext(element); } DebugEnd(); return (canGo); }
/* information block about an adventure */ static T_void GuildDisplayMapInfo (T_TxtboxID TxtboxID) { T_word16 selection; T_mapDescriptionStruct *p_map; T_doubleLinkListElement element; DebugRoutine ("GuildDisplayMapInfo"); selection=TxtboxGetSelectionNumber(TxtboxID); element=DoubleLinkListGetFirst(G_mapList); /* Record that adventure as the selected adventure. */ StatsSetCurrentQuestNumber(selection); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { if (selection==0) { /* display this map information */ p_map=DoubleLinkListElementGetData(element); TxtboxSetData (G_displayBoxes[GUILD_MAPS_DESC],p_map->description); break; } selection-=1; element=DoubleLinkListElementGetNext(element); } DebugEnd(); }
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() ; }
static T_word16 GuildUIGetSelectedAdventure(T_void) { T_word16 adventure ; T_word16 i, index ; T_mapDescriptionStruct *p_map ; T_doubleLinkListElement element ; DebugRoutine("GuildUIGetSelectedAdventure") ; /* Just the appropriate text line on the list. */ index = TxtboxGetSelectionNumber(G_displayBoxes[GUILD_MAPS_LIST]) ; StatsSetCurrentQuestNumber(index); element = DoubleLinkListGetFirst(G_mapList) ; for (i=0; i<index; i++) { element = DoubleLinkListElementGetNext(element) ; } if (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { p_map = (T_mapDescriptionStruct *) DoubleLinkListElementGetData(element) ; adventure = p_map->mapIndex ; } else { /* Element not found? */ DebugCheck(FALSE) ; adventure = 0 ; } DebugEnd() ; return adventure ; }
T_hash32Item Hash32ItemGetNext(T_hash32Item hashItem) { T_hash32ItemStruct *p_item ; T_hash32ItemStruct *p_next ; T_doubleLinkListElement element ; DebugRoutine("Hash32ItemGetNext") ; /* Check to see if the item is bad. */ DebugCheck(hashItem != HASH32_ITEM_BAD) ; if (hashItem != HASH32_ITEM_BAD) { /* Get a quick pointer. */ p_item = (T_hash32ItemStruct *)hashItem ; /* See if the tag is correct. */ DebugCheck(p_item->tag == HASH32_ITEM_TAG) ; if (p_item->tag == HASH32_ITEM_TAG) { /* Item is good. Look up the next item. */ element = DoubleLinkListElementGetNext(p_item->elementInBigList) ; if (element != DOUBLE_LINK_LIST_ELEMENT_BAD) p_next = DoubleLinkListElementGetData(element) ; else p_next = HASH32_ITEM_BAD ; } } DebugEnd() ; return ((T_hash32Item) p_next) ; }
/* redraws the list of open games */ static T_void GuildUIDrawGameList(T_void) { T_doubleLinkListElement element; T_gameDescriptionStruct *p_game=NULL; T_mapDescriptionStruct *p_map=NULL; T_byte8 *listData=NULL; T_byte8 *temp=NULL; T_byte8 stmp[64]; T_word16 count=0; T_word32 size=0; DebugRoutine ("GuildUIDrawGameList"); element=DoubleLinkListGetFirst (G_gameList); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { /* get this element's data */ p_game=(T_gameDescriptionStruct *)DoubleLinkListElementGetData(element); /* find corresponding map information structure */ p_map=GuildUIGetMapDescription(p_game->mapNumber); /* make this data line */ sprintf (stmp,"%s\r",p_map->name); /* add to list */ if (listData != NULL) size=strlen(listData); else size=0; size+=strlen(stmp); temp=MemAlloc(size+2); if (listData != NULL) sprintf (temp,"%s%s",listData,stmp); else strcpy (temp,stmp); if (listData != NULL) MemFree(listData); listData=temp; temp=NULL; element=DoubleLinkListElementGetNext(element); } if (listData != NULL) { /* get rid of last '\r' */ listData[strlen(listData)-1]='\0'; TxtboxSetData(G_displayBoxes[GUILD_GAME_LIST],listData); MemFree(listData); } else { TxtboxSetData(G_displayBoxes[GUILD_GAME_LIST],""); } DebugEnd(); }
T_hash32Item Hash32Find(T_hash32 hash, T_word32 key) { T_hash32Struct *p_hash ; T_hash32ItemStruct *p_item = HASH32_ITEM_BAD ; T_doubleLinkListElement element ; T_doubleLinkList list ; T_hash32ItemStruct *p_itemSearch ; DebugRoutine("Hash32Find") ; /* Make sure this is a valid hash table type. */ DebugCheck(hash != HASH32_BAD) ; if (hash != HASH32_BAD) { /* Get a quick pointer to the header. */ p_hash = (T_hash32Struct *)hash ; /* Make sure this is a pointer to a not already dead */ /* hash table. */ DebugCheck(p_hash->tag == HASH32_TAG) ; if (p_hash->tag == HASH32_TAG) { /* Find the list that the element is definitely in. */ list = p_hash->p_index[key & p_hash->keyMask] ; /* Search the list for a matching key. */ element = DoubleLinkListGetFirst(list) ; while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { /* Get the item in this list. */ p_itemSearch = (T_hash32ItemStruct *) DoubleLinkListElementGetData(element) ; /* See if the keys match */ if (p_itemSearch->key == key) { /* Grab it and break out of this linear search. */ p_item = p_itemSearch ; break ; } /* Find the next element. */ element = DoubleLinkListElementGetNext(element) ; } } } DebugEnd() ; /* Return what we found. */ return ((T_hash32Item)p_item) ; }
/* returns a pointer to a map information structure for map mapIndex */ static T_mapDescriptionStruct* GuildUIGetMapDescription (T_word16 mapIndex) { T_mapDescriptionStruct *mapInfo; T_doubleLinkListElement element; DebugRoutine ("GuildUIGetMapDescription"); element=DoubleLinkListGetFirst (G_mapList); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { mapInfo=(T_mapDescriptionStruct *)DoubleLinkListElementGetData(element); if (mapInfo->mapIndex==mapIndex) break; else mapInfo=NULL; element=DoubleLinkListElementGetNext(element); } DebugCheck (mapInfo != NULL); DebugEnd(); return (mapInfo); }
/* clears all player names from the player list box */ T_void GuildUIClearPlayers (T_void) { T_doubleLinkListElement element,nextElement; T_byte8 *p_name; T_byte8 *test; DebugRoutine ("GuildUIClearPlayers"); element=DoubleLinkListGetFirst(G_playerList); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { nextElement=DoubleLinkListElementGetNext(element); p_name=(T_byte8 *)DoubleLinkListElementGetData(element); MemFree(p_name); DoubleLinkListRemoveElement(element); element=nextElement; } test=TxtboxGetData(G_displayBoxes[GUILD_GAME_DESC]); if (test != NULL) TxtboxSetData(G_displayBoxes[GUILD_GAME_DESC],""); DebugEnd(); }
/* draws current player list (G_playerList) */ static T_void GuildUIDrawPlayerList (T_void) { T_doubleLinkListElement element; T_byte8* listData=NULL; T_byte8* temp=NULL; T_byte8* name=NULL; T_word16 size=0; DebugRoutine ("GuildUIDrawPlayerList"); element=DoubleLinkListGetFirst (G_playerList); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { /* get this element's data */ name=(T_byte8*)DoubleLinkListElementGetData(element); /* find corresponding map information structure */ /* add to list */ if (listData != NULL) size=strlen(listData); else size=0; size+=strlen(name); temp=MemAlloc(size+2); if (listData != NULL) sprintf (temp,"%s%s\r",listData,name); else sprintf (temp,"%s\r",name); if (listData != NULL) MemFree(listData); listData=temp; temp=NULL; element=DoubleLinkListElementGetNext(element); } TxtboxSetData(G_displayBoxes[GUILD_GAME_DESC],listData); if (listData != NULL) MemFree(listData); DebugEnd(); }
T_void GuildUIEnd (T_void) { T_word16 i; T_mapDescriptionStruct *p_map; T_doubleLinkListElement element,nextElement; DebugRoutine ("GuildUIEnd"); /* destroy ui objects */ GraphicDelete (G_backgroundPic); G_backgroundPic=NULL; for (i=0;i<4;i++) { ButtonDelete(G_upButtons[i]); G_upButtons[i]=NULL; ButtonDelete(G_dnButtons[i]); G_dnButtons[i]=NULL; TxtboxDelete (G_displayBoxes[i]); GraphicDelete (G_scrollBars[i]); G_scrollBars[i]=NULL; } ButtonDelete (G_joinButton); ButtonDelete (G_createButton); G_joinButton=NULL; G_createButton=NULL; /* free up maps data */ element=DoubleLinkListGetFirst(G_mapList); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { nextElement=DoubleLinkListElementGetNext(element); p_map=(T_mapDescriptionStruct *)DoubleLinkListElementGetData(element); MemFree (p_map->name); MemFree (p_map->description); MemFree (p_map); element=nextElement; } DoubleLinkListDestroy (G_mapList); G_mapList=DOUBLE_LINK_LIST_BAD; /* free up game list data */ DoubleLinkListFreeAndDestroy(&G_gameList) ; #if 0 element=DoubleLinkListGetFirst(G_gameList); while (element != DOUBLE_LINK_LIST_ELEMENT_BAD) { nextElement=DoubleLinkListElementGetNext(element); p_game=(T_gameDescriptionStruct *)DoubleLinkListElementGetData(element); MemFree(p_game); element=nextElement; } DoubleLinkListDestroy (G_gameList); G_gameList=DOUBLE_LINK_LIST_BAD; #endif /* free up player list data */ // GuildUIClearPlayers(); DoubleLinkListFreeAndDestroy (&G_playerList); // G_playerList=DOUBLE_LINK_LIST_BAD; DebugEnd(); }