Fixed: Server side issues

This commit is contained in:
kervala 2012-11-24 20:20:21 +01:00
parent 9ceb9e7d81
commit 8be848dd2b
5 changed files with 120 additions and 60 deletions

View file

@ -292,7 +292,7 @@
</STRUCT>
<STRUCT>
<ATOM Name="name" Value="PvpMode"/>
<ATOM Name="type" Value="uint8"/>
<ATOM Name="type" Value="uint32"/>
<ATOM Name="persistant" Value="true"/>
<ATOM Name="mirror" Value="true"/>
<ATOM Name="weight" Value="1"/>

View file

@ -430,6 +430,78 @@ bool getAIInstanceFromGroupName(string& groupName, uint32& instanceNumber)
return true;
}
bool checkBannerPriv(const string &sheetName, CEntityId eid)
{
if (sheetName.find("banner") == string::npos)
{
// Not a banner
return true;
}
CPlayer* player = PlayerManager.getPlayer( PlayerManager.getPlayerId(eid) );
if (player == NULL)
{
return false;
}
if (player->havePriv(":DEV:"))
{
// Dev should be able to get all banners
return true;
}
if ( ! player->havePriv(BannerPriv))
{
// Player has no banner privs
return false;
}
if (sheetName.find("_gu") != string::npos)
{
if (player->havePriv(":G:"))
{
return true;
}
}
else if (sheetName.find("_sgu") != string::npos)
{
if (player->havePriv(":SG:"))
{
return true;
}
// VG uses SG banner for now
if (player->havePriv(":VG:"))
{
return true;
}
}
else if (sheetName.find("_vgu") != string::npos)
{
if (player->havePriv(":VG:"))
{
return true;
}
}
else if (sheetName.find("_gm") != string::npos)
{
if (player->havePriv(":GM:"))
{
return true;
}
}
else if (sheetName.find("_sgm") != string::npos)
{
if (player->havePriv(":SGM:"))
{
return true;
}
}
return false;
}
CAdminCommand * findAdminCommand(const string & name)
{
H_AUTO(findAdminCommand);
@ -1381,18 +1453,12 @@ NLMISC_COMMAND (createItemInBag, "Create an item and put it in the player bag",
}
// banners are the only items in game which use privilege
if( sheetName.find("banner") != string::npos )
// banners are the only items in game which use privilege
bool ok = checkBannerPriv(sheetName, eid);
if ( ! ok)
{
CPlayer * player = PlayerManager.getPlayer( PlayerManager.getPlayerId(eid) );
// if (player != NULL && !player->havePriv(":DEV:") )
if (player != NULL && player->havePriv(BannerPriv) )
{
if( sheetName.find("_gu") != string::npos && !player->havePriv(":G:") ) return false;
if( sheetName.find("_sgu") != string::npos && !player->havePriv(":SG:") ) return false;
if( sheetName.find("_vgu") != string::npos && !player->havePriv(":VG:") ) return false;
if( sheetName.find("_gm") != string::npos && !player->havePriv(":GM:") ) return false;
if( sheetName.find("_sgm") != string::npos && !player->havePriv(":SGM:") ) return false;
}
log.displayNL("Invalid banner priviledge");
return false;
}
const CStaticItem *form = CSheets::getForm (sheet);
@ -1472,17 +1538,11 @@ NLMISC_COMMAND (createItemInTmpInv, "Create an item and put it in the player tem
}
// banners are the only items in game which use privilege
if( sheetName.find("banner") != string::npos )
bool ok = checkBannerPriv(sheetName, eid);
if ( ! ok)
{
CPlayer * player = PlayerManager.getPlayer( PlayerManager.getPlayerId(eid) );
if (player != NULL && player->havePriv(BannerPriv) )
{
if( sheetName.find("_gu") != string::npos && !player->havePriv(":G:") ) return false;
if( sheetName.find("_sgu") != string::npos && !player->havePriv(":SG:") ) return false;
if( sheetName.find("_vgu") != string::npos && !player->havePriv(":VG:") ) return false;
if( sheetName.find("_gm") != string::npos && !player->havePriv(":GM:") ) return false;
if( sheetName.find("_sgm") != string::npos && !player->havePriv(":SGM:") ) return false;
}
log.displayNL("Invalid banner priviledge");
return false;
}
const CStaticItem *form = CSheets::getForm (sheet);
@ -1545,17 +1605,11 @@ NLMISC_COMMAND (createItemInInv, "Create items and put them in the given invento
}
// banners are the only items in game which use privilege
if( sheetName.find("banner") != string::npos )
bool ok = checkBannerPriv(sheetName, eid);
if ( ! ok)
{
CPlayer * player = PlayerManager.getPlayer( PlayerManager.getPlayerId(eid) );
if (player != NULL && player->havePriv(BannerPriv) )
{
if( sheetName.find("_gu") != string::npos && !player->havePriv(":G:") ) return false;
if( sheetName.find("_sgu") != string::npos && !player->havePriv(":SG:") ) return false;
if( sheetName.find("_vgu") != string::npos && !player->havePriv(":VG:") ) return false;
if( sheetName.find("_gm") != string::npos && !player->havePriv(":GM:") ) return false;
if( sheetName.find("_sgm") != string::npos && !player->havePriv(":SGM:") ) return false;
}
log.displayNL("Invalid banner priviledge");
return false;
}
const CStaticItem *form = CSheets::getForm (sheet);
@ -4629,7 +4683,7 @@ CInventoryPtr getInv(CCharacter *c, const string &inv)
return inventoryPtr;
}
NLMISC_COMMAND (webExecCommand, "Execute a web command", "<user id> <web_app_url> <index> <command> <hmac> [<new_check=0|1>] [<next_step=0|1>] [<send_url=0|1>]")
NLMISC_COMMAND (webExecCommand, "Execute a web command", "<user id> <web_app_url> <index> <command> <hmac> [<new_check=0|1|2|3>] [<next_step=0|1>] [<send_url=0|1>]")
{
if (args.size() < 5)
@ -5516,7 +5570,7 @@ NLMISC_COMMAND (webExecCommand, "Execute a web command", "<user id> <web_app_url
//*************************************************
//***************** set_title
//*************************************************
// /a webExecCommand debug 1 set_title!toto hmac 0
// /a webExecCommand debug 1 set_title!#toto# hmac 0
else if (command_args[0] == "set_title")
{
if (command_args.size () != 2) return false;
@ -8538,7 +8592,7 @@ NLMISC_COMMAND(eventSetBotFacing, "Set the direction in which a bot faces", "<bo
std::vector<std::string> args2;
if (args.size() == 3 && args[3] != "0")
if (args.size() == 3 && args[2] != "0")
{
// Do the whole group
args2.push_back(args[0]);

View file

@ -501,7 +501,7 @@ CCharacter::CCharacter(): CEntityBase(false),
_TeamId= CTEAM::InvalidTeamId;
///init LeagueId
_LeagueId = TChanID::Unknown;
_LeagueId = DYN_CHAT_INVALID_CHAN;
// init combat flags
_CombatEventFlagTicks.resize(32);
@ -12482,10 +12482,15 @@ bool CCharacter::autoFillExchangeView()
{
invItem = playerBagInvPointer->getItem(inventoryIndex);
if (invItem == NULL)
continue;
continue;
if (invItem->getLockedByOwner())
continue;
if (invItem->getRefInventory() != NULL)
continue;
itemsSeenCount++;
// Changed to support comparisons on sheetID masks
if (invItem->getSheetId() == validateSteps[stepCounter].Sheet)
{

View file

@ -210,6 +210,21 @@ std::vector<TChanID> CPVPManager2::getCharacterChannels(CCharacter * user)
std::vector<TChanID> result;
result.clear();
// Add lang channel, should be first.
if (!user->getLangChannel().empty()) {
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find(user->getLangChannel());
if (it != _ExtraFactionChannel.end())
{
result.push_back((*it).second);
}
} else {
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("en");
if (it != _ExtraFactionChannel.end())
{
result.push_back((*it).second);
}
}
PVP_CLAN::TPVPClan faction = user->getAllegiance().first;
if( faction != PVP_CLAN::Neutral )
{
@ -230,21 +245,6 @@ std::vector<TChanID> CPVPManager2::getCharacterChannels(CCharacter * user)
}
}
// Add lang channel
if (!user->getLangChannel().empty()) {
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find(user->getLangChannel());
if (it != _ExtraFactionChannel.end())
{
result.push_back((*it).second);
}
} else {
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find("en");
if (it != _ExtraFactionChannel.end())
{
result.push_back((*it).second);
}
}
/*
bool matis = CFameInterface::getInstance().getFameIndexed(user->getId(), 0) >= PVPFameRequired*6000;
bool fyros = CFameInterface::getInstance().getFameIndexed(user->getId(), 1) >= PVPFameRequired*6000;
@ -1112,11 +1112,11 @@ void CPVPManager2::onIOSMirrorUp()
*/
// Community Channels
createExtraFactionChannel("en");
createExtraFactionChannel("fr");
createExtraFactionChannel("de");
createExtraFactionChannel("ru");
createExtraFactionChannel("es");
createExtraFactionChannel("en", true);
createExtraFactionChannel("fr", true);
createExtraFactionChannel("de", true);
createExtraFactionChannel("ru", true);
createExtraFactionChannel("es", true);
for (uint i = PVP_CLAN::BeginClans; i <= PVP_CLAN::EndClans; i++)
{
@ -1161,7 +1161,7 @@ void CPVPManager2::createFactionChannel(PVP_CLAN::TPVPClan clan)
}
}
void CPVPManager2::createExtraFactionChannel(const std::string & channelName)
void CPVPManager2::createExtraFactionChannel(const std::string & channelName, bool universalChannel)
{
TMAPExtraFactionChannel::iterator it = _ExtraFactionChannel.find(channelName);
@ -1171,6 +1171,7 @@ void CPVPManager2::createExtraFactionChannel(const std::string & channelName)
TChanID factionChannelId = DynChatEGS.addLocalizedChan(name);
// set historic size of the newly created channel
DynChatEGS.setHistoricSize( factionChannelId, FactionChannelHistoricSize );
DynChatEGS.setUniversalChannel( factionChannelId, universalChannel );
_ExtraFactionChannel.insert( make_pair(channelName, factionChannelId) );
}

View file

@ -150,7 +150,7 @@ public:
// create a faction channel if not already exist
void createFactionChannel(PVP_CLAN::TPVPClan clan);
// create an extra faction channel if not already exist (for marauders, agnos, urasiens and hominits)
void createExtraFactionChannel(const std::string & channelName);
void createExtraFactionChannel(const std::string & channelName, bool universalChannel = false);
// create an user channel if not already exist
TChanID createUserChannel(const std::string & channelName, const std::string & pass);
// remove a user channel