void NetGameSettings::Packetize(uint8 *buf, uint16 &size)
{
	size = 0;
	PUSHID(k_PACKET_GAME_SETTINGS_ID);

	PUSHLONG(m_x);
	PUSHLONG(m_y);
	PUSHLONG(m_numPlayers);
	PUSHBYTE(m_gameStyle);
	PUSHLONG(m_movesPerSlice);
	PUSHLONG(m_totalTime);
	PUSHLONG(m_turnTime);
	PUSHLONG(m_cityTime);
	uint32 playerMask = 0;
	for(sint32 i = 0; i < k_MAX_PLAYERS; i++) {
		if(g_player[i])
			playerMask |= (1 << i);
	}
	PUSHLONG(playerMask);

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

	PUSHLONG(g_theWorld->m_isYwrap);
	PUSHLONG(g_theWorld->m_isXwrap);
}
示例#2
0
void NetCityName::Packetize(uint8* buf, uint16 &size)
{
	size = 0;
	PUSHID(k_PACKET_CITY_NAME_ID);
	PUSHLONG((uint32)m_cityData->m_home_city);
	PUSHSTRING(m_cityData->m_name);
}
示例#3
0
void NetGuid::Packetize(uint8 *buf, uint16 &size)
{
	size = 0;
	PUSHID(k_PACKET_GUID_ID);
	memcpy(&buf[size], (uint8*)m_guid, sizeof(*m_guid));
	size += sizeof(*m_guid);
}
示例#4
0
void NetSetLeaderName::Packetize(uint8 *buf, uint16 &size)
{
	size = 0;
	PUSHID(k_PACKET_SET_LEADER_NAME_ID);
	
	PUSHBYTE(m_player);
	PUSHSTRING(g_player[m_player]->m_civilisation->GetLeaderName());
}
示例#5
0
void NetSetPlayerGuid::Packetize(uint8 *buf, uint16 &size)
{
	size = 0;
	PUSHID(k_PACKET_SET_PLAYER_GUID_ID);
	PUSHBYTE(m_player);
	memcpy(&buf[size], (uint8*)&g_player[m_player]->m_networkGuid, sizeof(GUID));
	size += sizeof(GUID);
}
示例#6
0
void NetCityResources::Packetize(uint8 *buf, uint16 &size)
{
	size = 0;
	PUSHID(k_PACKET_RESOURCES_ID);
	PUSHLONG((uint32)m_cityData->m_home_city);
#ifdef CTP1_TRADE
	PUSHLONG(m_cityData->m_resources.m_numGoods);
	PUSHLONG(m_cityData->m_resources.m_totalResources);
	sint32 i;
	for(i = 0; i < m_cityData->m_resources.m_numGoods; i++) {
		PUSHLONG(m_cityData->m_resources.m_supply[i]);
	}
#endif
}
示例#7
0
void NetCityBuildQueue::Packetize(uint8 *buf, uint16 &size)
{
	size = 0;
	PUSHID(k_PACKET_CITY_BQ_ID);

	PUSHLONG((uint32)m_cityData->m_home_city);
	PUSHLONG(m_cityData->m_build_queue.m_list->GetCount());

	PointerList<BuildNode>::Walker walk(m_cityData->m_build_queue.m_list);
	while(walk.IsValid()) {
		BuildNode *bn = walk.GetObj();
		PUSHLONG(bn->m_cost);
		PUSHLONG(bn->m_type);
		PUSHLONG(bn->m_category);
		PUSHBYTE(bn->m_flags);

		walk.Next();
	}
}
示例#8
0
//----------------------------------------------------------------------------
//
// Name       : NetVision::Packetize
//
// Description: Generate an application data packet to transmit.
//
// Parameters : buf         : buffer to store the message
//
// Globals    : -
//
// Returns    : size        : number of bytes stored in buf
//
// Remark(s)  : -
//
//----------------------------------------------------------------------------
void NetVision::Packetize(uint8 *buf, uint16 &size)
{
	size = 0;
	PUSHID(k_PACKET_VISION_ID);
	PUSHBYTE(m_owner);
	PUSHSHORT(m_row);
	PUSHBYTE(m_numRows);

	uint8 *ptr = NULL;
	uint8 bitPos = 0;
	Vision *vision = g_player[m_owner]->m_vision;
	sint32 w = vision->m_width;
	sint32 bottom = m_row + m_numRows;
	if(bottom > vision->m_height)
		bottom = vision->m_height;

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

		ptr++;
	}
	size = ptr - buf + 1;
}
示例#9
0
void NetCivilization::Packetize(uint8 *buf, uint16 &size)
{
	size = 0;
	PUSHID(k_PACKET_CIVILIZATION_ID);

	PUSHLONG(m_data->m_id);
	PUSHBYTE((uint8)m_data->m_owner);
	PUSHBYTE((uint8)m_data->m_gender);
	PUSHSHORT((uint16)m_data->m_civ);
	PUSHSTRING(m_data->m_leader_name);
	PUSHSTRING(m_data->m_civilisation_name);
	PUSHSTRING(m_data->m_country_name);
	PUSHSTRING(m_data->m_singular_name);
	PUSHSTRING(m_data->m_personality_description);
	
	uint16 numCityNames = (uint16)g_theCivilisationDB->Get(m_data->m_civ)->GetNumCityName();
	PUSHSHORT(numCityNames);
	sint32 i;
	for(i = 0; i < numCityNames; i++) {
		PUSHBYTE(m_data->m_cityname_count[i]);
	}
}
示例#10
0
void NetExclusions::Packetize(uint8 *buf, uint16 &size)
{
	PUSHID(k_PACKET_EXCLUSIONS_ID);
	PUSHLONG(g_exclusions->m_numUnits);
	PUSHLONG(g_exclusions->m_numBuildings);
	PUSHLONG(g_exclusions->m_numWonders);

	sint32 i;
	sint32 bitPos;
	uint8 next;
	for(i = 0; i < g_exclusions->m_numUnits; i += 8) {
		next = 0;
		for(bitPos = 0; (bitPos < 8) && ((i + bitPos) < g_exclusions->m_numUnits); bitPos++) {
			if(g_exclusions->IsUnitExcluded(i + bitPos))
				next |= 1 << bitPos;
		}
		PUSHBYTE(next);
	}

	for(i = 0; i < g_exclusions->m_numBuildings; i += 8) {
		next = 0;
		for(bitPos = 0; (bitPos < 8) && ((i + bitPos) < g_exclusions->m_numBuildings); bitPos++) {
			if(g_exclusions->IsBuildingExcluded(i + bitPos))
				next |= 1 << bitPos;
		}
		PUSHBYTE(next);
	}

	for(i = 0; i < g_exclusions->m_numWonders; i += 8) {
		next = 0;
		for(bitPos = 0; (bitPos < 8) && ((i + bitPos) < g_exclusions->m_numWonders); bitPos++) {
			if(g_exclusions->IsWonderExcluded(i + bitPos))
				next |= 1 << bitPos;
		}
		PUSHBYTE(next);
	}
}
示例#11
0
void NetCity2::Packetize(uint8* buf, uint16 &size)
{
	size = 0;
	PUSHID(k_PACKET_CITY2_ID);

	PUSHLONG((uint32)m_data->m_home_city);
	
	PUSHLONG(m_data->m_gold_lost_to_crime);
	PUSHLONG(m_data->m_gross_gold);
	PUSHLONG(m_data->m_goldFromTradeRoutes);
	PUSHLONG(m_data->m_gross_production);
	PUSHLONG(m_data->m_net_production);
	PUSHLONG(m_data->m_production_lost_to_crime);
	PUSHLONG64((uint64)m_data->m_builtWonders);
	PUSHDOUBLE(m_data->m_food_delta);
	PUSHDOUBLE(m_data->m_gross_food);
	PUSHDOUBLE(m_data->m_net_food);
	PUSHDOUBLE(m_data->m_food_lost_to_crime);
	PUSHDOUBLE(m_data->m_food_consumed_this_turn);
	PUSHLONG(m_data->m_total_pollution);

	uint8 flags = 
		(uint8)m_data->m_contribute_materials |
		((uint8)m_data->m_contribute_military << 1) |
		((uint8)m_data->m_buildCapitalization << 4) |
		((uint8)m_data->m_walls_nullified << 5) |
		((uint8)m_data->m_isInjoined << 6) |
		((uint8)m_data->m_buildInfrastructure << 7);
	PUSHBYTE(flags);

#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
						
	PUSHBYTE((sint8)m_data->m_spied_upon);

	PUSHBYTE((sint8)m_data->m_franchise_owner);
	PUSHBYTE((sint8)m_data->m_franchiseTurnsRemaining);
	
#ifdef _DEBUG
	
#endif
	PUSHBYTE((sint8)m_data->m_watchfulTurns);
	PUSHBYTE((sint8)m_data->m_bioInfectionTurns);
	PUSHBYTE((sint8)m_data->m_nanoInfectionTurns);
	PUSHBYTE((sint8)m_data->m_convertedTo);
	PUSHBYTE((sint8)m_data->m_convertedBy);
	PUSHLONG(m_data->m_convertedGold);

	PUSHLONG(m_data->m_accumulated_food);
	

	
	

	PUSHLONG(m_data->m_foodVatPollution);
	sint8 govSetting = -1;
	if(m_data->m_useGovernor) {
		govSetting = (sint8)m_data->m_buildListSequenceIndex;
	}
	PUSHBYTE(govSetting);

	PUSHBYTE(m_isInitialPacket);
}
示例#12
0
//----------------------------------------------------------------------------
//
// Name       : NetUnseenCell::Packetize
//
// Description: Generate an application data packet to transmit.
//
// Parameters : buf         : buffer to store the message
//
// Globals    : -
//
// Returns    : size        : number of bytes stored in buf
//
// Remark(s)  : -
//
//----------------------------------------------------------------------------
void NetUnseenCell::Packetize(uint8 *buf, uint16 &size)
{
	PUSHID(k_PACKET_UNSEEN_CELL_ID);
	PUSHBYTE(m_owner);

	PUSHLONG(m_ucell->m_env);
	PUSHBYTE(uint8(m_ucell->m_terrain_type));

	PUSHSHORT((uint16)m_ucell->m_point.x);
	PUSHSHORT((uint16)m_ucell->m_point.y);
	PUSHSHORT(m_ucell->m_move_cost);


	PUSHSHORT((uint16)m_ucell->m_flags);













	uint8 const citySize = (m_ucell->m_actor)
                           ? static_cast<uint8>(m_ucell->m_citySize)
                           : 0;
	PUSHBYTE(citySize);

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










		PUSHSHORT((uint16)m_ucell->m_cityOwner);
		PUSHSHORT((uint16)m_ucell->m_citySpriteIndex);

		PUSHSTRING(m_ucell->m_cityName);


		PUSHSHORT((uint16)m_ucell->m_actor->GetUnitDBIndex());
	}

