self kill command

self-kill
Ben Saine 3 years ago
parent 6cfc9585f5
commit 00597f9b18

@ -4,7 +4,7 @@
// This source file has been modified by the following contributors: // This source file has been modified by the following contributors:
// Copyright (C) 2012 Matt RAYKOWSKI (sfb) <matt.raykowski@gmail.com> // Copyright (C) 2012 Matt RAYKOWSKI (sfb) <matt.raykowski@gmail.com>
// Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com> // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
// Copyright (C) 2013-2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be> // Copyright (C) 2013-2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
@ -181,14 +181,14 @@ NLMISC_COMMAND(where, "Ask information on the position", "")
// Check parameters. // Check parameters.
if(args.empty()) if(args.empty())
{ // Create the message and send. { // Create the message and send.
const string msgName = "COMMAND:WHERE"; const char *msgName = "COMMAND:WHERE";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
NetMngr.push(out); NetMngr.push(out);
} }
else else
nlwarning("command 'where': unknown message named '%s'", msgName.c_str()); nlwarning("command 'where': unknown message named '%s'", msgName);
return true; return true;
} }
return false; return false;
@ -240,20 +240,18 @@ NLMISC_COMMAND(equipGroup, "equip group <name>", "name")
} }
if(CItemGroupManager::getInstance()->equipGroup(args[0])) if(CItemGroupManager::getInstance()->equipGroup(args[0]))
{ {
ucstring msg = CI18N::get("cmdEquipGroupSuccess"); string msg = CI18N::get("cmdEquipGroupSuccess");
//Use ucstring because group name can contain accentued characters (and stuff like that) //Use utf-8 string because group name can contain accentued characters (and stuff like that)
ucstring nameUC; string nameUC = args[0];
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return true; return true;
} }
else else
{ {
ucstring msg = CI18N::get("cmdEquipGroupError"); string msg = CI18N::get("cmdEquipGroupError");
//Use ucstring because group name can contain accentued characters (and stuff like that) //Use utf-8 string because group name can contain accentued characters (and stuff like that)
ucstring nameUC; string nameUC = args[0];
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return false; return false;
@ -274,10 +272,9 @@ NLMISC_COMMAND(moveGroup, "move group <name> to <dst>", "name dst")
if(CItemGroupManager::getInstance()->moveGroup(args[0], INVENTORIES::toInventory(args[1]))) if(CItemGroupManager::getInstance()->moveGroup(args[0], INVENTORIES::toInventory(args[1])))
{ {
ucstring msg = CI18N::get("cmdMoveGroupSuccess"); string msg = CI18N::get("cmdMoveGroupSuccess");
//Use ucstring because group name can contain accentued characters (and stuff like that) //Use utf-8 string because group name can contain accentued characters (and stuff like that)
ucstring nameUC; string nameUC = args[0];
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%name", nameUC);
strFindReplace(msg, "%inventory", args[1]); strFindReplace(msg, "%inventory", args[1]);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
@ -285,10 +282,9 @@ NLMISC_COMMAND(moveGroup, "move group <name> to <dst>", "name dst")
} }
else else
{ {
ucstring msg = CI18N::get("cmdMoveGroupError"); string msg = CI18N::get("cmdMoveGroupError");
//Use ucstring because group name can contain accentued characters (and stuff like that) //Use utf-8 string because group name can contain accentued characters (and stuff like that)
ucstring nameUC; string nameUC = args[0];
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%name", nameUC);
strFindReplace(msg, "%inventory", args[1]); strFindReplace(msg, "%inventory", args[1]);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
@ -312,24 +308,22 @@ NLMISC_COMMAND(createGroup, "create group <name> [true](create a <remove> for ev
removeUnequiped = !args[1].empty(); removeUnequiped = !args[1].empty();
if(CItemGroupManager::getInstance()->createGroup(args[0], removeUnequiped)) if(CItemGroupManager::getInstance()->createGroup(args[0], removeUnequiped))
{ {
ucstring msg; string msg;
if(removeUnequiped) if(removeUnequiped)
msg = CI18N::get("cmdCreateGroupSuccess2"); msg = CI18N::get("cmdCreateGroupSuccess2");
else else
msg = CI18N::get("cmdCreateGroupSuccess1"); msg = CI18N::get("cmdCreateGroupSuccess1");
//Use ucstring because group name can contain accentued characters (and stuff like that) //Use utf-8 string because group name can contain accentued characters (and stuff like that)
ucstring nameUC; string nameUC = args[0];
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return true; return true;
} }
else else
{ {
ucstring msg = CI18N::get("cmdCreateGroupError"); string msg = CI18N::get("cmdCreateGroupError");
//Use ucstring because group name can contain accentued characters (and stuff like that) //Use utf-8 string because group name can contain accentued characters (and stuff like that)
ucstring nameUC; string nameUC = args[0];
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return false; return false;
@ -350,20 +344,18 @@ NLMISC_COMMAND(deleteGroup, "delete group <name>", "name")
} }
if(CItemGroupManager::getInstance()->deleteGroup(args[0])) if(CItemGroupManager::getInstance()->deleteGroup(args[0]))
{ {
ucstring msg = CI18N::get("cmdDeleteGroupSuccess"); string msg = CI18N::get("cmdDeleteGroupSuccess");
//Use ucstring because group name can contain accentued characters (and stuff like that) //Use utf-8 string because group name can contain accentued characters (and stuff like that)
ucstring nameUC; string nameUC = args[0];
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return true; return true;
} }
else else
{ {
ucstring msg = CI18N::get("cmdDeleteGroupError"); string msg = CI18N::get("cmdDeleteGroupError");
//Use ucstring because group name can contain accentued characters (and stuff like that) //Use utf-8 string because group name can contain accentued characters (and stuff like that)
ucstring nameUC; string nameUC = args[0];
nameUC.fromUtf8(args[0]);
strFindReplace(msg, "%name", nameUC); strFindReplace(msg, "%name", nameUC);
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return false; return false;
@ -416,6 +408,18 @@ NLMISC_COMMAND(afk, "Set the player as 'away from keyboard'","[<custom text>]")
return true; return true;
} }
NLMISC_COMMAND(selfkill, "Kill the player ","")
{
CBitMemStream out;
if(!GenericMsgHeaderMngr.pushNameToStream("COMMAND:SELFKILL", out))
{
nlwarning("Unknown message name COMMAND:SELFKILL");
return false;
}
NetMngr.push(out);
return true;
}
bool randomCheckCharset(std::string const& str) bool randomCheckCharset(std::string const& str)
{ {
std::string::const_iterator it, itEnd = str.end(); std::string::const_iterator it, itEnd = str.end();
@ -494,7 +498,7 @@ NLMISC_COMMAND(random, "Roll a dice and say the result around","[<min>] <max> [h
if (!randomFromString(args[0], max)) if (!randomFromString(args[0], max))
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
ucstring msg = CI18N::get("uiRandomBadParameter"); string msg = CI18N::get("uiRandomBadParameter");
strFindReplace(msg, "%s", args[0] ); strFindReplace(msg, "%s", args[0] );
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return false; return false;
@ -504,7 +508,7 @@ NLMISC_COMMAND(random, "Roll a dice and say the result around","[<min>] <max> [h
if (!randomFromString(args[1], min)) if (!randomFromString(args[1], min))
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
ucstring msg = CI18N::get("uiRandomBadParameter"); string msg = CI18N::get("uiRandomBadParameter");
strFindReplace(msg, "%s", args[1] ); strFindReplace(msg, "%s", args[1] );
pIM->displaySystemInfo(msg); pIM->displaySystemInfo(msg);
return false; return false;
@ -544,7 +548,7 @@ NLMISC_COMMAND(dumpShapePos, "Dump Last Added Shape Pos.", "")
CInterfaceManager *IM = CInterfaceManager::getInstance(); CInterfaceManager *IM = CInterfaceManager::getInstance();
CVector pos = ShapeAddedByCommand.back().getPos(); CVector pos = ShapeAddedByCommand.back().getPos();
IM->displaySystemInfo(ucstring(toString("Shape Pos = %f, %f, %f", pos.x, pos.y, pos.z))); IM->displaySystemInfo(toString("Shape Pos = %f, %f, %f", pos.x, pos.y, pos.z));
return true; return true;
} }
//----------------------------------------------- //-----------------------------------------------
@ -853,7 +857,7 @@ NLMISC_COMMAND(bugReport, "Call the bug report tool with dump", "<AddScreenshot>
string sys; string sys;
sys = "Language "+CI18N::getCurrentLanguageName().toString() +" "; sys = "Language "+CI18N::getCurrentLanguageName() +" ";
if (!args.empty()) if (!args.empty())
{ {
@ -932,9 +936,7 @@ NLMISC_COMMAND(a, "Execute an admin command on you","<cmd> <arg>")
cmd = args[0]; cmd = args[0];
for (uint i = 1; i < args.size(); i++) for (uint i = 1; i < args.size(); i++)
{ {
// temporary fix for utf-8 std::string tmp = args[i];
// servers commands are not decoded so convert them to ansi
std::string tmp = ucstring::makeFromUtf8(args[i]).toString();
if (!arg.empty()) if (!arg.empty())
arg += ' '; arg += ' ';
@ -976,9 +978,7 @@ NLMISC_COMMAND(b, "Execute an admin command on your target","<cmd> <arg>")
cmd = args[0]; cmd = args[0];
for (uint i = 1; i < args.size(); i++) for (uint i = 1; i < args.size(); i++)
{ {
// temporary fix for utf-8 std::string tmp = args[i];
// servers commands are not decoded so convert them to ansi
std::string tmp = ucstring::makeFromUtf8(args[i]).toString();
if (!arg.empty()) if (!arg.empty())
arg += ' '; arg += ' ';
@ -1023,9 +1023,7 @@ NLMISC_COMMAND(c, "Execute an admin command on character name","<Character Name>
cmd = args[1]; cmd = args[1];
for (uint i = 2; i < args.size(); i++) for (uint i = 2; i < args.size(); i++)
{ {
// temporary fix for utf-8 std::string tmp = args[i];
// servers commands are not decoded so convert them to ansi
std::string tmp = ucstring::makeFromUtf8(args[i]).toString();
if (!arg.empty()) if (!arg.empty())
arg += ' '; arg += ' ';
@ -1096,15 +1094,15 @@ NLMISC_COMMAND(verbose, "Enable/Disable some Debug Information", "none or magic"
{ {
// Help // Help
CInterfaceManager *IM = CInterfaceManager::getInstance(); CInterfaceManager *IM = CInterfaceManager::getInstance();
IM->displaySystemInfo(ucstring("This command need 1 parameter :")); IM->displaySystemInfo("This command need 1 parameter :");
IM->displaySystemInfo(ucstring("<string> :")); IM->displaySystemInfo("<string> :");
IM->displaySystemInfo(ucstring("- none(to remove all verboses)")); IM->displaySystemInfo("- none(to remove all verboses)");
IM->displaySystemInfo(ucstring("- magic(to add debug infos about magic)")); IM->displaySystemInfo("- magic(to add debug infos about magic)");
IM->displaySystemInfo(ucstring("- anim (to add debug infos about animation)")); IM->displaySystemInfo("- anim (to add debug infos about animation)");
} }
else else
{ {
std::string type = NLMISC::toLower(args[0]); std::string type = NLMISC::toLowerAscii(args[0]);
if (type == "none") if (type == "none")
Verbose = VerboseNone; Verbose = VerboseNone;
else if(type == "magic") else if(type == "magic")
@ -1114,11 +1112,11 @@ NLMISC_COMMAND(verbose, "Enable/Disable some Debug Information", "none or magic"
else else
{ {
CInterfaceManager *IM = CInterfaceManager::getInstance(); CInterfaceManager *IM = CInterfaceManager::getInstance();
IM->displaySystemInfo(ucstring("This command need 1 parameter :")); IM->displaySystemInfo("This command need 1 parameter :");
IM->displaySystemInfo(ucstring("<string> :")); IM->displaySystemInfo("<string> :");
IM->displaySystemInfo(ucstring("- none(to remove all verboses)")); IM->displaySystemInfo("- none(to remove all verboses)");
IM->displaySystemInfo(ucstring("- magic(to add debug infos about magic)")); IM->displaySystemInfo("- magic(to add debug infos about magic)");
IM->displaySystemInfo(ucstring("- anim (to add debug infos about animation)")); IM->displaySystemInfo("- anim (to add debug infos about animation)");
} }
} }
return true; return true;
@ -1306,9 +1304,9 @@ NLMISC_COMMAND(execScript, "Execute a script file (.cmd)","<FileName>")
inComment++; inComment++;
if(inComment<=0) if(inComment<=0)
{ {
ucstring ucline(line); string ucline(line);
CInterfaceManager::parseTokens(ucline); CInterfaceManager::parseTokens(ucline);
ICommand::execute(ucline.toUtf8(), g_log); ICommand::execute(ucline, g_log);
} }
if(strncmp(line, "*/", 2)==0) if(strncmp(line, "*/", 2)==0)
inComment--; inComment--;
@ -1323,7 +1321,7 @@ NLMISC_COMMAND(execScript, "Execute a script file (.cmd)","<FileName>")
} }
else else
{ {
CInterfaceManager::getInstance()->displaySystemInfo(ucstring("Cannot open file")); CInterfaceManager::getInstance()->displaySystemInfo("Cannot open file");
} }
return true; return true;
@ -1358,7 +1356,7 @@ NLMISC_COMMAND(db, "Modify Database","<Property> <Value>")
else else
pIM->displaySystemInfo(toString("DB '%s' does not exist.", args[0].c_str())); pIM->displaySystemInfo(toString("DB '%s' does not exist.", args[0].c_str()));
#else #else
pIM->displaySystemInfo(ucstring("Can't write to DB when in Final Version.")); pIM->displaySystemInfo("Can't write to DB when in Final Version.");
#endif #endif
} }
else if (size == 1) else if (size == 1)
@ -1368,7 +1366,7 @@ NLMISC_COMMAND(db, "Modify Database","<Property> <Value>")
{ {
sint64 prop = node->getValue64(); sint64 prop = node->getValue64();
string str = toString(prop); string str = toString(prop);
pIM->displaySystemInfo(ucstring(str)); pIM->displaySystemInfo(str);
nlinfo("%s", str.c_str()); nlinfo("%s", str.c_str());
} }
else else
@ -1385,14 +1383,14 @@ NLMISC_COMMAND(setItemName, "set name of items, sbrick, etc..","<sheet_id> <name
{ {
if (args.size() < 2) return false; if (args.size() < 2) return false;
CSheetId id(args[0]); CSheetId id(args[0]);
ucstring name; string name;
name.fromUtf8(args[1]); name = args[1];
ucstring desc; string desc;
ucstring desc2; string desc2;
if (args.size() > 2) if (args.size() > 2)
desc.fromUtf8(args[2]); desc = args[2];
if (args.size() > 3) if (args.size() > 3)
desc2.fromUtf8(args[3]); desc2 = args[3];
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
if (pSMC) if (pSMC)
@ -1406,10 +1404,10 @@ NLMISC_COMMAND(setItemName, "set name of items, sbrick, etc..","<sheet_id> <name
NLMISC_COMMAND(setMissingDynstringText, "set text of missing dynamic string"," <name> <text>") NLMISC_COMMAND(setMissingDynstringText, "set text of missing dynamic string"," <name> <text>")
{ {
if (args.size() < 2) return false; if (args.size() < 2) return false;
ucstring name; string name;
name.fromUtf8(args[0]); name = args[0];
ucstring text; string text;
text.fromUtf8(args[1]); text = args[1];
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
if (pSMC) if (pSMC)
@ -1438,7 +1436,7 @@ NLMISC_COMMAND(ah, "Launch an action handler", "<ActionHandler> <AHparam>")
if (args.empty()) if (args.empty())
return false; return false;
if (!ClientCfg.AllowDebugLua && toLower(args[0]) == "lua") if (!ClientCfg.AllowDebugLua && toLowerAscii(args[0]) == "lua")
{ {
return false; // not allowed!! return false; // not allowed!!
} }
@ -1459,7 +1457,7 @@ NLMISC_COMMAND(ah, "Launch an action handler", "<ActionHandler> <AHparam>")
static void setDynString(uint32 strID, const std::string &value) static void setDynString(uint32 strID, const std::string &value)
{ {
STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance(); STRING_MANAGER::CStringManagerClient *pSMC = STRING_MANAGER::CStringManagerClient::instance();
pSMC->receiveString(strID, ucstring(value)); pSMC->receiveString(strID, value);
CBitMemStream bm; CBitMemStream bm;
if (bm.isReading()) bm.invert(); if (bm.isReading()) bm.invert();
bm.serial(strID); bm.serial(strID);
@ -1686,10 +1684,10 @@ NLMISC_COMMAND(missionProgress, "debug"," ")
NLMISC_COMMAND( displayDBModifs, "display server database modification in the chat window"," ") NLMISC_COMMAND( displayDBModifs, "display server database modification in the chat window"," ")
{ {
if ( VerboseDatabase ) if ( VerboseDatabase )
CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("the database is already in verbose mode"),CRGBA(255,255,255,255)); CInterfaceManager::getInstance()->getChatOutput()->addTextChild("the database is already in verbose mode",CRGBA(255,255,255,255));
else else
{ {
CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("database is now in verbose mode"),CRGBA(255,255,255,255)); CInterfaceManager::getInstance()->getChatOutput()->addTextChild("database is now in verbose mode",CRGBA(255,255,255,255));
VerboseDatabase = true; VerboseDatabase = true;
} }
return true; return true;
@ -1698,10 +1696,10 @@ NLMISC_COMMAND( displayDBModifs, "display server database modification in the ch
NLMISC_COMMAND( hideDBModifs, "stop displaying server database modification in the chat window"," ") NLMISC_COMMAND( hideDBModifs, "stop displaying server database modification in the chat window"," ")
{ {
if ( !VerboseDatabase ) if ( !VerboseDatabase )
CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("the database is already not in verbose mode"),CRGBA(255,255,255,255)); CInterfaceManager::getInstance()->getChatOutput()->addTextChild("the database is already not in verbose mode",CRGBA(255,255,255,255));
else else
{ {
CInterfaceManager::getInstance()->getChatOutput()->addTextChild(ucstring("database is not in verbose mode anymore"),CRGBA(255,255,255,255)); CInterfaceManager::getInstance()->getChatOutput()->addTextChild("database is not in verbose mode anymore",CRGBA(255,255,255,255));
VerboseDatabase = false; VerboseDatabase = false;
} }
return true; return true;
@ -1722,7 +1720,7 @@ NLMISC_COMMAND(getSheetId, "get_sheet_id","<sheet file name>")
return false; return false;
CSheetId id(args[0]); CSheetId id(args[0]);
CInterfaceManager::getInstance()->displaySystemInfo(ucstring(toString(id.asInt()))); CInterfaceManager::getInstance()->displaySystemInfo(toString(id.asInt()));
return true; return true;
} }
@ -1737,7 +1735,7 @@ NLMISC_COMMAND(getSheetName, "get_sheet_name","<Sheet Id>")
string name = id.toString(); string name = id.toString();
CInterfaceManager::getInstance()->displaySystemInfo(ucstring(name)); CInterfaceManager::getInstance()->displaySystemInfo(name);
return true; return true;
} }
@ -1817,14 +1815,14 @@ NLMISC_COMMAND(usePreprogCombat, "use the specified combat preprog sentence", "<
NLMISC_COMMAND(engage, "engage target in combat", "") NLMISC_COMMAND(engage, "engage target in combat", "")
{ {
// Create the message for the server to execute a phrase. // Create the message for the server to execute a phrase.
const string msgName = "COMBAT:ENGAGE"; const char *msgName = "COMBAT:ENGAGE";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
NetMngr.push(out); NetMngr.push(out);
} }
else else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true; return true;
} }
@ -1850,14 +1848,14 @@ NLMISC_COMMAND(disengage, "disengage from combat", "")
NLMISC_COMMAND(leaveTeam, "leave team", "") NLMISC_COMMAND(leaveTeam, "leave team", "")
{ {
// Create the message for the server to execute a phrase. // Create the message for the server to execute a phrase.
const string msgName = "TEAM:LEAVE"; const char *msgName = "TEAM:LEAVE";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
NetMngr.push(out); NetMngr.push(out);
} }
else else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true; return true;
} }
@ -1865,14 +1863,14 @@ NLMISC_COMMAND(leaveTeam, "leave team", "")
NLMISC_COMMAND(joinTeam, "join the specified team", "") NLMISC_COMMAND(joinTeam, "join the specified team", "")
{ {
// Create the message for the server to execute a phrase. // Create the message for the server to execute a phrase.
const string msgName = "TEAM:JOIN"; const char *msgName = "TEAM:JOIN";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
NetMngr.push(out); NetMngr.push(out);
} }
else else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true; return true;
} }
@ -1880,14 +1878,14 @@ NLMISC_COMMAND(joinTeam, "join the specified team", "")
NLMISC_COMMAND(joinTeamProposal, "propose to current target to join the team", "") NLMISC_COMMAND(joinTeamProposal, "propose to current target to join the team", "")
{ {
// Create the message for the server to execute a phrase. // Create the message for the server to execute a phrase.
const string msgName = "TEAM:JOIN_PROPOSAL"; const char *msgName = "TEAM:JOIN_PROPOSAL";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
NetMngr.push(out); NetMngr.push(out);
} }
else else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true; return true;
} }
@ -1895,14 +1893,14 @@ NLMISC_COMMAND(joinTeamProposal, "propose to current target to join the team", "
NLMISC_COMMAND(joinTeamDecline, "decline a join team proposal", "") NLMISC_COMMAND(joinTeamDecline, "decline a join team proposal", "")
{ {
// Create the message for the server to execute a phrase. // Create the message for the server to execute a phrase.
const string msgName = "TEAM:JOIN_PROPOSAL_DECLINE"; const char *msgName = "TEAM:JOIN_PROPOSAL_DECLINE";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
NetMngr.push(out); NetMngr.push(out);
} }
else else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true; return true;
} }
@ -1910,14 +1908,14 @@ NLMISC_COMMAND(joinTeamDecline, "decline a join team proposal", "")
NLMISC_COMMAND(kickTeammate, "kick someone from your team", "") NLMISC_COMMAND(kickTeammate, "kick someone from your team", "")
{ {
// Create the message for the server to execute a phrase. // Create the message for the server to execute a phrase.
const string msgName = "TEAM:KICK"; const char *msgName = "TEAM:KICK";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
NetMngr.push(out); NetMngr.push(out);
} }
else else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str()); nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true; return true;
} }
@ -1927,14 +1925,14 @@ NLMISC_COMMAND(cancelCurrentSentence, "cancel the sentence being executed", "")
// no parameter needed // no parameter needed
// Create the message for the server to cancel the phrase being executed // Create the message for the server to cancel the phrase being executed
const string msgName = "SENTENCE:CANCEL_CURRENT"; const char *msgName = "SENTENCE:CANCEL_CURRENT";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
NetMngr.push(out); NetMngr.push(out);
} }
else else
nlwarning("command : unknown message name : '%s'", msgName.c_str()); nlwarning("command : unknown message name : '%s'", msgName);
return true; return true;
} }
@ -1966,7 +1964,7 @@ NLMISC_COMMAND(drop,"drop an item to the ground","<id>")
sint32 z = (sint32)UserEntity->pos().z * 1000; sint32 z = (sint32)UserEntity->pos().z * 1000;
CBitMemStream bms; CBitMemStream bms;
string msgType = "ITEM:DROP"; const char *msgType = "ITEM:DROP";
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
{ {
bms.serial( itemId ); bms.serial( itemId );
@ -1995,7 +1993,7 @@ NLMISC_COMMAND(pos, "Change the position of the user (in local only)", "<x, y, (
if(args.size() == 1) if(args.size() == 1)
{ {
string dest = args[0]; string dest = args[0];
newPos = CTeleport::getPos(NLMISC::toLower(dest)); newPos = CTeleport::getPos(NLMISC::toLowerAscii(dest));
if(newPos == CTeleport::Unknown) if(newPos == CTeleport::Unknown)
{ {
//here we try to teleport to a bot destination //here we try to teleport to a bot destination
@ -2311,7 +2309,7 @@ NLMISC_COMMAND(record, "Start Recording", "<name>")
// Warning when already recording. // Warning when already recording.
if(NetMngr.isRecording()) if(NetMngr.isRecording())
{ {
IM->displaySystemInfo(ucstring("Already Recording. Stop the current Record first")); IM->displaySystemInfo("Already Recording. Stop the current Record first");
return true; return true;
} }
@ -2388,7 +2386,7 @@ NLMISC_COMMAND(sheet2idx, "Return the index of a sheet", "<sheet name> <visual s
else else
result = NLMISC::toString("sheet '%s' not valid", args[0].c_str()); result = NLMISC::toString("sheet '%s' not valid", args[0].c_str());
IM->displaySystemInfo(ucstring(result)); IM->displaySystemInfo(result);
nlinfo("'sheet2idx': %s", result.c_str()); nlinfo("'sheet2idx': %s", result.c_str());
return true; return true;
} }
@ -2411,7 +2409,7 @@ NLMISC_COMMAND(dynstr, "display a dyn string value", "<dyn string_id>")
uint dynId; uint dynId;
fromString(args[0], dynId); fromString(args[0], dynId);
ucstring result; string result;
STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynId, result); STRING_MANAGER::CStringManagerClient::instance()->getDynString(dynId, result);
CInterfaceManager::getInstance()->displaySystemInfo(result); CInterfaceManager::getInstance()->displaySystemInfo(result);
@ -2426,7 +2424,7 @@ NLMISC_COMMAND(serverstr, "display a server string value", "<serverstr string_id
uint dynId; uint dynId;
fromString(args[0], dynId); fromString(args[0], dynId);
ucstring result; string result;
STRING_MANAGER::CStringManagerClient::instance()->getString(dynId, result); STRING_MANAGER::CStringManagerClient::instance()->getString(dynId, result);
CInterfaceManager::getInstance()->displaySystemInfo(result); CInterfaceManager::getInstance()->displaySystemInfo(result);
@ -2510,11 +2508,11 @@ NLMISC_COMMAND(mode, "Change the mode for an entity in a slot", "<Slot> <Mode> [
if(args.size() < 2) if(args.size() < 2)
{ {
// Help // Help
CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 paramters :")); CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 paramters :");
CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" <Slot> : the slot number of the entity to change")); CInterfaceManager::getInstance()->displaySystemInfo(" <Slot> : the slot number of the entity to change");
CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" <Mode> : the mode wanted for the entity, one of the following number :")); CInterfaceManager::getInstance()->displaySystemInfo(" <Mode> : the mode wanted for the entity, one of the following number :");
for(uint i = 0; i<MBEHAV::NUMBER_OF_MODES; ++i) for(uint i = 0; i<MBEHAV::NUMBER_OF_MODES; ++i)
CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::modeToString((MBEHAV::EMode)i).c_str()))); CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::modeToString((MBEHAV::EMode)i).c_str()));
} }
// Right parameters number // Right parameters number
else else
@ -2544,7 +2542,7 @@ NLMISC_COMMAND(mode, "Change the mode for an entity in a slot", "<Slot> <Mode> [
} }
// Invalid slot. // Invalid slot.
else else
CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot");
} }
// Command well done. // Command well done.
@ -2557,12 +2555,12 @@ NLMISC_COMMAND(behaviour, "Change the behaviour for an entity in a slot", "<Slot
if(args.size() < 2 || args.size() > 6) if(args.size() < 2 || args.size() > 6)
{ {
// Help // Help
CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 to 6 paramters :")); CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 to 6 paramters :");
CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" <Slot> : the slot number of the entity to change")); CInterfaceManager::getInstance()->displaySystemInfo(" <Slot> : the slot number of the entity to change");
CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" <Behaviour> : the behaviour to play for the entity, one of the following number :")); CInterfaceManager::getInstance()->displaySystemInfo(" <Behaviour> : the behaviour to play for the entity, one of the following number :");
for(uint i = 0; i<MBEHAV::EMOTE_BEGIN; ++i) for(uint i = 0; i<MBEHAV::EMOTE_BEGIN; ++i)
CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i).c_str()))); CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i).c_str()));
CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END));
} }
else else
{ {
@ -2633,7 +2631,7 @@ NLMISC_COMMAND(behaviour, "Change the behaviour for an entity in a slot", "<Slot
entity->updateVisualProperty(NetMngr.getCurrentServerTick()+dt, CLFECOMMON::PROPERTY_BEHAVIOUR); entity->updateVisualProperty(NetMngr.getCurrentServerTick()+dt, CLFECOMMON::PROPERTY_BEHAVIOUR);
} }
else else
CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot");
} }
// Command well done. // Command well done.
@ -2655,12 +2653,12 @@ NLMISC_COMMAND(magic, "Cast a spell", "\n"
if(args.size() != 6) if(args.size() != 6)
{ {
// Help // Help
// CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 or 3 paramters :")); // CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 or 3 paramters :");
// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" <Slot> : the slot number of the entity to change")); // CInterfaceManager::getInstance()->displaySystemInfo(" <Slot> : the slot number of the entity to change");
// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" <Behaviour> : the behaviour to play for the entity, one of the following number :")); // CInterfaceManager::getInstance()->displaySystemInfo(" <Behaviour> : the behaviour to play for the entity, one of the following number :");
// for(uint i = 0; i<MBEHAV::EMOTE_BEGIN; ++i) // for(uint i = 0; i<MBEHAV::EMOTE_BEGIN; ++i)
// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)))); // CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)));
// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); // CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END));
} }
else else
{ {
@ -2709,7 +2707,7 @@ NLMISC_COMMAND(magic, "Cast a spell", "\n"
entity->updateVisualProperty(NetMngr.getCurrentServerTick()+50, CLFECOMMON::PROPERTY_BEHAVIOUR); entity->updateVisualProperty(NetMngr.getCurrentServerTick()+50, CLFECOMMON::PROPERTY_BEHAVIOUR);
} }
else else
CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot");
} }
// Command well done. // Command well done.
@ -2728,12 +2726,12 @@ NLMISC_COMMAND(spell, "Cast a spell", "\n"
if(args.size() != 6) if(args.size() != 6)
{ {
// Help // Help
// CInterfaceManager::getInstance()->displaySystemInfo(ucstring("This command need 2 or 3 paramters :")); // CInterfaceManager::getInstance()->displaySystemInfo("This command need 2 or 3 paramters :");
// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" <Slot> : the slot number of the entity to change")); // CInterfaceManager::getInstance()->displaySystemInfo(" <Slot> : the slot number of the entity to change");
// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(" <Behaviour> : the behaviour to play for the entity, one of the following number :")); // CInterfaceManager::getInstance()->displaySystemInfo(" <Behaviour> : the behaviour to play for the entity, one of the following number :");
// for(uint i = 0; i<MBEHAV::EMOTE_BEGIN; ++i) // for(uint i = 0; i<MBEHAV::EMOTE_BEGIN; ++i)
// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)))); // CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d - %s", i, MBEHAV::behaviourToString((MBEHAV::EBehaviour)i)));
// CInterfaceManager::getInstance()->displaySystemInfo(ucstring(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END))); // CInterfaceManager::getInstance()->displaySystemInfo(NLMISC::toString(" %d-%d - Emotes", MBEHAV::EMOTE_BEGIN, MBEHAV::EMOTE_END));
} }
else else
{ {
@ -2782,7 +2780,7 @@ NLMISC_COMMAND(spell, "Cast a spell", "\n"
entity->updateVisualProperty(NetMngr.getCurrentServerTick()+50, CLFECOMMON::PROPERTY_BEHAVIOUR); entity->updateVisualProperty(NetMngr.getCurrentServerTick()+50, CLFECOMMON::PROPERTY_BEHAVIOUR);
} }
else else
CInterfaceManager::getInstance()->displaySystemInfo(ucstring("There is no entity in the given slot")); CInterfaceManager::getInstance()->displaySystemInfo("There is no entity in the given slot");
} }
// Command well done. // Command well done.
@ -3783,7 +3781,7 @@ NLMISC_COMMAND( createPerso, "create a new character", "Parameters:\n-Character
fromString(args[4], level); fromString(args[4], level);
CBitMemStream bms; CBitMemStream bms;
string msgType = "CHEAT:CREATE_CHARACTER"; const char *msgType = "CHEAT:CREATE_CHARACTER";
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
{ {
bms.serial( characterName ); bms.serial( characterName );
@ -3814,7 +3812,7 @@ NLMISC_COMMAND( add_role, "add role to character", "<Role( MeleeFighter, RangeFi
fromString(args[1], level); fromString(args[1], level);
CBitMemStream bms; CBitMemStream bms;
string msgType = "CHEAT:ADD_ROLE"; const char *msgType = "CHEAT:ADD_ROLE";
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) ) if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
{ {
bms.serialEnum( role ); bms.serialEnum( role );
@ -3871,7 +3869,7 @@ NLMISC_COMMAND(testLongBubble, "To display a bubble with a long text", "<entity>
fromString(args[0], entityId); fromString(args[0], entityId);
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CInterfaceManager *pIM = CInterfaceManager::getInstance();
ucstring text("test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n"); string text("test\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\ntest\n");
uint duration = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutBubbles).getValSInt32(); uint duration = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutBubbles).getValSInt32();
CEntityCL *entity = EntitiesMngr.entity(entityId); CEntityCL *entity = EntitiesMngr.entity(entityId);
@ -4005,7 +4003,7 @@ NLMISC_COMMAND(displayInventoryCounter, "display the Inventory counter to compar
srvVal&= pIM->getLocalSyncActionCounterMask(); srvVal&= pIM->getLocalSyncActionCounterMask();
locVal&= pIM->getLocalSyncActionCounterMask(); locVal&= pIM->getLocalSyncActionCounterMask();
pIM->displaySystemInfo(ucstring( "ServerCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)) ); pIM->displaySystemInfo("ServerCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal));
// Well done. // Well done.
return true; return true;
@ -4023,7 +4021,7 @@ NLMISC_COMMAND(displayActionCounter, "display the action counters", "")
srvVal&= PHRASE_EXECUTE_COUNTER_MASK; srvVal&= PHRASE_EXECUTE_COUNTER_MASK;
locVal&= PHRASE_EXECUTE_COUNTER_MASK; locVal&= PHRASE_EXECUTE_COUNTER_MASK;
pIM->displaySystemInfo(ucstring( "NextCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)) ); pIM->displaySystemInfo("NextCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal));
// cycle // cycle
srvVal= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_CYCLE)->getValue32(); srvVal= NLGUI::CDBManager::getInstance()->getDbProp(PHRASE_DB_COUNTER_CYCLE)->getValue32();
@ -4031,7 +4029,7 @@ NLMISC_COMMAND(displayActionCounter, "display the action counters", "")
srvVal&= PHRASE_EXECUTE_COUNTER_MASK; srvVal&= PHRASE_EXECUTE_COUNTER_MASK;
locVal&= PHRASE_EXECUTE_COUNTER_MASK; locVal&= PHRASE_EXECUTE_COUNTER_MASK;
pIM->displaySystemInfo(ucstring( "CycleCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal)) ); pIM->displaySystemInfo("CycleCounter: " + toString(srvVal) + "/ LocalCounter: " + toString(locVal));
return true; return true;
} }
@ -4114,7 +4112,7 @@ NLMISC_COMMAND(skillToInt, "Convert a skill to an int", "")
{ {
if (args.size() != 1) return false; if (args.size() != 1) return false;
CInterfaceManager *im = CInterfaceManager::getInstance(); CInterfaceManager *im = CInterfaceManager::getInstance();
im->displaySystemInfo(ucstring(toString((uint) SKILLS::toSkill(args[0])))); im->displaySystemInfo(toString((uint) SKILLS::toSkill(args[0])));
return true; return true;
} }
@ -4144,11 +4142,11 @@ NLMISC_COMMAND(browseRingAdmin, "Browse a HTML document with the ring web browse
NLMISC_COMMAND(GUCreate, "create a guild", "<guild name>") NLMISC_COMMAND(GUCreate, "create a guild", "<guild name>")
{ {
if (args.size() != 1) return false; if (args.size() != 1) return false;
const string msgName = "GUILD:CREATE"; const char *msgName = "GUILD:CREATE";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
string buf = args[0]; ucstring buf = ucstring::makeFromUtf8(args[0]); // FIXME: UTF-8 (serial)
out.serial( buf ); out.serial( buf );
NetMngr.push(out); NetMngr.push(out);
} }
@ -4158,7 +4156,7 @@ NLMISC_COMMAND(GUCreate, "create a guild", "<guild name>")
NLMISC_COMMAND(GUQuit, "quit a guild", "") NLMISC_COMMAND(GUQuit, "quit a guild", "")
{ {
if (args.size() != 0) return false; if (args.size() != 0) return false;
const string msgName = "GUILD:QUIT"; const char *msgName = "GUILD:QUIT";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4170,7 +4168,7 @@ NLMISC_COMMAND(GUQuit, "quit a guild", "")
NLMISC_COMMAND(GULeaveLeadership, "abandon leadership of a guild", "") NLMISC_COMMAND(GULeaveLeadership, "abandon leadership of a guild", "")
{ {
if (args.size() != 0) return false; if (args.size() != 0) return false;
const string msgName = "GUILD:ABANDON_LEADERSHIP"; const char *msgName = "GUILD:ABANDON_LEADERSHIP";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4181,7 +4179,7 @@ NLMISC_COMMAND(GULeaveLeadership, "abandon leadership of a guild", "")
NLMISC_COMMAND(GULeaveOfficerTitle, "abandon officer title", "") NLMISC_COMMAND(GULeaveOfficerTitle, "abandon officer title", "")
{ {
if (args.size() != 0) return false; if (args.size() != 0) return false;
const string msgName = "GUILD:ABANDON_OFFICER_TITLE"; const char *msgName = "GUILD:ABANDON_OFFICER_TITLE";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4193,7 +4191,7 @@ NLMISC_COMMAND(GULeaveOfficerTitle, "abandon officer title", "")
NLMISC_COMMAND(GUNameOfficer, "name an officer", "<player name>") NLMISC_COMMAND(GUNameOfficer, "name an officer", "<player name>")
{ {
if (args.size() != 1) return false; if (args.size() != 1) return false;
const string msgName = "GUILD:NAME_OFFICER"; const char *msgName = "GUILD:NAME_OFFICER";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4207,7 +4205,7 @@ NLMISC_COMMAND(GUNameOfficer, "name an officer", "<player name>")
NLMISC_COMMAND(GUDismissOfficer, "dismiss an officer", "<player name>") NLMISC_COMMAND(GUDismissOfficer, "dismiss an officer", "<player name>")
{ {
if (args.size() != 1) return false; if (args.size() != 1) return false;
const string msgName = "GUILD:DISMISS_OFFICER"; const char *msgName = "GUILD:DISMISS_OFFICER";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4221,7 +4219,7 @@ NLMISC_COMMAND(GUDismissOfficer, "dismiss an officer", "<player name>")
NLMISC_COMMAND(GUKick, "kick a member", "<player name>") NLMISC_COMMAND(GUKick, "kick a member", "<player name>")
{ {
if (args.size() != 1) return false; if (args.size() != 1) return false;
const string msgName = "GUILD:KICK_MEMBER"; const char *msgName = "GUILD:KICK_MEMBER";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4248,7 +4246,7 @@ NLMISC_COMMAND(GURefuse, "refuse an invitation", "")
NLMISC_COMMAND(GUFriend, "invite a player to become a friend of the guild", "<player name>") NLMISC_COMMAND(GUFriend, "invite a player to become a friend of the guild", "<player name>")
{ {
if (args.size() != 1) return false; if (args.size() != 1) return false;
const string msgName = "GUILD:FRIEND_INVITATION"; const char *msgName = "GUILD:FRIEND_INVITATION";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4262,7 +4260,7 @@ NLMISC_COMMAND(GUFriend, "invite a player to become a friend of the guild", "<pl
NLMISC_COMMAND(GUFriendAccept, "accept to be a friend of a guild that invited you", "") NLMISC_COMMAND(GUFriendAccept, "accept to be a friend of a guild that invited you", "")
{ {
if (args.size() != 0) return false; if (args.size() != 0) return false;
const string msgName = "GUILD:ACCEPT_FRIEND_INVITATION"; const char *msgName = "GUILD:ACCEPT_FRIEND_INVITATION";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4274,7 +4272,7 @@ NLMISC_COMMAND(GUFriendAccept, "accept to be a friend of a guild that invited yo
NLMISC_COMMAND(GUFriendRefuse, "refuse to be a friend of a guild that invited you", "") NLMISC_COMMAND(GUFriendRefuse, "refuse to be a friend of a guild that invited you", "")
{ {
if (args.size() != 0) return false; if (args.size() != 0) return false;
const string msgName = "GUILD:REFUSE_FRIEND_INVITATION"; const char *msgName = "GUILD:REFUSE_FRIEND_INVITATION";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4286,7 +4284,7 @@ NLMISC_COMMAND(GUFriendRefuse, "refuse to be a friend of a guild that invited yo
NLMISC_COMMAND(GUSetSuccessor, "set the successor of the guild leader", "<player name>") NLMISC_COMMAND(GUSetSuccessor, "set the successor of the guild leader", "<player name>")
{ {
if (args.size() != 1) return false; if (args.size() != 1) return false;
const string msgName = "GUILD:SET_SUCCESSOR"; const char *msgName = "GUILD:SET_SUCCESSOR";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4300,7 +4298,7 @@ NLMISC_COMMAND(GUSetSuccessor, "set the successor of the guild leader", "<player
NLMISC_COMMAND(GUInfos, "get information on a guild", "<guild name>") NLMISC_COMMAND(GUInfos, "get information on a guild", "<guild name>")
{ {
if (args.size() != 1) return false; if (args.size() != 1) return false;
const string msgName = "GUILD:GET_INFOS"; const char *msgName = "GUILD:GET_INFOS";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4314,7 +4312,7 @@ NLMISC_COMMAND(GUInfos, "get information on a guild", "<guild name>")
NLMISC_COMMAND(GUJournal, "get the guild journal", "") NLMISC_COMMAND(GUJournal, "get the guild journal", "")
{ {
if (args.size() != 0) return false; if (args.size() != 0) return false;
const string msgName = "GUILD:GET_LOG"; const char *msgName = "GUILD:GET_LOG";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4328,7 +4326,7 @@ NLMISC_COMMAND(buildingTeleport, "teleport to a building", "building index")
if (args.size() != 1) return false; if (args.size() != 1) return false;
uint16 index; uint16 index;
fromString(args[0], index); fromString(args[0], index);
const string msgName = "GUILD:TELEPORT"; const char *msgName = "GUILD:TELEPORT";
CBitMemStream out; CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out)) if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{ {
@ -4520,7 +4518,7 @@ NLMISC_COMMAND(getSkillValue, "get a skill value by its name", "skill_name")
CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", skillId), false); CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:SKILL", skillId), false);
if(node) if(node)
{ {
pIM->displaySystemInfo(ucstring(toString(node->getValue32()))); pIM->displaySystemInfo(toString(node->getValue32()));
} }
return true; return true;
@ -4550,7 +4548,7 @@ NLMISC_COMMAND(getBaseSkillValue, "get a baseskill value by its name", "skill_na
CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", skillId), false); CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp(toString("SERVER:CHARACTER_INFO:SKILLS:%d:BaseSKILL", skillId), false);
if(node) if(node)
{ {
pIM->displaySystemInfo(ucstring(toString(node->getValue32()))); pIM->displaySystemInfo(toString(node->getValue32()));
} }
return true; return true;
@ -4812,7 +4810,7 @@ NLMISC_COMMAND(stick_log, "", "<slot>")
skel->getStickedObjects(sticks); skel->getStickedObjects(sticks);
nlinfo("StickedModels: %d", sticks.size()); nlinfo("StickedModels: %d", sticks.size());
pIM->displaySystemInfo(ucstring(toString("StickedModels: %d", sticks.size()))); pIM->displaySystemInfo(toString("StickedModels: %d", sticks.size()));
for(uint i=0;i<sticks.size();i++) for(uint i=0;i<sticks.size();i++)
{ {
@ -5328,8 +5326,8 @@ void CUserCommand::release()
// *************************************************************************** // ***************************************************************************
CUserCommand::CUserCommand(const string &commandName, const ucstring &help, const ucstring &argsHelp) CUserCommand::CUserCommand(const string &commandName, const string &help, const string &argsHelp)
: ICommand("user", commandName.c_str(), toString(help).c_str(), toString(argsHelp).c_str()) : ICommand("user", commandName.c_str(), help.c_str(), argsHelp.c_str())
{ {
CommandName = commandName; CommandName = commandName;
} }
@ -5377,13 +5375,13 @@ bool CUserCommand::execute(const std::string &/* rawCommandString */, const std:
if ((uint)index >= args.size()) if ((uint)index >= args.size())
{ {
// Not enough arguments // Not enough arguments
pIM->displaySystemInfo (ucstring(CommandName+" : ")+CI18N::get ("uiCommandWrongArgumentCount")); pIM->displaySystemInfo (CommandName+" : "+CI18N::get ("uiCommandWrongArgumentCount"));
return false; return false;
} }
else else
{ {
if (keywords[i] == "$") if (keywords[i] == "$")
finalArgs += /*ucstring(*/args[index++]/*).toUtf8()*/; finalArgs += args[index++];
else else
{ {
while (index<args.size()) while (index<args.size())
@ -5414,7 +5412,7 @@ bool CUserCommand::execute(const std::string &/* rawCommandString */, const std:
else else
{ {
// Not enough argument // Not enough argument
pIM->displaySystemInfo (ucstring(CommandName+" : ")+CI18N::get ("uiCommandWrongArgumentCount")); pIM->displaySystemInfo (CommandName+" : "+CI18N::get ("uiCommandWrongArgumentCount"));
return false; return false;
} }
return true; return true;
@ -5461,13 +5459,13 @@ void CUserCommand::createCommand (const char *name, const char *action, const ch
} }
// Find action name // Find action name
ucstring help; string help;
const CBaseAction *ab = Actions.getBaseAction (::CAction::CName (action, ptrParams)); const CBaseAction *ab = Actions.getBaseAction (::CAction::CName (action, ptrParams));
if (ab) if (ab)
help = CI18N::get(ab->LocalizedName); help = CI18N::get(ab->LocalizedName);
// Build a argument help // Build a argument help
ucstring argsHelp; string argsHelp;
if (ab) if (ab)
{ {
@ -5491,7 +5489,7 @@ void CUserCommand::createCommand (const char *name, const char *action, const ch
// Add the string // Add the string
if (!argsHelp.empty()) if (!argsHelp.empty())
argsHelp += " "; argsHelp += " ";
argsHelp += ucstring("<") + CI18N::get(ab->Parameters[j].LocalizedName) + ucstring(">"); argsHelp += "<" + CI18N::get(ab->Parameters[j].LocalizedName) + ">";
bFound = true; bFound = true;
} }
} }
@ -5658,7 +5656,7 @@ NLMISC_COMMAND(tickToDate, "convert a tick value into a readable ryzom time", ""
CInterfaceManager *im = CInterfaceManager::getInstance(); CInterfaceManager *im = CInterfaceManager::getInstance();
float ryTime = rt.getRyzomTime(); float ryTime = rt.getRyzomTime();
std::string readableDate = toString("Day = %d, hour = %d:%d", rt.getRyzomDay(), (int) floorf(ryTime), (int) floorf(60.f * fmodf(ryTime, 1.f))); std::string readableDate = toString("Day = %d, hour = %d:%d", rt.getRyzomDay(), (int) floorf(ryTime), (int) floorf(60.f * fmodf(ryTime, 1.f)));
im->displaySystemInfo(ucstring(readableDate)); im->displaySystemInfo(readableDate);
return true; return true;
} }
@ -5680,7 +5678,7 @@ NLMISC_COMMAND(dumpShapeMaxDist, "dump max dist for shapes", "")
cs->getWholeEquipmentList(equipList); cs->getWholeEquipmentList(equipList);
for (uint k = 0; k < equipList.size(); ++k) for (uint k = 0; k < equipList.size(); ++k)
{ {
std::string item = toLower(equipList[k]->getItem()); std::string item = toLowerAscii(equipList[k]->getItem());
if (!item.empty()) if (!item.empty())
{ {
@ -5930,7 +5928,7 @@ NLMISC_COMMAND(time, "Shows information about the current time", "")
tm = gmtime(&date); tm = gmtime(&date);
strftime(cs_utc, size, "%X", tm); strftime(cs_utc, size, "%X", tm);
ucstring msg = CI18N::get("uiCurrentLocalAndUtcTime"); string msg = CI18N::get("uiCurrentLocalAndUtcTime");
strFindReplace(msg, "%local", cs_local); strFindReplace(msg, "%local", cs_local);
strFindReplace(msg, "%utc", cs_utc); strFindReplace(msg, "%utc", cs_utc);
CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND"); CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND");
@ -5939,7 +5937,7 @@ NLMISC_COMMAND(time, "Shows information about the current time", "")
NLMISC_COMMAND(playedTime, "Display character played time", "") NLMISC_COMMAND(playedTime, "Display character played time", "")
{ {
ucstring msg = CI18N::get("uiPlayedTime"); string msg = CI18N::get("uiPlayedTime");
strFindReplace(msg, "%time", NLMISC::secondsToHumanReadable(CharPlayedTime)); strFindReplace(msg, "%time", NLMISC::secondsToHumanReadable(CharPlayedTime));
CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND"); CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND");
return true; return true;
@ -5947,7 +5945,7 @@ NLMISC_COMMAND(playedTime, "Display character played time", "")
NLMISC_COMMAND(version, "Display client version", "") NLMISC_COMMAND(version, "Display client version", "")
{ {
ucstring msg = getDebugVersion(); string msg = getDebugVersion();
CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND"); CInterfaceManager::getInstance()->displaySystemInfo(msg, "AROUND");
return true; return true;
} }

Loading…
Cancel
Save