nobHarborBuilding::nobHarborBuilding(const MapPoint pos, const unsigned char player, const Nation nation) : nobBaseWarehouse(BLD_HARBORBUILDING, pos, player, nation), orderware_ev(NULL) { // ins Militärquadrat einfügen gwg->GetMilitarySquares().Add(this); gwg->RecalcTerritory(*this, false, true); // Alle Waren 0, außer 100 Träger inventory.clear(); // Aktuellen Warenbestand zur aktuellen Inventur dazu addieren AddToInventory(); // Der Wirtschaftsverwaltung Bescheid sagen gwg->GetPlayer(player).AddWarehouse(this); /// Die Meere herausfinden, an die dieser Hafen grenzt for(unsigned i = 0; i < 6; ++i) sea_ids[i] = gwg->IsCoastalPoint(gwg->GetNeighbour(pos, i)); // Post versenden if(GAMECLIENT.GetPlayerID() == this->player) GAMECLIENT.SendPostMessage(new ImagePostMsgWithLocation( _("New harbor building finished"), PMC_GENERAL, pos, BLD_HARBORBUILDING, nation)); }
nobHarborBuilding::nobHarborBuilding(const unsigned short x, const unsigned short y,const unsigned char player,const Nation nation) : nobBaseWarehouse(BLD_HARBORBUILDING,x,y,player,nation), orderware_ev(0) { // ins Militärquadrat einfügen gwg->GetMilitarySquare(x,y).push_back(this); gwg->RecalcTerritory(this,GetMilitaryRadius(),false,true); // Alle Waren 0, außer 100 Träger goods.clear(); real_goods.clear(); // Aktuellen Warenbestand zur aktuellen Inventur dazu addieren AddToInventory(); // Der Wirtschaftsverwaltung Bescheid sagen gwg->GetPlayer(player)->AddWarehouse(this); /// Die Meere herausfinden, an die dieser Hafen grenzt for(unsigned i = 0;i<6;++i) sea_ids[i] = gwg->IsCoastalPoint(gwg->GetXA(x,y,i), gwg->GetYA(x,y,i)); // Post versenden if(GameClient::inst().GetPlayerID() == this->player) GameClient::inst().SendPostMessage(new ImagePostMsgWithLocation( _("New harbor building finished"), PMC_GENERAL, x, y, BLD_HARBORBUILDING, nation)); }
nobStorehouse::nobStorehouse(const unsigned short x, const unsigned short y,const unsigned char player,const Nation nation) : nobBaseWarehouse(BLD_STOREHOUSE,x,y,player,nation) { // Alle Waren 0, außer 100 Träger goods.clear(); real_goods.clear(); // Aktuellen Warenbestand zur aktuellen Inventur dazu addieren AddToInventory(); // Der Wirtschaftsverwaltung Bescheid sagen gwg->GetPlayer(player)->AddWarehouse(this); // Post versenden if(GameClient::inst().GetPlayerID() == this->player) GameClient::inst().SendPostMessage(new ImagePostMsgWithLocation( _("New storehouse finished"), PMC_GENERAL, x, y, BLD_STOREHOUSE, nation)); }
static bool ParseFile(FILE *pFile) { uint8_t size; if(pFile == NULL) { FATAL_ERROR(); return false; } fread(&size, sizeof(char), 1, pFile); fread(room.title, sizeof(char), size, pFile); room.title[size] = '\0'; fread(&size, sizeof(char), 1, pFile); if(size == 0) { room.itemRequirements = 0; } else { fread(&room.itemRequirements, sizeof(char), size, pFile); } while(!FindInInventory(room.itemRequirements) || room.itemRequirements) { fread(&size, sizeof(char), 1, pFile); fseek(pFile, size, SEEK_CUR); fread(&size, sizeof(char), 1, pFile); fread(&room.itemsContained, sizeof(char), size, pFile); fseek(pFile, 4, SEEK_CUR); fread(&size, sizeof(char), 1, pFile); if(size == 0) { room.itemRequirements = 0; } else { fread(&room.itemRequirements, sizeof(char), size, pFile); } } fread(&size, sizeof(char), 1, pFile); fread(room.description, sizeof(char), size, pFile); room.description[size] = '\0'; fread(&size, sizeof(char), 1, pFile); if(size != 0) { fread(&room.itemsContained, sizeof(char), size, pFile); AddToInventory(room.itemsContained); } else { room.itemsContained = 0; } fread(&room.north, sizeof(uint8_t), 1, pFile); fread(&room.east, sizeof(uint8_t), 1, pFile); fread(&room.south, sizeof(uint8_t), 1, pFile); fread(&room.west, sizeof(uint8_t), 1, pFile); room.roomExits = 0; if(room.north) { room.roomExits |= GAME_ROOM_EXIT_NORTH_EXISTS; } if(room.east) { room.roomExits |= GAME_ROOM_EXIT_NORTH_EXISTS; } if(room.south) { room.roomExits |= GAME_ROOM_EXIT_SOUTH_EXISTS; } if(room.west) { room.roomExits |= GAME_ROOM_EXIT_WEST_EXISTS; } fclose(pFile); return true; }
void CInventory::Update() { if (m_bOpen) { GRAPHICS->RenderText(L"Inventory", { -300.0f, 650.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.85f, 0.8f }); GRAPHICS->RenderText(L"Resources", { -700.0f, 475.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.45f, 0.4f }); GRAPHICS->RenderText(L"Items", { -640.0f, -135.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.45f, 0.4f }); string enumSzItem[NUM_ITEMS] = { "Bones", "Wood Log", "Herb", "Gunpowder", "Bomb", "Wood Plank", "Health Potion" }; string numBones = enumSzItem[m_nCursor]; wstring wBones(numBones.begin(), numBones.end()); GRAPHICS->RenderText(wBones.c_str(), { -100.0f, 300.0f }, { 1.0f, 1.0f, 1.0f, 1.0f }, { 0.7f, 0.65f }); float fStockY = 365.0f; for (size_t i = 0; i < NUM_ITEMS; i++) { string strAmmount = "x" + to_string(m_CurrentStock[i]); wstring printStr(strAmmount.begin(), strAmmount.end()); GRAPHICS->RenderText(printStr.c_str(), { -500.0f, fStockY }, { 1.0f, 1.0f, 1.0f, 1.0f }, { 0.4f, 0.3f }); fStockY -= 127.5f; if (i == 3) { fStockY -= 115.0f; } } #pragma region Check Cursor for Craftability //bomb = 2 bone and 2 gunpowder //wood plank = 2 wood //health potion = 1 bone and 2 herb if (CInputManager::GetInstance()->GetControllerBeingUsed() == true) { m_cpInputImgs[0]->SetTexture(L"../Game/Assets/Art/2D/Inventory/UpDPad_Controller.dds"); m_cpInputImgs[1]->SetTexture(L"../Game/Assets/Art/2D/Inventory/DownDPad_Controller.dds"); m_cpInputImgs[2]->SetTexture(L"../Game/Assets/Art/2D/Inventory/AButton_Controller.dds"); m_cpInputImgs[3]->SetTexture(L"../Game/Assets/Art/2D/Inventory/XButton_Controller.dds"); //scale down the button images for crafting m_cpInputImgs[2]->GetVertex2DArr()[1].m_fPosition[0] = 0.15f;//top-right X m_cpInputImgs[2]->GetVertex2DArr()[2].m_fPosition[0] = 0.15f;//bottom-right X m_cpInputImgs[2]->GetVertex2DArr()[0].m_fPosition[1] = 0.0f;//top left Y m_cpInputImgs[2]->GetVertex2DArr()[1].m_fPosition[1] = 0.0f;//top-right Y m_cpInputImgs[3]->GetVertex2DArr()[1].m_fPosition[0] = 0.15f;//top-right X m_cpInputImgs[3]->GetVertex2DArr()[2].m_fPosition[0] = 0.15f;//bottom-right X m_cpInputImgs[3]->GetVertex2DArr()[0].m_fPosition[1] = 0.0f;//top left Y m_cpInputImgs[3]->GetVertex2DArr()[1].m_fPosition[1] = 0.0f;//top-right Y m_cpInputImgs[2]->SetPosition(XMFLOAT3{ -0.3f, -0.45f, m_cpInputImgs[2]->GetPosition().z}); m_cpInputImgs[3]->SetPosition(XMFLOAT3{ 0.125f, -0.45f, m_cpInputImgs[3]->GetPosition().z }); } else { m_cpInputImgs[0]->SetTexture(L"../Game/Assets/Art/2D/Inventory/UpArrow_Keyboard.dds"); m_cpInputImgs[1]->SetTexture(L"../Game/Assets/Art/2D/Inventory/DownArrow_Keyboard.dds"); m_cpInputImgs[2]->SetTexture(L"../Game/Assets/Art/2D/Inventory/Enter_Keyboard.dds"); m_cpInputImgs[3]->SetTexture(L"../Game/Assets/Art/2D/Inventory/SpaceBar_Keyboard.dds"); //scale up the keyboard images for crafting m_cpInputImgs[2]->GetVertex2DArr()[1].m_fPosition[0] = 0.2f;//top-right X m_cpInputImgs[2]->GetVertex2DArr()[2].m_fPosition[0] = 0.2f;//bottom-right X m_cpInputImgs[2]->GetVertex2DArr()[0].m_fPosition[1] = 0.1f;//top left Y m_cpInputImgs[2]->GetVertex2DArr()[1].m_fPosition[1] = 0.1f;//top-right Y m_cpInputImgs[3]->GetVertex2DArr()[1].m_fPosition[0] = 0.2f;//top-right X m_cpInputImgs[3]->GetVertex2DArr()[2].m_fPosition[0] = 0.2f;//bottom-right X m_cpInputImgs[3]->GetVertex2DArr()[0].m_fPosition[1] = 0.1f;//top left Y m_cpInputImgs[3]->GetVertex2DArr()[1].m_fPosition[1] = 0.1f;//top-right Y m_cpInputImgs[2]->SetPosition(XMFLOAT3{ -0.35f, -0.5f, m_cpInputImgs[2]->GetPosition().z }); m_cpInputImgs[3]->SetPosition(XMFLOAT3{ 0.05f, -0.5f, m_cpInputImgs[3]->GetPosition().z }); } switch ((eItems)m_nCursor) { case CInventory::Bones: case CInventory::Wood: case CInventory::Herb: case CInventory::Gunpowder: { m_bAbleToCraft = false; for (unsigned int i = 0; i < 2; i++) m_cpInputImgs[i]->GetRender() = true; m_cpInputImgs[2]->GetRender() = false; m_cpInputImgs[3]->GetRender() = false; } break; case CInventory::Bomb: { if (GetStock(Gunpowder) >= 2 && GetStock(Bones) >= 2) { m_bAbleToCraft = true; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 0.0f, 1.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); } else { m_bAbleToCraft = false; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 1.0f, 0.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); GRAPHICS->RenderText(L"Not Enough Resources", { 250.0f, -225.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.45f, 0.4f }, (eTextMod)1); } for (unsigned int i = 0; i < 4; i++) m_cpInputImgs[i]->GetRender() = true; GRAPHICS->RenderText(L"Craft One", { -175.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }); unsigned int unCraftAllAmount = 0; if (GetStock(Bones) / 2 < GetStock(Gunpowder) / 2) unCraftAllAmount = GetStock(Bones) / 2; else unCraftAllAmount = GetStock(Gunpowder) / 2; string szCraftAll = "Craft All (" + to_string(unCraftAllAmount) + ")"; wstring wszCraftAll(szCraftAll.begin(), szCraftAll.end()); GRAPHICS->RenderText(wszCraftAll.c_str(), { 375.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }, (eTextMod)1); } break; case CInventory::Bridge: { if (GetStock(Wood) >= 1) { m_bAbleToCraft = true; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 0.0f, 1.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); } else { m_bAbleToCraft = false; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 1.0f, 0.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); GRAPHICS->RenderText(L"Not Enough Resources", { 250.0f, -225.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.45f, 0.4f }, (eTextMod)1); } for (unsigned int i = 0; i < 4; i++) m_cpInputImgs[i]->GetRender() = true; GRAPHICS->RenderText(L"Craft One", { -175.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }); unsigned int unCraftAllAmount = GetStock(Wood) * 2; string szCraftAll = "Craft All (" + to_string(unCraftAllAmount) + ")"; wstring wszCraftAll(szCraftAll.begin(), szCraftAll.end()); GRAPHICS->RenderText(wszCraftAll.c_str(), { 375.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }, (eTextMod)1); } break; case CInventory::HealthPotion: { if (GetStock(Herb) >= 2 && GetStock(Bones) >= 1) { m_bAbleToCraft = true; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 0.0f, 1.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); } else { m_bAbleToCraft = false; GRAPHICS->RenderText(L"Craft:", { -200.0f, -200.0f }, { 1.0f, 0.0f, 0.0f, 1.0f }, { 0.75f, 0.7f }, (eTextMod)1); GRAPHICS->RenderText(L"Not Enough Resources", { 250.0f, -225.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.45f, 0.4f }, (eTextMod)1); } for (unsigned int i = 0; i < 4; i++) m_cpInputImgs[i]->GetRender() = true; GRAPHICS->RenderText(L"Craft One", { -175.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }); unsigned int unCraftAllAmount = 0; if (GetStock(Bones) / 2 < GetStock(Herb)) unCraftAllAmount = GetStock(Bones) / 2; else unCraftAllAmount = GetStock(Herb); string szCraftAll = "Craft All (" + to_string(unCraftAllAmount) + ")"; wstring wszCraftAll(szCraftAll.begin(), szCraftAll.end()); GRAPHICS->RenderText(wszCraftAll.c_str(), { 375.0f, -525.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.35f, 0.3f }, (eTextMod)1); } break; default: break; } #pragma endregion #pragma region Input if (CInputManager::GetInstance()->IsKeyPressed("Down") || CInputManager::GetInstance()->IsButtonPressed("Cursor Down")) { AudioSystemWwise::Get()->PostEvent(AK::EVENTS::LOOT); m_vcBoarder[m_nCursor]->GetRender() = true; m_vcBoarder[m_nCursor]->SetTexture(L"../Game/Assets/Art/2D/Inventory/Failbot_Icon_Normal.dds"); if (m_nCursor++ >= (NUM_ITEMS - 1)) { m_nCursor = 0; } m_vcBoarder[m_nCursor]->SetTexture(L"../Game/Assets/Art/2D/Inventory/Failbot_Icon_Selected.dds"); m_cpCurrentItem->SetTexture(m_vIconPaths[m_nCursor]); } if (CInputManager::GetInstance()->IsKeyPressed("Up") || CInputManager::GetInstance()->IsButtonPressed("Cursor Up")) { AudioSystemWwise::Get()->PostEvent(AK::EVENTS::LOOT); m_vcBoarder[m_nCursor]->GetRender() = true; m_vcBoarder[m_nCursor]->SetTexture(L"../Game/Assets/Art/2D/Inventory/Failbot_Icon_Normal.dds"); if (m_nCursor-- <= 0) { m_nCursor = NUM_ITEMS - 1; } m_vcBoarder[m_nCursor]->SetTexture(L"../Game/Assets/Art/2D/Inventory/Failbot_Icon_Selected.dds"); m_cpCurrentItem->SetTexture(m_vIconPaths[m_nCursor]); } if ((CInputManager::GetInstance()->IsKeyPressed("Craft") || CInputManager::GetInstance()->IsButtonPressed("Jump Action")) && m_bAbleToCraft == true) { m_bCrafting = true; m_bCraftAll = false; } if ((CInputManager::GetInstance()->IsKeyPressed("CraftAll") || CInputManager::GetInstance()->IsButtonPressed("Health Potion")) && m_bAbleToCraft == true) { m_bCrafting = true; m_bCraftAll = true; } #pragma endregion #pragma region Input Option text Display string szTooltip[NUM_ITEMS] = { "Dropped by Skeletons", "Dropped from Trees", "Dropped from Bushes", "Dropped by Orcs", "Craftable Item\nRequires: ", "Craftable Item\nRequires: ", "Craftable Item\nRequires: ", }; wstring wToolTip(szTooltip[m_nCursor].begin(), szTooltip[m_nCursor].end()); GRAPHICS->RenderText(wToolTip.c_str(), { -300.0f, 100.0f }, { 0.0f, 0.0f, 0.0f, 1.0f }, { 0.55f, 0.5f }); if (m_nCursor > eItems::Gunpowder) { if (m_nCursor == eItems::Bomb) { XMFLOAT4 f2Color1 = { 1.0f, 0.0f, 0.0f, 1.0f }; XMFLOAT4 f2Color2 = { 1.0f, 0.0f, 0.0f, 1.0f }; string szRequirement1 = "2 Bones"; string szRequirement2 = "2 Gunpowder"; if (GetStock(eItems::Bones) >= 2) { f2Color1 = { 0.0f, 1.0f, 0.0f, 1.0f }; } if (GetStock(eItems::Gunpowder) >= 2) { f2Color2 = { 0.0f, 1.0f, 0.0f, 1.0f }; } wstring wInfo1(szRequirement1.begin(), szRequirement1.end()); wstring wInfo2(szRequirement2.begin(), szRequirement2.end()); GRAPHICS->RenderText(wInfo1.c_str(), { 0.0f, 0.0f }, f2Color1, { 0.55f, 0.5f }); GRAPHICS->RenderText(wInfo2.c_str(), { 0.0f, -60.0f }, f2Color2, { 0.55f, 0.5f }); } else if (m_nCursor == eItems::HealthPotion) { XMFLOAT4 f2Color1 = { 1.0f, 0.0f, 0.0f, 1.0f }; XMFLOAT4 f2Color2 = { 1.0f, 0.0f, 0.0f, 1.0f }; string szRequirement1 = "2 Herbs"; string szRequirement2 = "1 Bone"; if (GetStock(eItems::Herb) >= 2) { f2Color1 = { 0.0f, 1.0f, 0.0f, 1.0f }; } if (GetStock(eItems::Bones) >= 1) { f2Color2 = { 0.0f, 1.0f, 0.0f, 1.0f }; } wstring wInfo1(szRequirement1.begin(), szRequirement1.end()); wstring wInfo2(szRequirement2.begin(), szRequirement2.end()); GRAPHICS->RenderText(wInfo1.c_str(), { 0.0f, 0.0f }, f2Color1, { 0.55f, 0.5f }); GRAPHICS->RenderText(wInfo2.c_str(), { 0.0f, -60.0f }, f2Color2, { 0.55f, 0.5f }); } else if (m_nCursor == eItems::Bridge) { XMFLOAT4 f2Color = { 1.0f, 0.0f, 0.0f, 1.0f }; string szRequirement1 = "1 Wood Log"; if (GetStock(eItems::Wood) >= 1) { f2Color = { 0.0f, 1.0f, 0.0f, 1.0f }; } wstring wInfo1(szRequirement1.begin(), szRequirement1.end()); GRAPHICS->RenderText(wInfo1.c_str(), { 0.0f, 0.0f }, f2Color, { 0.55f, 0.5f }); } } #pragma endregion #pragma region Crafting //user is in the process of crafting if (m_bCrafting == true) { m_cpCraftingBar->GetRender() = true; m_fCraftTime += DELTA_TIME(); if (m_fCraftTime >= CRAFT_TIME) { m_bCrafting = false; m_fCraftTime = 0.0f; m_cpCraftingBar->GetRender() = false; AudioSystemWwise::Get()->PostEvent(AK::EVENTS::CRAFT); #pragma region Removing and Adding Items from Inventory if (m_bCraftAll == true) { switch ((eItems)m_nCursor) { case CInventory::Bomb: { unsigned int numBones = GetStock(Bones); unsigned int numGunpowder = GetStock(Gunpowder); if (numBones % 2 != 0) numBones -= 1; if (numGunpowder % 2 != 0) numGunpowder -= 1; unsigned int totalAdded = 0; if (numBones / 2 < numGunpowder / 2) totalAdded = numBones / 2; else totalAdded = numGunpowder / 2; for (unsigned int i = 0; i < totalAdded; i++) { RemoveFromInventory(Bones, 2); RemoveFromInventory(Gunpowder, 2); AddToInventory(Bomb, 1); } } break; case CInventory::Bridge://wood plank { unsigned int numWood = GetStock(Wood); for (unsigned int i = 0; i < numWood; i++) { RemoveFromInventory(Wood, 1); AddToInventory(Bridge, 2); } } break; case CInventory::HealthPotion: { unsigned int numBones = GetStock(Bones); unsigned int numHerbs = GetStock(Herb); if (numHerbs % 2 != 0) numHerbs -= 1; unsigned int totalAdded = 0; if (numHerbs / 2 < numBones) totalAdded = numHerbs / 2; else totalAdded = numBones; for (unsigned int i = 0; i < totalAdded; i++) { RemoveFromInventory(Bones, 1); RemoveFromInventory(Herb, 2); AddToInventory(HealthPotion, 1); } } break; default: break; } } else { switch ((eItems)m_nCursor) { case CInventory::Bomb: { RemoveFromInventory(Bones, 2); RemoveFromInventory(Gunpowder, 2); AddToInventory(Bomb, 1); } break; case CInventory::Bridge://wood plank { RemoveFromInventory(Wood, 1); AddToInventory(Bridge, 2); } break; case CInventory::HealthPotion: { RemoveFromInventory(Bones, 1); RemoveFromInventory(Herb, 2); AddToInventory(HealthPotion, 1); } break; default: break; } } #pragma endregion m_cpCraftingBar->GetVertex2DArr()[1].m_fPosition[0] = m_fCraftBarStartX; m_cpCraftingBar->GetVertex2DArr()[2].m_fPosition[0] = m_fCraftBarStartX; } // update index 1 and 2 of 2dVert float fRatio = m_fCraftTime / CRAFT_TIME; m_cpCraftingBar->GetVertex2DArr()[1].m_fPosition[0] = m_fCraftBarStartX + (m_fCraftBarSize * fRatio); m_cpCraftingBar->GetVertex2DArr()[2].m_fPosition[0] = m_fCraftBarStartX + (m_fCraftBarSize * fRatio); } #pragma endregion if (CInputManager::GetInstance()->IsKeyPressed("Escape")) Close(); } }
/** * This function sets up anything that needs to happen at the start of the game. This is just * setting the current room to STARTING_ROOM and loading it. It should return SUCCESS if it succeeds * and STANDARD_ERROR if it doesn't. * @return SUCCESS or STANDARD_ERROR */ int GameInit(void) { uint8_t length = 0, store = 0; uint8_t *lengthp = &length, *northp = &room.north, *eastp = &room.east, *southp = &room.south, *westp = &room.west, *storep = &store; int count = 0; //Initialize it to the first room and open the file roomNumber = STARTING_ROOM; FILE *fp = fopen("/room32.txt", "rb"); if (fp == NULL) { FATAL_ERROR(); } fseek(fp, 0, SEEK_SET); //Get the LENGTH of the TITLE section count = fread(lengthp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } //SKIP the FIRST version //COPY the LENGTH # of chars into the title BUFFER count = fread(room.title, sizeof(char), length, fp); if (count < length) { return STANDARD_ERROR; } //SKIP the ITEM REQ section and skip the rest... count = fread(lengthp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } fseek(fp, length, SEEK_CUR); //...desc count = fread(lengthp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } fseek(fp, length, SEEK_CUR); //...items contained count = fread(lengthp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } fseek(fp, length, SEEK_CUR); //...exits fseek(fp, 4, SEEK_CUR); //...Version 1 SKIPPED //SKIP item req of Version 2 count = fread(lengthp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } fseek(fp, length, SEEK_CUR); //Now that all the other data is skipped //Get the LENGTH of the DESC section of V2 count = fread(lengthp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } //COPY the LENGTH # of chars in the desc BUFFER count = fread(room.desc, sizeof(char), length, fp); if (count < length) { return STANDARD_ERROR; } //STORE the items contained INTO player INVENTORY count = fread(lengthp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } int i; for (i = 0; i < length; ++i) { count = fread(storep, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } AddToInventory(store); } //COPY the room numbers for EACH direction count = fread(northp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } count = fread(eastp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } count = fread(southp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } count = fread(westp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } fclose(fp); return SUCCESS; }
/** * @see GameGoNorth */ int GameGoWest(void) { uint8_t length = 0, count = 0, check = 0, store = 0; uint8_t *lengthp = &length, *northp = &room.north, *eastp = &room.east, *southp = &room.south, *westp = &room.west, *checkp = &check, *storep = &store; bool itemPass = false; //Check IF there is an EXTIT to the NORTH if so then load it if (room.west != 0) { //Make the NEXT room number into a string and OPEN that room file sprintf(fileName, fFormat, room.west); FILE *fp = fopen(fileName, "rb"); if (fp == NULL) { FATAL_ERROR(); } //SKIP CURRENT TITLE SECTION Get length of TITLE section and ADD to CURRENT file position count = fread(lengthp, sizeof (uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } //Clear the array and overwrite it memset(room.title, 0, GAME_MAX_ROOM_TITLE_LENGTH); count = fread(room.title, sizeof(char), length, fp); if (count < length) { return STANDARD_ERROR; } //Checks if the ITEMS DO match up; finds appropriate room version while (!itemPass) { // CHECK ITEM REQUIREMENTS section and ADD to CURRENT file position count = fread(lengthp, sizeof (uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } //If their are NO ITEM REQS then its the default version thus BREAK if (length == 0) { itemPass = true; break; } int i; for (i = 0; i < length; ++i) { count = fread(checkp, sizeof (uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } if (FindInInventory(check)) { itemPass = true; } else { itemPass = false; break; } } //If no items returned false-found then the this is the compatible version if (itemPass) { break; } //SKIP DESC SECTION count = fread(lengthp, sizeof (uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } fseek(fp, length, SEEK_CUR); //SKIP ITEM SECTION count = fread(lengthp, sizeof (uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } fseek(fp, length, SEEK_CUR); //SKIP EXIT SECTION count = fread(lengthp, sizeof (uint8_t), 1, fp); fseek(fp, length, SEEK_CUR); } //COPY DESC SECTION of the CONFIRMED version count = fread(lengthp, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } //Clear the array and overwrite it memset(room.desc, 0, GAME_MAX_ROOM_DESC_LENGTH); count = fread(room.desc, sizeof(uint8_t), length, fp); if (count < length) { return STANDARD_ERROR; } //STORE ITEM SECTION of the CONFIRMED version count = fread(lengthp, sizeof (uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } int i; for (i = 0; i < length; ++i) { count = fread(storep, sizeof(uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } AddToInventory(store); } //READ the DIRECTIONS of this version and load it... //...NORTH count = fread(northp, sizeof (uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } //...EAST count = fread(eastp, sizeof (uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } //...SOUTH count = fread(southp, sizeof (uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } //...WEST count = fread(westp, sizeof (uint8_t), 1, fp); if (count < 1) { return STANDARD_ERROR; } fclose(fp); return SUCCESS; } //Otherwise if there WAS NOT a NORTH room then return ERROR else { return STANDARD_ERROR; } //If there was a north room but it didn't finish processing then return standard error return STANDARD_ERROR; }
nobHQ::nobHQ(const MapPoint pos, const unsigned char player, const Nation nation, const bool isTent) : nobBaseWarehouse(BLD_HEADQUARTERS, pos, player, nation), isTent_(isTent) { // StartWaren setzen switch(gwg->GetGGS().startWares) { // sehr wenig case 0: inventory.visual.goods[GD_BEER] = 0; inventory.visual.goods[GD_TONGS] = 1; inventory.visual.goods[GD_HAMMER] = 4; inventory.visual.goods[GD_AXE] = 1; inventory.visual.goods[GD_SAW] = 0; inventory.visual.goods[GD_PICKAXE] = 0; inventory.visual.goods[GD_SHOVEL] = 1; inventory.visual.goods[GD_CRUCIBLE] = 1; inventory.visual.goods[GD_RODANDLINE] = 1; //?? inventory.visual.goods[GD_SCYTHE] = 2; //?? inventory.visual.goods[GD_WATEREMPTY] = 0; inventory.visual.goods[GD_WATER] = 0; inventory.visual.goods[GD_CLEAVER] = 0; inventory.visual.goods[GD_ROLLINGPIN] = 1; inventory.visual.goods[GD_BOW] = 0; inventory.visual.goods[GD_BOAT] = 0; inventory.visual.goods[GD_SWORD] = 0; inventory.visual.goods[GD_IRON] = 0; inventory.visual.goods[GD_FLOUR] = 0; inventory.visual.goods[GD_FISH] = 1; inventory.visual.goods[GD_BREAD] = 2; inventory.visual.goods[GD_SHIELDROMANS] = 0; inventory.visual.goods[GD_WOOD] = 6; inventory.visual.goods[GD_BOARDS] = 11; inventory.visual.goods[GD_STONES] = 17; inventory.visual.goods[GD_SHIELDVIKINGS] = 0; inventory.visual.goods[GD_SHIELDAFRICANS] = 0; inventory.visual.goods[GD_GRAIN] = 0; inventory.visual.goods[GD_COINS] = 0; inventory.visual.goods[GD_GOLD] = 0; inventory.visual.goods[GD_IRONORE] = 4; inventory.visual.goods[GD_COAL] = 4; inventory.visual.goods[GD_MEAT] = 0; inventory.visual.goods[GD_HAM] = 0; inventory.visual.goods[GD_SHIELDJAPANESE] = 0; inventory.visual.people[JOB_HELPER] = 13; inventory.visual.people[JOB_WOODCUTTER] = 2; inventory.visual.people[JOB_FISHER] = 0; inventory.visual.people[JOB_FORESTER] = 1; inventory.visual.people[JOB_CARPENTER] = 1; inventory.visual.people[JOB_STONEMASON] = 1; inventory.visual.people[JOB_HUNTER] = 1; inventory.visual.people[JOB_FARMER] = 0; inventory.visual.people[JOB_MILLER] = 0; inventory.visual.people[JOB_BAKER] = 0; inventory.visual.people[JOB_BUTCHER] = 0; inventory.visual.people[JOB_MINER] = 2; inventory.visual.people[JOB_BREWER] = 0; inventory.visual.people[JOB_PIGBREEDER] = 0; inventory.visual.people[JOB_DONKEYBREEDER] = 0; inventory.visual.people[JOB_IRONFOUNDER] = 0; inventory.visual.people[JOB_MINTER] = 0; inventory.visual.people[JOB_METALWORKER] = 0; inventory.visual.people[JOB_ARMORER] = 1; inventory.visual.people[JOB_BUILDER] = 2; inventory.visual.people[JOB_PLANER] = 1; inventory.visual.people[JOB_PRIVATE] = 13; inventory.visual.people[JOB_PRIVATEFIRSTCLASS] = 0; inventory.visual.people[JOB_SERGEANT] = 0; inventory.visual.people[JOB_OFFICER] = 0; inventory.visual.people[JOB_GENERAL] = 0; inventory.visual.people[JOB_GEOLOGIST] = 2; inventory.visual.people[JOB_SHIPWRIGHT] = 0; inventory.visual.people[JOB_SCOUT] = 1; inventory.visual.people[JOB_PACKDONKEY] = 2; break; // Wenig case 1: inventory.visual.goods[GD_BEER] = 0; inventory.visual.goods[GD_TONGS] = 0; inventory.visual.goods[GD_HAMMER] = 8; inventory.visual.goods[GD_AXE] = 3; inventory.visual.goods[GD_SAW] = 1; inventory.visual.goods[GD_PICKAXE] = 1; inventory.visual.goods[GD_SHOVEL] = 2; inventory.visual.goods[GD_CRUCIBLE] = 2; inventory.visual.goods[GD_RODANDLINE] = 3; inventory.visual.goods[GD_SCYTHE] = 4; inventory.visual.goods[GD_WATEREMPTY] = 0; inventory.visual.goods[GD_WATER] = 0; inventory.visual.goods[GD_CLEAVER] = 1; inventory.visual.goods[GD_ROLLINGPIN] = 1; inventory.visual.goods[GD_BOW] = 1; inventory.visual.goods[GD_BOAT] = 6; inventory.visual.goods[GD_SWORD] = 0; inventory.visual.goods[GD_IRON] = 0; inventory.visual.goods[GD_FLOUR] = 0; inventory.visual.goods[GD_FISH] = 2; inventory.visual.goods[GD_BREAD] = 4; inventory.visual.goods[GD_SHIELDROMANS] = 0; inventory.visual.goods[GD_WOOD] = 12; inventory.visual.goods[GD_BOARDS] = 22; inventory.visual.goods[GD_STONES] = 34; inventory.visual.goods[GD_SHIELDVIKINGS] = 0; inventory.visual.goods[GD_SHIELDAFRICANS] = 0; inventory.visual.goods[GD_GRAIN] = 0; inventory.visual.goods[GD_COINS] = 0; inventory.visual.goods[GD_GOLD] = 0; inventory.visual.goods[GD_IRONORE] = 8; inventory.visual.goods[GD_COAL] = 8; inventory.visual.goods[GD_MEAT] = 3; inventory.visual.goods[GD_HAM] = 0; inventory.visual.goods[GD_SHIELDJAPANESE] = 0; inventory.visual.people[JOB_HELPER] = 26; inventory.visual.people[JOB_WOODCUTTER] = 4; inventory.visual.people[JOB_FISHER] = 0; inventory.visual.people[JOB_FORESTER] = 2; inventory.visual.people[JOB_CARPENTER] = 2; inventory.visual.people[JOB_STONEMASON] = 2; inventory.visual.people[JOB_HUNTER] = 1; inventory.visual.people[JOB_FARMER] = 0; inventory.visual.people[JOB_MILLER] = 0; inventory.visual.people[JOB_BAKER] = 0; inventory.visual.people[JOB_BUTCHER] = 0; inventory.visual.people[JOB_MINER] = 5; inventory.visual.people[JOB_BREWER] = 0; inventory.visual.people[JOB_PIGBREEDER] = 0; inventory.visual.people[JOB_DONKEYBREEDER] = 0; inventory.visual.people[JOB_IRONFOUNDER] = 0; inventory.visual.people[JOB_MINTER] = 0; inventory.visual.people[JOB_METALWORKER] = 1; inventory.visual.people[JOB_ARMORER] = 2; inventory.visual.people[JOB_BUILDER] = 5; inventory.visual.people[JOB_PLANER] = 3; inventory.visual.people[JOB_PRIVATE] = 26; inventory.visual.people[JOB_PRIVATEFIRSTCLASS] = 0; inventory.visual.people[JOB_SERGEANT] = 0; inventory.visual.people[JOB_OFFICER] = 0; inventory.visual.people[JOB_GENERAL] = 0; inventory.visual.people[JOB_GEOLOGIST] = 3; inventory.visual.people[JOB_SHIPWRIGHT] = 0; inventory.visual.people[JOB_SCOUT] = 1; inventory.visual.people[JOB_PACKDONKEY] = 4; break; // Mittel case 2: inventory.visual.goods[GD_BEER] = 6; inventory.visual.goods[GD_TONGS] = 0; inventory.visual.goods[GD_HAMMER] = 16; inventory.visual.goods[GD_AXE] = 6; inventory.visual.goods[GD_SAW] = 2; inventory.visual.goods[GD_PICKAXE] = 2; inventory.visual.goods[GD_SHOVEL] = 4; inventory.visual.goods[GD_CRUCIBLE] = 4; inventory.visual.goods[GD_RODANDLINE] = 6; inventory.visual.goods[GD_SCYTHE] = 8; inventory.visual.goods[GD_WATEREMPTY] = 0; inventory.visual.goods[GD_WATER] = 0; inventory.visual.goods[GD_CLEAVER] = 2; inventory.visual.goods[GD_ROLLINGPIN] = 2; inventory.visual.goods[GD_BOW] = 2; inventory.visual.goods[GD_BOAT] = 12; inventory.visual.goods[GD_SWORD] = 6; inventory.visual.goods[GD_IRON] = 0; inventory.visual.goods[GD_FLOUR] = 0; inventory.visual.goods[GD_FISH] = 4; inventory.visual.goods[GD_BREAD] = 8; inventory.visual.goods[GD_SHIELDROMANS] = 6; inventory.visual.goods[GD_WOOD] = 24; inventory.visual.goods[GD_BOARDS] = 44; inventory.visual.goods[GD_STONES] = 68; inventory.visual.goods[GD_SHIELDVIKINGS] = 0; inventory.visual.goods[GD_SHIELDAFRICANS] = 0; inventory.visual.goods[GD_GRAIN] = 0; inventory.visual.goods[GD_COINS] = 0; inventory.visual.goods[GD_GOLD] = 0; inventory.visual.goods[GD_IRONORE] = 16; inventory.visual.goods[GD_COAL] = 16; inventory.visual.goods[GD_MEAT] = 6; inventory.visual.goods[GD_HAM] = 0; inventory.visual.goods[GD_SHIELDJAPANESE] = 0; inventory.visual.people[JOB_HELPER] = 52; inventory.visual.people[JOB_WOODCUTTER] = 8; inventory.visual.people[JOB_FISHER] = 0; inventory.visual.people[JOB_FORESTER] = 4; inventory.visual.people[JOB_CARPENTER] = 4; inventory.visual.people[JOB_STONEMASON] = 4; inventory.visual.people[JOB_HUNTER] = 2; inventory.visual.people[JOB_FARMER] = 0; inventory.visual.people[JOB_MILLER] = 0; inventory.visual.people[JOB_BAKER] = 0; inventory.visual.people[JOB_BUTCHER] = 0; inventory.visual.people[JOB_MINER] = 10; inventory.visual.people[JOB_BREWER] = 0; inventory.visual.people[JOB_PIGBREEDER] = 0; inventory.visual.people[JOB_DONKEYBREEDER] = 0; inventory.visual.people[JOB_IRONFOUNDER] = 0; inventory.visual.people[JOB_MINTER] = 0; inventory.visual.people[JOB_METALWORKER] = 2; inventory.visual.people[JOB_ARMORER] = 4; inventory.visual.people[JOB_BUILDER] = 10; inventory.visual.people[JOB_PLANER] = 6; inventory.visual.people[JOB_PRIVATE] = 46; inventory.visual.people[JOB_PRIVATEFIRSTCLASS] = 0; inventory.visual.people[JOB_SERGEANT] = 0; inventory.visual.people[JOB_OFFICER] = 0; inventory.visual.people[JOB_GENERAL] = 0; inventory.visual.people[JOB_GEOLOGIST] = 6; inventory.visual.people[JOB_SHIPWRIGHT] = 0; inventory.visual.people[JOB_SCOUT] = 2; inventory.visual.people[JOB_PACKDONKEY] = 8; break; // Viel case 3: inventory.visual.goods[GD_BEER] = 12; inventory.visual.goods[GD_TONGS] = 0; inventory.visual.goods[GD_HAMMER] = 32; inventory.visual.goods[GD_AXE] = 12; inventory.visual.goods[GD_SAW] = 4; inventory.visual.goods[GD_PICKAXE] = 4; inventory.visual.goods[GD_SHOVEL] = 8; inventory.visual.goods[GD_CRUCIBLE] = 8; inventory.visual.goods[GD_RODANDLINE] = 12; inventory.visual.goods[GD_SCYTHE] = 16; inventory.visual.goods[GD_WATEREMPTY] = 0; inventory.visual.goods[GD_WATER] = 0; inventory.visual.goods[GD_CLEAVER] = 4; inventory.visual.goods[GD_ROLLINGPIN] = 4; inventory.visual.goods[GD_BOW] = 4; inventory.visual.goods[GD_BOAT] = 24; inventory.visual.goods[GD_SWORD] = 12; inventory.visual.goods[GD_IRON] = 0; inventory.visual.goods[GD_FLOUR] = 0; inventory.visual.goods[GD_FISH] = 8; inventory.visual.goods[GD_BREAD] = 16; inventory.visual.goods[GD_SHIELDROMANS] = 12; inventory.visual.goods[GD_WOOD] = 48; inventory.visual.goods[GD_BOARDS] = 88; inventory.visual.goods[GD_STONES] = 136; inventory.visual.goods[GD_SHIELDVIKINGS] = 0; inventory.visual.goods[GD_SHIELDAFRICANS] = 0; inventory.visual.goods[GD_GRAIN] = 0; inventory.visual.goods[GD_COINS] = 0; inventory.visual.goods[GD_GOLD] = 0; inventory.visual.goods[GD_IRONORE] = 32; inventory.visual.goods[GD_COAL] = 32; inventory.visual.goods[GD_MEAT] = 12; inventory.visual.goods[GD_HAM] = 0; inventory.visual.goods[GD_SHIELDJAPANESE] = 0; inventory.visual.people[JOB_HELPER] = 104; inventory.visual.people[JOB_WOODCUTTER] = 16; inventory.visual.people[JOB_FISHER] = 0; inventory.visual.people[JOB_FORESTER] = 8; inventory.visual.people[JOB_CARPENTER] = 8; inventory.visual.people[JOB_STONEMASON] = 8; inventory.visual.people[JOB_HUNTER] = 4; inventory.visual.people[JOB_FARMER] = 0; inventory.visual.people[JOB_MILLER] = 0; inventory.visual.people[JOB_BAKER] = 0; inventory.visual.people[JOB_BUTCHER] = 0; inventory.visual.people[JOB_MINER] = 20; inventory.visual.people[JOB_BREWER] = 0; inventory.visual.people[JOB_PIGBREEDER] = 0; inventory.visual.people[JOB_DONKEYBREEDER] = 0; inventory.visual.people[JOB_IRONFOUNDER] = 0; inventory.visual.people[JOB_MINTER] = 0; inventory.visual.people[JOB_METALWORKER] = 4; inventory.visual.people[JOB_ARMORER] = 8; inventory.visual.people[JOB_BUILDER] = 20; inventory.visual.people[JOB_PLANER] = 12; inventory.visual.people[JOB_PRIVATE] = 92; inventory.visual.people[JOB_PRIVATEFIRSTCLASS] = 0; inventory.visual.people[JOB_SERGEANT] = 0; inventory.visual.people[JOB_OFFICER] = 0; inventory.visual.people[JOB_GENERAL] = 0; inventory.visual.people[JOB_GEOLOGIST] = 12; inventory.visual.people[JOB_SHIPWRIGHT] = 0; inventory.visual.people[JOB_SCOUT] = 4; inventory.visual.people[JOB_PACKDONKEY] = 16; break; } inventory.real = inventory.visual; // Aktuellen Warenbestand zur aktuellen Inventur dazu addieren AddToInventory(); // Take 1 as the reserve per rank for(unsigned i = 0; i <= gwg->GetGGS().GetMaxMilitaryRank(); ++i) { reserve_soldiers_claimed_visual[i] = reserve_soldiers_claimed_real[i] = 1; RefreshReserve(i); } // Evtl. liegen am Anfang Waffen im HQ, sodass rekrutiert werden muss TryRecruiting(); // ins Militärquadrat einfügen gwg->GetMilitarySquares().Add(this); gwg->RecalcTerritory(*this, TerritoryChangeReason::Build); }