#ifdef BATTLE_FLAGS
	PUSHSHORT(m_ucell->m_battleFlags);
#endif
	uint8 c = (uint8)m_ucell->m_improvements->GetCount();
	PUSHBYTE(c);
	PointerList<UnseenImprovementInfo>::Walker impWalk(m_ucell->m_improvements);
	for(; impWalk.IsValid(); impWalk.Next()) {
		PUSHBYTE((uint8)impWalk.GetObj()->m_type);
		PUSHBYTE((uint8)impWalk.GetObj()->m_percentComplete);
	}

	c = (uint8)m_ucell->m_installations->GetCount();
	PUSHBYTE(c);
	PointerList<UnseenInstallationInfo>::Walker instWalk(m_ucell->m_installations);
	for(; instWalk.IsValid(); instWalk.Next()) {
		PUSHBYTE((uint8)instWalk.GetObj()->m_type);
		PUSHLONG(instWalk.GetObj()->m_visibility);
	}

	PUSHBYTE(m_ucell->m_tileInfo->m_riverPiece);
	PUSHBYTE(m_ucell->m_tileInfo->m_megaInfo);
	PUSHSHORT(m_ucell->m_tileInfo->m_terrainType);
	PUSHSHORT(m_ucell->m_tileInfo->m_tileNum);
	for(c = 0; c < k_NUM_TRANSITIONS; c++) {
		PUSHBYTE(m_ucell->m_tileInfo->m_transitions[c]);
	}
}