BOOLEAN MAPCREATE_STRUCT::Load(INT8** hBuffer, FLOAT dMajorMapVersion) { if(dMajorMapVersion < 7.0) { _OLD_MAPCREATE_STRUCT OldMapInformation; LOADDATA(&OldMapInformation, *hBuffer, sizeof(_OLD_MAPCREATE_STRUCT)); *this = OldMapInformation; } else LOADDATA(this, *hBuffer, sizeof(MAPCREATE_STRUCT)); return(TRUE); }
// WANNE - BMP: DONE! void LoadWorldItemsFromMap( INT8 **hBuffer, float dMajorMapVersion, int ubMinorMapVersion ) { // Start loading itmes... UINT32 i; WORLDITEM dummyItem; INT32 iItemIndex; UINT32 uiNumWorldItems; //If any world items exist, we must delete them now. TrashWorldItems(); //Read the number of items that were saved in the map. LOADDATA( &uiNumWorldItems, *hBuffer, 4 ); if( gTacticalStatus.uiFlags & LOADING_SAVED_GAME && !gfEditMode ) { //The sector has already been visited. The items are saved in a different format that will be //loaded later on. So, all we need to do is skip the data entirely. if (dMajorMapVersion >= 6.0 && ubMinorMapVersion > 26 ) { for (unsigned int x = 0; x < uiNumWorldItems; ++x) { //ADB WORLDITEM's size on disk is unknown dummyItem.Load(hBuffer, dMajorMapVersion, ubMinorMapVersion); } } else { *hBuffer += sizeof ( OLD_WORLDITEM_101 ) * uiNumWorldItems; } return; } else for ( i = 0; i < uiNumWorldItems; i++ ) { //Add all of the items to the world indirectly through AddItemToPool, but only if the chance //associated with them succeed. dummyItem.Load(hBuffer, dMajorMapVersion, ubMinorMapVersion); gMapTrn.GetTrnCnt(dummyItem.sGridNo);//dnl ch44 270909 WORLDITEM translation if( dummyItem.object.usItem == OWNERSHIP ) { dummyItem.ubNonExistChance = 0; } if( gfEditMode || dummyItem.ubNonExistChance <= PreRandom( 100 ) || (gGameExternalOptions.ubMapItemChanceOverride > 0 && (gGameExternalOptions.ubMapItemChanceOverride >= PreRandom(100)) ) ) //Madd: map item chance override, note this calc is done in reverse { if( !gfEditMode ) { //check for matching item existance modes and only add if there is a match! //if we are in platinum mode, REALISTIC items are allowed, but not SCIFI items if( dummyItem.usFlags & WORLD_ITEM_SCIFI_ONLY && !(gGameOptions.ubGameStyle == STYLE_SCIFI) || dummyItem.usFlags & WORLD_ITEM_REALISTIC_ONLY && (gGameOptions.ubGameStyle == STYLE_SCIFI) ) { //no match, so don't add item to world continue; } /* if ( !gGameOptions.fGunNut ) { UINT16 usReplacement; // do replacements? if ( Item[ dummyItem.object.usItem ].usItemClass == IC_GUN ) { INT8 bAmmo, bNewAmmo; usReplacement = StandardGunListReplacement( dummyItem.object.usItem ); if ( usReplacement ) { // everything else can be the same? no. bAmmo = dummyItem.object[0]->data.gun.ubGunShotsLeft; bNewAmmo = (Weapon[ usReplacement ].ubMagSize * bAmmo) / Weapon[ dummyItem.object.usItem ].ubMagSize; if ( bAmmo > 0 && bNewAmmo == 0 ) { bNewAmmo = 1; } dummyItem.object.usItem = usReplacement; dummyItem.object[0]->data.gun.ubGunShotsLeft = bNewAmmo; } } if ( Item[ dummyItem.object.usItem ].usItemClass == IC_AMMO ) { usReplacement = StandardGunListAmmoReplacement( dummyItem.object.usItem ); if ( usReplacement ) { UINT8 ubLoop; // go through status values and scale up/down for ( ubLoop = 0; ubLoop < dummyItem.object.ubNumberOfObjects; ubLoop++ ) { dummyItem.object.status.bStatus[ ubLoop ] = dummyItem.object.status.bStatus[ ubLoop ] * Magazine[ Item[ usReplacement ].ubClassIndex ].ubMagSize / Magazine[ Item[ dummyItem.object.usItem ].ubClassIndex ].ubMagSize; } // then replace item # dummyItem.object.usItem = usReplacement; } } } */ } if( dummyItem.object.usItem == ACTION_ITEM && gfLoadPitsWithoutArming ) { //if we are loading a pit, they are typically loaded without being armed. if( dummyItem.object[0]->data.misc.bActionValue == ACTION_ITEM_SMALL_PIT || dummyItem.object[0]->data.misc.bActionValue == ACTION_ITEM_LARGE_PIT ) { dummyItem.usFlags &= ~WORLD_ITEM_ARMED_BOMB; dummyItem.bVisible = BURIED; dummyItem.object[0]->data.misc.bDetonatorType = 0; } } else if ( dummyItem.bVisible == HIDDEN_ITEM && dummyItem.object[0]->data.bTrap > 0 && ( Item[dummyItem.object.usItem].mine || dummyItem.object.usItem == TRIP_FLARE || dummyItem.object.usItem == TRIP_KLAXON) ) { ArmBomb( &dummyItem.object, BOMB_PRESSURE ); dummyItem.usFlags |= WORLD_ITEM_ARMED_BOMB; // this is coming from the map so the enemy must know about it. gpWorldLevelData[ dummyItem.sGridNo ].uiFlags |= MAPELEMENT_ENEMY_MINE_PRESENT; } if ( dummyItem.usFlags & WORLD_ITEM_ARMED_BOMB ) { //all armed bombs are buried dummyItem.bVisible = BURIED; } #if 0//dnl ch74 201013 this is already done in OBJECTTYPE::Load() //Madd: ok, so this drives me nuts -- why bother with default attachments if the map isn't going to load them for you? //this should fix that... for(UINT8 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS; cnt++) { if(Item [ dummyItem.object.usItem ].defaultattachments[cnt] == 0) break; OBJECTTYPE defaultAttachment; CreateItem(Item [ dummyItem.object.usItem ].defaultattachments[cnt],100,&defaultAttachment); dummyItem.object.AttachObject(NULL,&defaultAttachment, FALSE); } #endif AddItemToPoolAndGetIndex( dummyItem.sGridNo, &dummyItem.object, dummyItem.bVisible, dummyItem.ubLevel, dummyItem.usFlags, dummyItem.bRenderZHeightAboveLevel, dummyItem.soldierID, &iItemIndex ); gWorldItems[ iItemIndex ].ubNonExistChance = dummyItem.ubNonExistChance; } } if ( !gfEditMode ) { DeleteWorldItemsBelongingToTerroristsWhoAreNotThere(); if ( gWorldSectorX == 3 && gWorldSectorY == MAP_ROW_P && gbWorldSectorZ == 1 ) { DeleteWorldItemsBelongingToQueenIfThere(); } } }