Exemple #1
0
void noRoadNode::Destroy_noRoadNode()
{
    DestroyAllRoads();

    Destroy_noCoordBase();
}
void noBaseBuilding::Destroy_noBaseBuilding()
{
	DestroyAllRoads();
	//notify the ai about this
	GAMECLIENT.SendAIEvent(new AIEvent::Building(AIEvent::BuildingDestroyed, x, y, type), player);

	gwg->GetGameInterface()->GI_UpdateMinimap(x, y);

	// evtl Anbauten wieder abreißen
	DestroyBuildingExtensions();

	// ggf. Fenster schließen
	gwg->ImportantObjectDestroyed(x, y);

	// Baukosten zurückerstatten (nicht bei Baustellen)
	if( (GetGOT() != GOT_BUILDINGSITE) && 
		( GameClient::inst().GetGGS().isEnabled(ADDON_REFUND_MATERIALS) || 
		GameClient::inst().GetGGS().isEnabled(ADDON_REFUND_ON_EMERGENCY) ) )
	{
		// lebt unsere Flagge noch?
		noFlag *flag = GetFlag();
		if(flag)
		{
			unsigned int percent_index = 0;

			// wenn Rückerstattung aktiv ist, entsprechende Prozentzahl wählen
			if(GameClient::inst().GetGGS().isEnabled(ADDON_REFUND_MATERIALS))
				percent_index = GameClient::inst().GetGGS().getSelection(ADDON_REFUND_MATERIALS);

			// wenn Rückerstattung bei Notprogramm aktiv ist, 50% zurückerstatten
			else if(gwg->GetPlayer(player)->hasEmergency() && GameClient::inst().GetGGS().isEnabled(ADDON_REFUND_ON_EMERGENCY))
				percent_index = 2;
			
			// wieviel kriegt man von jeder Ware wieder?
			const unsigned int percents[5] = { 0, 25, 50, 75, 100 };
			const unsigned int percent = 10 * percents[percent_index];

			// zurückgaben berechnen (abgerundet)
			unsigned int boards = (percent * BUILDING_COSTS[nation][type].boards) / 1000;
			unsigned int stones = (percent * BUILDING_COSTS[nation][type].stones) / 1000;

			GoodType goods[2] = {GD_BOARDS, GD_STONES};
			bool which = 0;
			while(flag->IsSpaceForWare() && ( boards > 0 || stones > 0 ))
			{
				if( (!which && boards > 0) || (which && stones > 0))
				{
					// Ware erzeugen
					Ware *ware = new Ware(goods[which], 0, flag);
					// Inventur anpassen
					gwg->GetPlayer(player)->IncreaseInventoryWare(goods[which], 1);
					// Abnehmer für Ware finden
					ware->goal = gwg->GetPlayer(player)->FindClientForWare(ware);
					// Ware soll ihren weiteren Weg berechnen
					ware->RecalcRoute();
					// Ware ablegen
					flag->AddWare(ware);
					ware->LieAtFlag(flag);

					if(!which)
						--boards;
					else
						--stones;
				}

				which = !which;
			}

		}
	}

	Destroy_noRoadNode();
}