Exemplo n.º 1
0
void NetExclusions::Unpacketize(uint16 id, uint8 *buf, uint16 size)
{
	uint16 packid;
	uint16 pos = 0;

	PULLID(packid);
	Assert(packid == k_PACKET_EXCLUSIONS_ID);

	if(!g_exclusions) {
		g_exclusions = new Exclusions();
	}

	PULLLONG(g_exclusions->m_numUnits);
	PULLLONG(g_exclusions->m_numBuildings);
	PULLLONG(g_exclusions->m_numWonders);

	delete [] g_exclusions->m_units;
	delete [] g_exclusions->m_buildings;
	delete [] g_exclusions->m_wonders;

	g_exclusions->m_units = new sint32[g_exclusions->m_numUnits];
	g_exclusions->m_buildings = new sint32[g_exclusions->m_numBuildings];
	g_exclusions->m_wonders = new sint32[g_exclusions->m_numWonders];
	memset(g_exclusions->m_units, 0, sizeof(sint32) * g_exclusions->m_numUnits);
	memset(g_exclusions->m_buildings, 0, sizeof(sint32) * g_exclusions->m_numBuildings);
	memset(g_exclusions->m_wonders, 0, sizeof(sint32) * g_exclusions->m_numWonders);

	sint32 i;
	sint32 bitPos;
	uint8 next;

	for(i = 0; i < g_exclusions->m_numUnits; i += 8) {
		PULLBYTE(next);
		for(bitPos = 0; (bitPos < 8) && ((i + bitPos) < g_exclusions->m_numUnits); bitPos++) {
			if(next & (1 << bitPos)) {
				g_exclusions->ExcludeUnit(i + bitPos, TRUE);
			}
		}
	}

	for(i = 0; i < g_exclusions->m_numBuildings; i += 8) {
		PULLBYTE(next);
		for(bitPos = 0; (bitPos < 8) && ((i + bitPos) < g_exclusions->m_numBuildings); bitPos++) {
			if(next & (1 << bitPos)) {
				g_exclusions->ExcludeBuilding(i + bitPos, TRUE);
			}
		}
	}

	for(i = 0; i < g_exclusions->m_numWonders; i += 8) {
		PULLBYTE(next);
		for(bitPos = 0; (bitPos < 8) && ((i + bitPos) < g_exclusions->m_numWonders); bitPos++) {
			if(next & (1 << bitPos)) {
				g_exclusions->ExcludeWonder(i + bitPos, TRUE);
			}
		}
	}
}
Exemplo n.º 2
0
/* $3b RTI inherent ##### */
INLINE void rti( void )
{
	PULLBYTE(CC);
	PULLBYTE(B);
	PULLBYTE(A);
	PULLWORD(pX);
	PULLWORD(pPC);
	CHANGE_PC();
	CHECK_IRQ_LINES(); /* HJB 990417 */
}
Exemplo n.º 3
0
static void reti( void )
{
	PULLWORD( PC );
	PULLBYTE( pSR );

	tms7000_icount -= 9;
	tms7000_check_IRQ_lines();
}
Exemplo n.º 4
0
static void pop_st( void )
{
	UINT16	t;

	PULLBYTE(t);
	pSR = t;

	tms7000_icount -= 6;
}
Exemplo n.º 5
0
//----------------------------------------------------------------------------
//
// Name       : NetVision::Unpacketize
//
// Description: Retrieve the data from a received application data packet.
//
// Parameters : id          : Sender identification?
//              buf         : Buffer with received message
//              size        : Length of received message (in bytes)
//
// Globals    : -
//
// Returns    : -
//
// Remark(s)  : -
//
//----------------------------------------------------------------------------
void NetVision::Unpacketize(uint16 id, uint8 *buf, uint16 size)
{
	sint32 pos = 0;
	uint16 packid;
	PULLID(packid);
	Assert(packid == k_PACKET_VISION_ID);

	PULLBYTE(m_owner);
	PULLSHORT(m_row);
	PULLBYTE(m_numRows);

	uint8 *         ptr     = NULL;
	uint8           bitPos  = 0;
	Vision *        vision  = g_player[m_owner]->m_vision;
	sint32          w       = vision->m_width;
	sint32 const    bottom  =
	    std::min<sint32>(m_row + m_numRows, vision->m_height);

	for (sint32 y = m_row; y < bottom; ++y)
	{
		bitPos = 0;
		ptr = &buf[pos] + ((y - m_row) * ((w+7) / 8));
		for (sint32 x = 0; x < vision->m_width; ++x)
		{
			if(*ptr & (1 << bitPos)) {
				vision->m_array[x][y] |= 0x8000;
			} else {
				vision->m_array[x][y] &= 0x7fff;
			}
			bitPos++;
			if(bitPos >= 8) {
				bitPos = 0;
				ptr++;
			}
		}
	}
	if(bitPos != 0) {

		ptr++;
	}
	Assert(size == ptr - buf + 1);

}
Exemplo n.º 6
0
static void pop_b( void )
{
	UINT16	t;

	PULLBYTE(t);
	WRB(t);

	CLR_NZC;
	SET_N8(t);
	SET_Z8(t);

	tms7000_icount -= 6;
}
Exemplo n.º 7
0
static void pop_r( void )
{
	UINT16	t;
	UINT8	r;

	IMMBYTE(r);
	PULLBYTE(t);
	WM(r,t);

	CLR_NZC;
	SET_N8(t);
	SET_Z8(t);

	tms7000_icount -= 8;
}
Exemplo n.º 8
0
void NetCivilization::Unpacketize(uint16 id, uint8 *buf, uint16 size)
{
	sint32 pos = 0;
	uint16 packid;
	uint16 tmp ;
	PULLID(packid);
	Assert(packid == k_PACKET_CIVILIZATION_ID);
	Civilisation cid;

	PULLLONGTYPE(cid, Civilisation);
	
	g_network.CheckReceivedObject((uint32)cid);

	if(!g_theCivilisationPool)
		return;

	if(!g_theCivilisationPool->IsValid(cid)) {
		m_data = new CivilisationData(cid);
	} else {
		m_data = g_theCivilisationPool->AccessData(cid);
	}
	
	m_data->m_id = (uint32)cid;
	PULLBYTETYPE(m_data->m_owner, PLAYER_INDEX);
	PULLBYTETYPE(m_data->m_gender, GENDER);
	PULLSHORT(tmp) ;
	m_data->m_civ = static_cast<sint32>(tmp);
	PULLSTRING(m_data->m_leader_name);
	PULLSTRING(m_data->m_civilisation_name);
	PULLSTRING(m_data->m_country_name);
	PULLSTRING(m_data->m_singular_name);
	PULLSTRING(m_data->m_personality_description);

	uint16 numCityNames;	
	PULLSHORT(numCityNames);
	sint32 i;
	for(i = 0; i < numCityNames; i++) {
		PULLBYTE(m_data->m_cityname_count[i]);
	}

	if(!g_theCivilisationPool->IsValid(cid)) {
		g_theCivilisationPool->HackSetKey(((uint32)cid + k_ID_KEY_MASK) + 1);
		g_theCivilisationPool->Insert(m_data);
		*g_player[m_data->m_owner]->m_civilisation = cid;
	}
}
Exemplo n.º 9
0
void NetSetPlayerGuid::Unpacketize(uint16 id, uint8 *buf, uint16 size)
{
	sint32 pos = 0;
	uint16 packid;
	PULLID(packid);
	Assert(packid == k_PACKET_SET_PLAYER_GUID_ID);

	PULLBYTE(m_player);

	GUID guid;
	memcpy((uint8*)&guid, &buf[pos], sizeof(GUID));
	pos += sizeof(GUID);
	if(g_player[m_player]) {
		g_player[m_player]->m_networkGuid = guid;
	}
	Assert(pos == size);
}
Exemplo n.º 10
0
void NetSetLeaderName::Unpacketize(uint16 id, uint8 *buf, uint16 size)
{
	sint32 pos = 0;
	uint16 packid;
	PULLID(packid);
	Assert(packid == k_PACKET_SET_LEADER_NAME_ID);
	
	MBCHAR nbuf[1024];
	PULLBYTE(m_player);
	PULLSTRING(nbuf);
	if(g_player[m_player]) {
		g_player[m_player]->m_civilisation->AccessData()->SetLeaderName(nbuf);

		if(g_networkPlayersScreen) {
			g_networkPlayersScreen->UpdateData();
		}
	}
}
Exemplo n.º 11
0
void NetCityBuildQueue::Unpacketize(uint16 id, uint8 *buf, uint16 size)
{
	sint32 pos = 0;
	uint16 packid;
	PULLID(packid);
	Assert(packid == k_PACKET_CITY_BQ_ID);
	if(packid != k_PACKET_CITY_BQ_ID)
		return;

	
	Unit city;
	PULLLONGTYPE(city, Unit);
	Assert(g_theUnitPool->IsValid(city));
	if(!g_theUnitPool->IsValid(city))
		return;
	m_cityData = city.AccessData()->GetCityData();

	m_cityData->m_build_queue.Clear(TRUE);
	sint32 len;
	PULLLONG(len);

	BuildNode *bn = NULL;
	for(sint32 i = 0; i < len; i++) {
		bn = new BuildNode;
		PULLLONG(bn->m_cost);
		PULLLONG(bn->m_type);
		PULLLONG(bn->m_category);
		PULLBYTE(bn->m_flags);
		m_cityData->m_build_queue.m_list->AddTail(bn);
	}

	if(g_network.IsHost()) {
		g_network.Block(m_cityData->m_owner);
		
		g_network.Enqueue(m_cityData);
		g_network.Unblock(m_cityData->m_owner);
	}
}
Exemplo n.º 12
0
void NetGameSettings::Unpacketize(uint16 id, uint8 *buf, uint16 size)
{
	uint16 packid;
	uint16 pos = 0;
	uint32 playerMask;

	PULLID(packid);
	Assert(packid == k_PACKET_GAME_SETTINGS_ID);

	PULLLONG(m_x);
	PULLLONG(m_y);
	PULLLONG(m_numPlayers);
	PULLBYTE(m_gameStyle);
	PULLLONG(m_movesPerSlice);
	PULLLONG(m_totalTime);
	PULLLONG(m_turnTime);
	PULLLONG(m_cityTime);
	PULLLONG(playerMask);

	PULLLONG(g_theGameSettings->m_difficulty);
	PULLLONG(g_theGameSettings->m_risk);
	PULLLONG(g_theGameSettings->m_alienEndGame);
	PULLLONG(g_theGameSettings->m_pollution);

	BOOL isYwrap, isXwrap;
	PULLLONG(isYwrap);
	PULLLONG(isXwrap);

	Assert(pos == size);

	if(g_controlPanel) {

	}

	g_tiledMap->CopyVision();

	for(sint32 p = 0; p < k_MAX_PLAYERS; p++) {
		if(g_player[p]) {
			g_player[p]->m_all_armies->FastKillList();
			g_player[p]->GetAllUnitList()->FastKillList();
			g_player[p]->GetAllCitiesList()->FastKillList();
			g_player[p]->GetTradersList()->FastKillList();
			g_player[p]->m_vision->Clear();
		}
	}
	g_theUnitTree->Clear();
	g_theInstallationTree->Clear();
	delete g_theUnitTree;
	g_theUnitTree = NULL;
	delete g_theInstallationTree;
	g_theInstallationTree = NULL;

	g_network.ClearDeadUnits();













	g_theWorld->Reset(sint16(m_x), sint16(m_y), isYwrap, isXwrap);

	sint32 i;
	for(i = 0; i < k_MAX_PLAYERS; i++) {
		if(g_player[i]) {
			delete g_player[i];
		}
	}
	delete [] g_player;

	g_player = new Player *[k_MAX_PLAYERS];
	for(i = 0; i < k_MAX_PLAYERS; i++) {
		g_player[i] = NULL;
	}

	for(i = 0; i < k_MAX_PLAYERS; i++) {
		if(playerMask & (1 << i)) {
			g_player[i] = new Player(i, 0, PLAYER_TYPE_HUMAN);
		}
	}

	delete g_selected_item;
	g_selected_item = new SelectedItem(m_numPlayers);

	g_theUnitTree = new QuadTree<Unit>((sint16)g_theWorld->GetXWidth(),
									   (sint16)g_theWorld->GetYHeight(),
									   g_theWorld->IsYwrap());
	g_theInstallationTree = new InstallationQuadTree((sint16)g_theWorld->GetXWidth(),
													 (sint16)g_theWorld->GetYHeight(),
													 g_theWorld->IsYwrap());

	g_network.SetStyleFromServer(m_gameStyle, m_movesPerSlice, m_totalTime, m_turnTime, m_cityTime);

	g_tiledMap->CopyVision();

	gameinit_ResetForNetwork();

	g_network.SetLoop(TRUE);
}
Exemplo n.º 13
0
void NetCity::Unpacketize(uint16 id, uint8* buf, uint16 size)
{
	Assert(buf[0] == 'C' && buf[1] == 'D');
	Unit uid(getlong(&buf[2]));
	sint32 pos;

	if(g_theUnitPool->IsValid(uid)) {
		DPRINTF(k_DBG_NET, ("Net: received city %lx\n", (uint32)uid));
		UnitData* unitData = g_theUnitPool->AccessUnit(uid);
		uint16 unitSize;
		PLAYER_INDEX oldOwner = unitData->m_owner;

		Assert(unitData->m_city_data != NULL);
		if(unitData->m_city_data == NULL) {
			g_network.RequestResync(RESYNC_INVALID_UNIT);
			return;
		}

		NetUnit::UnpacketizeUnit(&buf[6], unitSize, unitData);

		if(oldOwner != unitData->m_owner) {
			g_player[oldOwner]->RemoveCityReferenceFromPlayer(uid, CAUSE_REMOVE_CITY_UNKNOWN, unitData->m_owner);
			g_player[unitData->m_owner]->AddCityReferenceToPlayer(uid, CAUSE_NEW_CITY_UNKNOWN);
		}
		unitData->m_city_data->m_owner = unitData->m_owner;

		pos = 6 + unitSize;
		CityData* cityData = unitData->m_city_data;

		double oldVision = cityData->GetVisionRadius();

		PULLBYTE(m_isInitialPacket);

		bool resync = false;

#define PLCHK(x) { sint32 tmp = x; PULLLONG(x); if(cityData->GetOwner() == g_network.GetPlayerIndex() && !m_isInitialPacket) { Assert(tmp == x); if(tmp != x) resync = true; }}
#define PSCHK(x) { sint16 tmp = x; PULLSHORT(x); if(cityData->GetOwner() == g_network.GetPlayerIndex() && !m_isInitialPacket) { Assert(tmp == x); if(tmp != x) resync = true; }}
#define PL32CHK(x) { uint32 tmp = x; PULLLONG(x); if(cityData->GetOwner() == g_network.GetPlayerIndex() && !m_isInitialPacket) { Assert(tmp == x); if(tmp != x) resync = true; }}
#define PL64CHK(x) { uint64 tmp = x; PULLLONG64(x); if(cityData->GetOwner() == g_network.GetPlayerIndex() && !m_isInitialPacket) { Assert(tmp == x); if(tmp != x) resync = true; }}
		PL32CHK(cityData->m_slaveBits);
		sint32 shieldstore;
		PULLLONG(shieldstore);
		if(cityData->GetOwner() != g_network.GetPlayerIndex() || m_isInitialPacket) {
			cityData->m_shieldstore = shieldstore;
		}
		PLCHK(cityData->m_shieldstore_at_begin_turn);
		PLCHK(cityData->m_net_gold);
		PLCHK(cityData->m_science);
		PLCHK(cityData->m_luxury);
		PULLLONGTYPE(cityData->m_city_attitude, CITY_ATTITUDE);

		PL64CHK(cityData->m_built_improvements);

		sint32 i;
#ifdef CTP1_TRADE
		uint8 numNonZeroResources;
		PULLBYTE(numNonZeroResources);
		cityData->m_resources.Clear();
		for(i = 0; i < numNonZeroResources; i++) {
			uint8 resource;
			uint16 count;
			PULLBYTE(resource);
			PULLSHORT(count);
			cityData->m_resources.SetResourceCount(resource, count);
		}
#endif

		PLCHK(cityData->m_population);
		for(i = 0; i < (sint32)POP_MAX; i++) {
			PSCHK(cityData->m_numSpecialists[i]);
		}

		PLCHK(cityData->m_partialPopulation);
		PLCHK(cityData->m_sizeIndex);
		PLCHK(cityData->m_workerFullUtilizationIndex);
		PLCHK(cityData->m_workerPartialUtilizationIndex);

		PULLDOUBLE(cityData->m_defensiveBonus);
		PULLBYTE(cityData->m_founder);

		UnpacketizeResources(cityData->m_collectingResources, buf, pos);
		UnpacketizeResources(cityData->m_sellingResources, buf, pos);
		UnpacketizeResources(cityData->m_buyingResources, buf, pos);

		for(sint32 r = 0; r < g_theResourceDB->NumRecords(); r++)
		{
			PULLLONG(cityData->m_distanceToGood[r]);
		}

		cityData->UpdateSprite();

		if(resync)
			g_network.RequestResync(RESYNC_CITY_STATS);
		else if (oldVision != cityData->GetVisionRadius())
		{
			unitData->RemoveOldUnitVision(oldVision);
			unitData->AddUnitVision();
		}
	}
}
Exemplo n.º 14
0
/* $33 PULB inherent ----- */
INLINE void pulb (void)
{
	PULLBYTE(m6808.d.b.l);
}
Exemplo n.º 15
0
/* $32 PULA inherent ----- */
INLINE void pula (void)
{
	PULLBYTE(m6808.d.b.h);
}
Exemplo n.º 16
0
void NetTradeRoute::Unpacketize(uint16 id, uint8 *buf, uint16 size)
{
	sint32 pos;
	uint32 transportCost;
	uint32 passesThrough;
	uint32 sourceCityID;
	uint32 destCityID;
	uint32 recip;
	uint16 numWp;
	sint32 i;

	Assert(MAKE_CIV3_ID(buf[0], buf[1]) == k_PACKET_TRADE_ROUTE_ID);

	TradeRoute route(getlong(&buf[2]));

	g_network.CheckReceivedObject((uint32)route);

	if(!g_theTradePool->IsValid(route)) {
		m_routeData = new TradeRouteData(route);
	} else {
		m_routeData = g_theTradePool->AccessTradeRoute(route);
	}
	pos = 6;
	uint8 newRoute;
	PULLBYTE(newRoute);
	m_newRoute = newRoute != 0;

	PULLBYTETYPE(m_routeData->m_owner, PLAYER_INDEX);
	PULLBYTETYPE(m_routeData->m_payingFor, PLAYER_INDEX);

	PULLLONG(transportCost);
	m_routeData->m_transportCost = transportCost / 10000.;
	PULLBYTETYPE(m_routeData->m_sourceRouteType, ROUTE_TYPE);
	PULLLONG(m_routeData->m_sourceResource);
	
	PULLLONG(passesThrough);
	for(i = 0; i < k_MAX_PLAYERS; i++) {
		m_routeData->m_passesThrough[i] = (passesThrough & (1 << i)) ? TRUE : FALSE;
	}
	PULLBYTE(m_routeData->m_crossesWater);
	PULLBYTE(m_routeData->m_isActive);
	PULLLONG(m_routeData->m_color);
	PULLLONG(m_routeData->m_outline);

	PULLLONG(m_routeData->m_gold_in_return);

	PULLLONG(sourceCityID);
	PULLLONG(destCityID);


	if(!g_theTradePool->IsValid(m_routeData->m_id)) {
		m_routeData->m_sourceCity = Unit(sourceCityID);
		m_routeData->m_destinationCity = Unit(destCityID);
	} else {
		if(m_routeData->m_sourceCity.m_id != sourceCityID) {
			m_routeData->m_sourceCity.DelTradeRoute(route);
			m_routeData->m_sourceCity = Unit(sourceCityID);
			m_routeData->m_sourceCity.AddTradeRoute(route);
		}

		if(m_routeData->m_destinationCity.m_id != destCityID) {
			m_routeData->m_destinationCity.DelTradeRoute(route);
			m_routeData->m_destinationCity = Unit(destCityID);
			m_routeData->m_destinationCity.AddTradeRoute(route);
		}
	}

	PULLLONG(recip);
	m_routeData->m_recip = TradeRoute(recip);

	PULLSHORT(numWp);

	
	m_routeData->RemoveFromCells();

	m_routeData->m_path.Clear();
    PLAYER_INDEX owner;
	for(i = 0; i < numWp; i++) {
		MapPoint pnt;
		PULLSHORTTYPE(pnt.x, sint16);
		PULLSHORTTYPE(pnt.y, sint16);
		m_routeData->m_path.Insert(pnt);
        owner = m_routeData->m_sourceCity.GetOwner(); 
		
		g_theWorld->GetCell(pnt)->AddTradeRoute(route);
	}

	if(!g_theTradePool->IsValid(route)) {
		g_theTradePool->HackSetKey(((uint32)m_routeData->m_id & k_ID_KEY_MASK) + 1);
		g_theTradePool->Insert(m_routeData);
		m_routeData->m_sourceCity.AddTradeRoute(route, !m_newRoute);
		m_routeData->m_destinationCity.AddTradeRoute(route, !m_newRoute);
		g_theTradePool->m_all_routes->Insert(route);
		g_director->TradeActorCreate(route);
	}

	
	TradeManager::Notify();
}
Exemplo n.º 17
0
void NetCity2::Unpacketize(uint16 id, uint8 *buf, uint16 size)
{
	sint32 pos = 0;
	uint16 packid;
	PULLID(packid);
	Assert(packid == k_PACKET_CITY2_ID);
	if(packid != k_PACKET_CITY2_ID)
		return;

	
	Unit home_city;
	PULLLONGTYPE(home_city, Unit);
	
	if(!g_theUnitPool->IsValid(home_city))
		return;
	m_data = home_city.AccessData()->GetCityData();

	if(!m_data) {
		if(g_network.IsClient()) {
			g_network.RequestResync(RESYNC_INVALID_UNIT);
			return;
		} else {
			g_network.Resync(g_network.IdToIndex(id));
			return;
		}
	}

	double oldgross = m_data->m_gross_food, 
		oldproduced = m_data->m_net_food, 
		oldconsumed = m_data->m_food_consumed_this_turn;
	double oldLostToCrime = m_data->m_food_lost_to_crime;
	sint32 oldaccum = m_data->m_accumulated_food;

	PULLLONG(m_data->m_gold_lost_to_crime);
	PULLLONG(m_data->m_gross_gold);
	PULLLONG(m_data->m_goldFromTradeRoutes);
	PULLLONG(m_data->m_gross_production);
	PULLLONG(m_data->m_net_production);
	PULLLONG(m_data->m_production_lost_to_crime);
	PULLLONG64(m_data->m_builtWonders);
	PULLDOUBLE(m_data->m_food_delta);
	PULLDOUBLE(m_data->m_gross_food);
	PULLDOUBLE(m_data->m_net_food);
	PULLDOUBLE(m_data->m_food_lost_to_crime);
	PULLDOUBLE(m_data->m_food_consumed_this_turn);
	PULLLONG(m_data->m_total_pollution);

	uint8 flags;
	PULLBYTE(flags);
	m_data->m_contribute_materials = flags & 0x01;
	m_data->m_contribute_military = (flags & 0x02) >> 1;
	m_data->m_buildCapitalization = (flags & 0x10) >> 4;
	m_data->m_walls_nullified = (flags & 0x20) >> 5;
	m_data->m_isInjoined = (flags & 0x40) >> 6;
	m_data->m_buildInfrastructure = (flags & 0x80) >> 7;

	PULLBYTETYPE(m_data->m_spied_upon, sint32);

	PULLBYTETYPE(m_data->m_franchise_owner, sint8);
	PULLBYTETYPE(m_data->m_franchiseTurnsRemaining, sint8);
	PULLBYTETYPE(m_data->m_watchfulTurns, sint8);
	PULLBYTETYPE(m_data->m_bioInfectionTurns, sint8);
	PULLBYTETYPE(m_data->m_nanoInfectionTurns, sint8);
	PULLBYTETYPE(m_data->m_convertedTo, sint8);
	PULLBYTETYPE(m_data->m_convertedBy, CONVERTED_BY);
	PULLLONG(m_data->m_convertedGold);

	PULLLONG(m_data->m_accumulated_food);


	PULLLONG(m_data->m_foodVatPollution);

	sint8 govSetting;	
	PULLBYTE(govSetting);
	if(govSetting == -1) {
		m_data->m_useGovernor = FALSE;
		m_data->m_buildListSequenceIndex = 0;
	} else {
		m_data->m_useGovernor = TRUE;
		m_data->m_buildListSequenceIndex = govSetting;
	}

	uint8 isInitialPacket;
	PULLBYTE(isInitialPacket);

#if 0
	DPRINTF(k_DBG_NET, ("city: %d, %d, %d, %d, %d, %d, %d, %d, %d\n",
						m_data->m_spied_upon,
						m_data->m_franchise_owner,
						m_data->m_franchiseTurnsRemaining,
						m_data->m_ignore_happiness,
						m_data->m_watchfulTurns,
						m_data->m_bioInfectionTurns,
						m_data->m_nanoInfectionTurns,
						m_data->m_convertedTo,
						m_data->m_convertedBy));
#endif

	if(m_data->m_owner == g_network.GetPlayerIndex() &&
		!isInitialPacket) {
		Assert(oldgross == m_data->m_gross_food);
		Assert(oldLostToCrime == m_data->m_food_lost_to_crime);
		Assert(oldproduced == m_data->m_net_food);
		Assert(oldconsumed == m_data->m_food_consumed_this_turn);
		Assert(oldaccum == m_data->m_accumulated_food);

		if(oldgross != m_data->m_gross_food ||
		   oldLostToCrime != m_data->m_food_lost_to_crime ||
		   oldproduced != m_data->m_net_food ||
		   oldconsumed != m_data->m_food_consumed_this_turn ||
		   oldaccum != m_data->m_accumulated_food) {
			g_network.RequestResync(RESYNC_CITY_STATS);
		}
	}

	Assert(pos == size);
}
Exemplo n.º 18
0
//----------------------------------------------------------------------------
//
// Name       : NetUnseenCell::Unpacketize
//
// Description: Retrieve the data from a received application data packet.
//
// Parameters : id          : Sender identification?
//              buf         : Buffer with received message
//              size        : Length of received message (in bytes)
//
// Globals    : -
//
// Returns    : -
//
// Remark(s)  : -
//
//----------------------------------------------------------------------------
void NetUnseenCell::Unpacketize(uint16 id, uint8 *buf, uint16 size)
{
	uint16 pos = 0;
	uint16 packid;
	PULLID(packid);
	Assert(packid == k_PACKET_UNSEEN_CELL_ID);
	PULLBYTE(m_owner);

	m_ucell = new UnseenCell;

	PULLLONG(m_ucell->m_env);
	PULLBYTETYPE(m_ucell->m_terrain_type, TERRAIN_TYPES);

	PULLSHORT(m_ucell->m_point.x);
	PULLSHORT(m_ucell->m_point.y);
	PULLSHORT(m_ucell->m_move_cost);




	PULLSHORT(m_ucell->m_flags);













	uint8 citySize;
	PULLBYTE(citySize);

	if(citySize > 0) {
		PULLBYTE(m_ucell->m_bioInfectedOwner);
		PULLBYTE(m_ucell->m_nanoInfectedOwner);
		PULLBYTE(m_ucell->m_convertedOwner);
		PULLBYTE(m_ucell->m_franchiseOwner);
		PULLBYTE(m_ucell->m_injoinedOwner);
		PULLBYTE(m_ucell->m_happinessAttackOwner);









		PULLSHORT(m_ucell->m_cityOwner);
		PULLSHORT(m_ucell->m_citySpriteIndex);

		PULLNEWSTRING(m_ucell->m_cityName);







		SpriteState *ss = new SpriteState(0);
		Unit		unitID;

		uint16 dbIndex;
		PULLSHORT(dbIndex);

		double		visionRange = g_theUnitDB->Get(dbIndex, g_player[m_owner]->GetGovernmentType())->GetVisionRange();


		m_ucell->m_actor = new UnitActor(ss,
											unitID,
											(sint32)dbIndex,
											m_ucell->m_point,
											m_ucell->m_cityOwner,
											TRUE,
											visionRange,
											m_ucell->m_citySpriteIndex);
		m_ucell->m_actor->SetUnitVisibility(1 << m_owner);

		m_ucell->m_actor->SetSize(citySize);

		m_ucell->m_actor->ChangeImage(ss, dbIndex, unitID);
	}
	m_ucell->m_citySize = citySize;

#ifdef BATTLE_FLAGS
	PULLSHORT(m_ucell->m_battleFlags);
#endif
	uint8 c, i;
	PULLBYTE(c);
	for(i = 0; i < c; i++) {
		uint8 type;
		uint8 percent;
		PULLBYTE(type);
		PULLBYTE(percent);
		m_ucell->m_improvements->AddTail(
			new UnseenImprovementInfo((TERRAIN_IMPROVEMENT)type,
									  (sint32)percent));
	}

	PULLBYTE(c);
	for(i = 0; i < c; i++) {
		uint8 type;
		uint32 vis;
		PULLBYTE(type);
		PULLLONG(vis);
		m_ucell->m_installations->AddTail(new UnseenInstallationInfo((sint32)type, vis));
	}

	m_ucell->m_tileInfo = new TileInfo;

	PULLBYTE(m_ucell->m_tileInfo->m_riverPiece);
	PULLBYTE(m_ucell->m_tileInfo->m_megaInfo);
	uint16 terrain;
	PULLSHORT(terrain);
	m_ucell->m_tileInfo->m_terrainType = static_cast<uint8>(terrain);
	PULLSHORT(m_ucell->m_tileInfo->m_tileNum);
	for(c = 0; c < k_NUM_TRANSITIONS; c++) {
		PULLBYTE(m_ucell->m_tileInfo->m_transitions[c]);
	}

	g_player[m_owner]->m_vision->AddUnseen(m_ucell);
}