T_hash32Item Hash32Add(T_hash32 hash, T_word32 key, T_void *p_data) { T_hash32Struct *p_hash ; T_hash32ItemStruct *p_item = HASH32_ITEM_BAD ; DebugRoutine("Hash32Add") ; /* 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) { /* Allocate memory for the item. */ p_item = (T_hash32ItemStruct *) MemAlloc(sizeof(T_hash32ItemStruct)) ; /* Make sure we got the memory. */ DebugCheck(p_item != NULL) ; if (p_item) { /* Fill out the item's info. */ p_item->key = key ; p_item->p_data = p_data ; p_item->ownerHash = hash ; /* Put the item in the full listing. */ p_item->elementInBigList = DoubleLinkListAddElementAtEnd( p_hash->itemList, (T_void *)p_item) ; /* Put the item in the particular hash bucket. */ p_item->elementInHashList = DoubleLinkListAddElementAtEnd( p_hash->p_index[key & p_hash->keyMask], (T_void *)p_item) ; /* Done, mark valid. */ p_item->tag = HASH32_ITEM_TAG ; } } } DebugEnd() ; /* Return what we created, or else BAD */ return ((T_hash32Item)p_item) ; }
/* adds a game to the list of active 'open' games */ T_void GuildUIAddGame(T_word16 mapNumber, T_gameGroupID groupID, T_word16 questNumber) { T_gameDescriptionStruct *p_game; DebugRoutine ("GuildUIAddGame"); p_game=MemAlloc(sizeof(T_gameDescriptionStruct)); p_game->mapNumber=mapNumber; p_game->groupID = groupID ; p_game->questNumber = questNumber; DoubleLinkListAddElementAtEnd (G_gameList,p_game); /* Only redraw the list if we are not joining or creating a game. */ if (PeopleHereGetOurState() == 0) GuildUIDrawGameList(); /* If this is the first time entry, go to it. */ if (DoubleLinkListGetNumberElements(G_gameList) == 1) TxtboxCursTop(G_displayBoxes[GUILD_GAME_LIST]) ; DebugEnd(); }
/* adds a player name to the list of players for the selected game */ T_void GuildUIAddPlayer (T_byte8 *playerName) { T_byte8 *data; T_word32 size; DebugRoutine ("GuildUIAddPlayer"); //size=TxtboxCanFit(G_displayBoxes[GUILD_GAME_DESC],playerName); size = strlen(playerName); data=NULL; data=MemAlloc(size+1); DebugCheck (data != NULL); strncpy (data,playerName,size); data[size]='\0'; /* add personName to list */ DoubleLinkListAddElementAtEnd (G_playerList,data); GuildUIDrawPlayerList(); DebugEnd(); }
T_efxID EfxCreate (E_efxType type, // type of effect T_word32 Xorigin, // x,y,z location of effect T_word32 Yorigin, T_word32 Zorigin, T_word16 numberOf, // number of objects to create E_Boolean transparent, // should objects be transparent? T_word32 extraData) // extra data for some efx { T_doubleLinkListElement myElement=NULL; T_efxStruct *p_efx; DebugRoutine ("EfxCreate"); DebugCheck (type < EFX_UNKNOWN); if (type < EFX_UNKNOWN) { /* create a new efx structure */ p_efx=(T_efxStruct *)MemAlloc(sizeof(T_efxStruct)); DebugCheck (p_efx != NULL); if (p_efx != NULL) { /* initialize a double linked list to hold all newly created */ /* object pointers */ p_efx->objectList=DOUBLE_LINK_LIST_BAD; p_efx->objectList=DoubleLinkListCreate(); DebugCheck (p_efx->objectList != DOUBLE_LINK_LIST_BAD); if (p_efx->objectList != DOUBLE_LINK_LIST_BAD) { /* init extra data */ p_efx->reserved=TickerGet(); p_efx->updateCallback=NULL; p_efx->Xorigin=Xorigin; p_efx->Yorigin=Yorigin; p_efx->Zorigin=Zorigin; p_efx->numberOf=numberOf; p_efx->duration=0; /* add this efx to global list */ p_efx->myID=DoubleLinkListAddElementAtEnd(G_effectsInProgress,p_efx); /* call the effect set up routine */ switch (type) { case EFX_BLOOD_SHRAPNEL: EfxCreateBloodSplat (p_efx->myID,transparent); break; case EFX_WALL_HIT: EfxCreateGenericShrapnel (OBJECT_TYPE_WALL_HIT, p_efx->myID, FALSE, TRUE); break; case EFX_TELEPORT: p_efx->duration=100; EfxCreateGenericExplosion (OBJECT_TYPE_TELEPORT, p_efx->myID, TRUE, 0); AreaSoundCreate( p_efx->Xorigin>>16, p_efx->Yorigin>>16, 500, 255, AREA_SOUND_TYPE_ONCE, 0, AREA_SOUND_BAD, NULL, 0, SOUND_TELEPORT) ; break; case EFX_POWER_EXPLOSION: EfxCreateGenericExplosion (OBJECT_TYPE_POWER_EXPLOSION, p_efx->myID, FALSE, 0); break; case EFX_POISON_EXPLOSION: EfxCreateGenericExplosion (OBJECT_TYPE_POISON_EXPLOSION, p_efx->myID, FALSE, 0); break; case EFX_ACID_EXPLOSION: EfxCreateGenericExplosion (OBJECT_TYPE_ACID_EXPLOSION, p_efx->myID, FALSE, 0); break; case EFX_ELECTRIC_EXPLOSION: EfxCreateGenericExplosion (OBJECT_TYPE_ELECTRIC_EXPLOSION, p_efx->myID, FALSE, -20); break; case EFX_MAGIC_EXPLOSION: EfxCreateGenericExplosion (OBJECT_TYPE_MAGIC_EXPLOSION, p_efx->myID, FALSE, -20); break; case EFX_FIRE_EXPLOSION: EfxCreateGenericExplosion (OBJECT_TYPE_FIRE_EXPLOSION, p_efx->myID, FALSE, -25); EfxCreate (EFX_FLAME_SHRAPNEL, p_efx->Xorigin, p_efx->Yorigin, p_efx->Zorigin, 3, FALSE, 0); break; case EFX_FIRE_SHRAPNEL: p_efx->duration=150; EfxCreateGenericShrapnel(OBJECT_TYPE_FIRE_SHRAPNEL, p_efx->myID, TRUE, FALSE); break; case EFX_FLAME_SHRAPNEL: p_efx->duration=80; EfxCreateGenericShrapnel(OBJECT_TYPE_FLAME_SHRAPNEL, p_efx->myID, TRUE, FALSE); break; case EFX_BONE_SHRAPNEL: p_efx->duration=80; EfxCreateGenericShrapnel(OBJECT_TYPE_BONE_SHRAPNEL, p_efx->myID, TRUE, FALSE); break; case EFX_ACID_SHRAPNEL: EfxCreateGenericShrapnel(OBJECT_TYPE_ACID_SHRAPNEL, p_efx->myID, FALSE, TRUE); break; case EFX_POISON_SHRAPNEL: EfxCreateGenericShrapnel(OBJECT_TYPE_POISON_SHRAPNEL, p_efx->myID, FALSE, TRUE); break; case EFX_ELECTRIC_SHRAPNEL: p_efx->duration=60; EfxCreateGenericShrapnel(OBJECT_TYPE_ELECTRIC_SHRAPNEL, p_efx->myID, TRUE, FALSE); break; case EFX_MAGIC_SHRAPNEL: p_efx->duration=60; EfxCreateGenericShrapnel(OBJECT_TYPE_MANA_SHRAPNEL, p_efx->myID, TRUE, FALSE); break; default: break; } }
/* routine builds a list of maps that the player can create */ static T_void GuildUIBuildMapList (T_void) { T_byte8 stmp[64]; T_byte8 stmp2[512]; T_word16 mapIndex,mapKey; T_byte8 *dataIn; T_resource res; T_word32 size,tempSize; T_word32 inCnt,outCnt; T_byte8 charIn; T_word16 pass=0; T_word16 listcount=0; T_mapDescriptionStruct *p_mapStruct; T_byte8 *listdata=NULL,*temps=NULL; DebugRoutine ("GuildUIBuildMapList"); /* initialize map listings */ G_mapList=DoubleLinkListCreate(); listcount=0; sprintf (stmp,"MAPDESC/DES%05d",listcount++); while (PictureExist(stmp)) { /* alloc space for new map description block */ p_mapStruct = MemAlloc (sizeof(T_mapDescriptionStruct)); DebugCheck (p_mapStruct != NULL); /* lock in data 'text file' */ dataIn=(T_byte8 *)PictureLockData (stmp,&res); size=ResourceGetSize(res); /* scan for newline */ outCnt=inCnt=0; pass=0; while (inCnt < size) { /* get a character from input data */ charIn=dataIn[inCnt++]; stmp2[outCnt++]=charIn; /* check for temporary overflow */ DebugCheck (outCnt<512); if (charIn=='\n') { /* reached 'end of line' */ /* parse our temp string */ stmp2[outCnt]='\0'; outCnt=0; if (pass==0) { /* getting map access (journal page needed ) */ sscanf (stmp2,"%d",&mapKey); p_mapStruct->mapKey=mapKey; } else if (pass==1) { /* getting map number */ sscanf (stmp2,"%d",&mapIndex); p_mapStruct->mapIndex=mapIndex; } else if (pass==2) { /* getting map name */ tempSize=strlen(stmp2); /* alloc string */ p_mapStruct->name=MemAlloc(tempSize+1); strcpy (p_mapStruct->name,stmp2); p_mapStruct->name[strlen(p_mapStruct->name)-2]='\0'; } else if (pass==3) { /* getting map description */ tempSize=strlen(stmp2); /* alloc string */ p_mapStruct->description=MemAlloc(tempSize+1); strcpy (p_mapStruct->description,stmp2); } else { break; } pass++; } } PictureUnlockAndUnfind(res); /* add our structure to global list */ DoubleLinkListAddElementAtEnd (G_mapList,p_mapStruct); /* build our list of maps on the fly */ if (GuildUIPlayerCanVisitMap(listcount)) { sprintf (stmp,"^009%s",p_mapStruct->name); } else { sprintf (stmp,"^010%s",p_mapStruct->name); } /* add stmp to list */ tempSize=strlen(stmp); if (listdata!=NULL) tempSize+=strlen(listdata); temps=MemAlloc(tempSize+2); if (listdata == NULL) sprintf (temps,"%s\r",stmp); else sprintf (temps,"%s%s\r",listdata,stmp); if (listdata != NULL) MemFree (listdata); listdata=temps; listdata[strlen(listdata)]='\0'; /* increment map description file name */ sprintf (stmp,"MAPDESC/DES%05d",listcount++); } TxtboxSetData (G_displayBoxes[GUILD_MAPS_LIST],listdata); TxtboxCursBot(G_displayBoxes[GUILD_MAPS_LIST]); TxtboxBackSpace (G_displayBoxes[GUILD_MAPS_LIST]); TxtboxCursTop(G_displayBoxes[GUILD_MAPS_LIST]); MemFree(listdata); GuildDisplayMapInfo (G_displayBoxes[GUILD_MAPS_LIST]); DebugEnd(); }