Пример #1
0
static int l_fac_add_to_factions(lua_State *L)
{
	FactionBuilder *facbld = l_fac_check_builder(L, 1);
	Faction *fac = facbld->fac;

	const std::string factionName(luaL_checkstring(L, 2));

	if (!facbld->registered && !facbld->skip) {
		if (facbld->fac->hasHomeworld) {
			printf("l_fac_add_to_factions: added (%3d,%3d,%3d) f=%4.0f e=%2.2f '%s' [%s]\n"
				, fac->homeworld.sectorX, fac->homeworld.sectorY, fac->homeworld.sectorZ, fac->foundingDate, fac->expansionRate, fac->name.c_str(), factionName.c_str());
		}
		else {
			printf("l_fac_add_to_factions: added '%s' [%s]\n", fac->name.c_str(), factionName.c_str());
		}

		// add the faction to the various faction data structures
		s_factions.push_back(facbld->fac);
		s_factions_byName[facbld->fac->name] = facbld->fac;
		s_spatial_index.Add(facbld->fac);

		if (facbld->fac->hasHomeworld) s_homesystems.insert(facbld->fac->homeworld.SystemOnly());
		facbld->fac->idx = s_factions.size()-1;
		facbld->registered = true;

		return 0;
	} else if (facbld->skip) {
		printf("l_fac_add_to_factions: invalid homeworld, skipped (%3d,%3d,%3d) f=%4.0f e=%2.2f '%s' [%s]\n"
				, fac->homeworld.sectorX, fac->homeworld.sectorY, fac->homeworld.sectorZ, fac->foundingDate, fac->expansionRate, fac->name.c_str(), factionName.c_str());
		return 0;
	} else {
		return luaL_error(L, "faction '%s' already added\n", facbld->fac->name.c_str());
	}
}
Пример #2
0
void CharSheetManager::_processFactionRequest(Message* message,DispatchClient* client)
{
    PlayerObject* player = gWorldManager->getPlayerByAccId(client->getAccountId());

    if(player == NULL)
    {
        DLOG(info) << "CharSheetManager::_processFactionRequest: could not find player " << client->getAccountId();
        return;
    }

    gMessageFactory->StartMessage();
    gMessageFactory->addUint32(opFactionResponseMessage);
    gMessageFactory->addString(player->getFaction());
    gMessageFactory->addUint32(player->getFactionPointsByFactionId(2));
    gMessageFactory->addUint32(player->getFactionPointsByFactionId(3));
    gMessageFactory->addUint32(0);

    FactionList* factions = player->getFactionList();

    gMessageFactory->addUint32(factions->size());

    FactionList::iterator it = factions->begin();

    while(it != factions->end())
    {
        gMessageFactory->addString(mvFactions[(*it).first - 1]);
        ++it;
    }

    gMessageFactory->addUint32(factions->size());

    it = factions->begin();

    while(it != factions->end())
    {
        gMessageFactory->addFloat((float)((*it).second));
        ++it;
    }

    Message* newMessage = gMessageFactory->EndMessage();

    client->SendChannelA(newMessage,client->getAccountId(),CR_Client,6);
}
Пример #3
0
//static
void Faction::Init()
{
	lua_State *L = luaL_newstate();
	LUA_DEBUG_START(L);

	pi_lua_open_standard_base(L);

	LuaConstants::Register(L);

	LUA_DEBUG_CHECK(L, 0);

	RegisterFactionsAPI(L);

	LUA_DEBUG_CHECK(L, 0);
	pi_lua_dofile_recursive(L, "factions");

	LUA_DEBUG_END(L, 0);
	lua_close(L);

	printf("Number of factions added: " SIZET_FMT "\n", s_factions.size());
	StarSystem::ShrinkCache();    // clear the star system cache of anything we used for faction generation
}
Пример #4
0
const Uint32 Faction::GetNumFactions()
{
	return s_factions.size();
}
Пример #5
0
Faction *Faction::GetFaction(const Uint32 index)
{
	assert( index < s_factions.size() );
	return s_factions[index];
}