Cleanup string

develop
kaetemi 4 years ago
parent c9f967b52b
commit 0d2633b697

@ -0,0 +1,131 @@
// NeL - MMORPG Framework <https://wiki.ryzom.dev/>
// Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NLMISC_STRING_VIEW_H
#define NLMISC_STRING_VIEW_H
#include <nel/misc/types_nl.h>
#include <string>
#ifdef NL_CPP14
using namespace std::string_literals;
#ifdef NL_CPP17
#include <string_view>
using namespace std::string_view_literals;
#endif
#endif
#ifdef NL_CPP14
/// Obtain an std::string from a string literal.
#define nlstr(strLit) (strLit##s)
#else
/// Obtain an std::string from a string literal.
#define nlstr(strLit) (std::string(strLit))
#endif
#ifdef NL_CPP17
/// Obtain a string view from a string literal.
#define nlsv(strLit) (strLit##sv)
/// Obtain an std::string from a string view.
#define nlsvs(strView) (std::string(strView))
#else
/// Obtain a string view from a string literal.
#define nlsv(strLit) (CStringView(strLit, ::strlen(strLit)))
/// Obtain an std::string from a string view.
#define nlsvs(strView) (std::string(strView.data(), strView.size()))
#endif
/// Obtain a temporary C-string from a string view. Use directly in argument, do not store.
#define nlsvc(strView) ((strView.data()[strView.size()]) ? nlsvs(strView).c_str() : strView.data())
namespace NLMISC {
/// String view literals allow bypassing allocation and strlen calls.
/// CStringView is a 100% drop-in replacement for (const char *str, size_t len) tuples. It's a non-owning reference.
/// Always use `CStringView` where previously `const std::string &` would have been used. It avoids accidental copy.
/// Gotcha: CStringView doesn't need to end with \0, so there's no guarantee with functions that expect \0 terminated strings,
/// use the `nlsvc` macro to get a temporary C-string from a CStringView.
/// Use the `nlsv` macro to get a CStringView from a string literal.
/// Use the `nlstr` macro to get an std::string from a string literal.
/// Use the `nlsvs` macro to get an std::string from a CStringView.
#ifdef NL_CPP17
typedef std::string_view CStringView;
#else
class CStringView
{
public:
CStringView(const std::string &str) : m_Str(&str[0]), m_Len(str.size()) {}
CStringView(const char *const str, const size_t len) : m_Str(str), m_Len(len) {}
CStringView(const char *const str) : m_Str(str), m_Len(sizeof(str)) {}
inline const char *data() const { return m_Str; }
inline size_t length() const { return m_Len; }
inline size_t size() const { return m_Len; }
inline CStringView substr(const size_t offset, const size_t count = -1) { return CStringView(m_Str + offset, std::min(m_Len - offset, count)); }
inline bool operator==(const CStringView o) { if (m_Len != o.m_Len) return false; return memcmp(m_Str, o.m_Str, m_Len) == 0; }
inline bool operator!=(const CStringView o) { if (m_Len != o.m_Len) return true; return memcmp(m_Str, o.m_Str, m_Len) != 0; }
struct const_iterator
{
public:
const_iterator() : m_Addr(NULL) { }
inline void operator++()
{
++m_Addr;
}
inline void operator+=(ptrdiff_t v)
{
m_Addr += v;
}
inline void operator--()
{
--m_Addr;
}
inline void operator-=(ptrdiff_t v)
{
m_Addr -= v;
}
inline bool operator!=(const const_iterator &o) const { return m_Addr != o.m_Addr; }
inline bool operator==(const const_iterator &o) const { return m_Addr == o.m_Addr; }
inline const char &operator*() const { return *m_Addr; }
private:
friend class CStringView;
inline const_iterator(const char *addr) : m_Addr(addr) {}
const char *m_Addr;
};
typedef const_iterator iterator;
iterator begin() const { return iterator(m_Str); }
inline iterator end() const { return iterator(m_Str + m_Len); }
private:
const char *m_Str;
size_t m_Len;
};
#endif
}
#endif /* #ifndef NLMISC_STRING_VIEW_H */
/* end of file */

@ -18,9 +18,12 @@
#define NLMISC_UTF_STRING_VIEW_H
#include <nel/misc/types_nl.h>
#include <nel/misc/ucstring.h>
#include <string>
#include <nel/misc/string_view.h>
#include <nel/misc/ucstring.h>
namespace NLMISC {
class IStream;
@ -40,6 +43,9 @@ public:
{
nlassert(len <= strlen(utf8Str));
}
inline CUtfStringView(CStringView utf8Str) : m_Str(utf8Str.data()), m_Size(utf8Str.size()), m_Iterator(utf8Iterator) {}
#if defined(NL_OS_WINDOWS)
inline CUtfStringView(const wchar_t *utf16Str) : m_Str(utf16Str), m_Size(wcslen(utf16Str)), m_Iterator(utf16Iterator) {}
inline CUtfStringView(const wchar_t *utf16Str, size_t len): m_Str(utf16Str), m_Size(len), m_Iterator(utf16Iterator)
@ -166,6 +172,6 @@ private:
} /* namespace NLMISC */
#endif /* #ifndef NLMISC_STREAMED_PACKAGE_PROVIDER_H */
#endif /* #ifndef NLMISC_UTF_STRING_VIEW_H */
/* end of file */

@ -0,0 +1,31 @@
// NeL - MMORPG Framework <https://wiki.ryzom.dev/>
// Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdmisc.h"
#include "nel/misc/string_view.h"
// STL includes
// Project includes
namespace NLMISC
{
void nothing_here_string_view_nl() { }
} /* namespace NLMISC */
/* end of file */

@ -329,7 +329,7 @@ void CClientChatManager::tell( const string& receiverIn, const string& strIn )
// *** send str
CBitMemStream bms;
string msgType = "STRING:TELL";
const char *msgType = "STRING:TELL";
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
{
bms.serial( receiver );
@ -385,7 +385,7 @@ void CClientChatManager::tell( const string& receiverIn, const string& strIn )
void CClientChatManager::filter( uint8 filter )
{
CBitMemStream bms;
string msgType = "STRING:FILTER";
const char *msgType = "STRING:FILTER";
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
{
bms.serial( filter );
@ -417,7 +417,7 @@ void CClientChatManager::setChatMode(CChatGroup::TGroupType group, TChanID dynam
if (group != CChatGroup::team)
{
CBitMemStream bms;
string msgType = "STRING:CHAT_MODE";
const char *msgType = "STRING:CHAT_MODE";
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
{
bms.serial( mode );

@ -181,14 +181,14 @@ NLMISC_COMMAND(where, "Ask information on the position", "")
// Check parameters.
if(args.empty())
{ // Create the message and send.
const string msgName = "COMMAND:WHERE";
const char *msgName = "COMMAND:WHERE";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
NetMngr.push(out);
}
else
nlwarning("command 'where': unknown message named '%s'", msgName.c_str());
nlwarning("command 'where': unknown message named '%s'", msgName);
return true;
}
return false;
@ -1803,14 +1803,14 @@ NLMISC_COMMAND(usePreprogCombat, "use the specified combat preprog sentence", "<
NLMISC_COMMAND(engage, "engage target in combat", "")
{
// Create the message for the server to execute a phrase.
const string msgName = "COMBAT:ENGAGE";
const char *msgName = "COMBAT:ENGAGE";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
NetMngr.push(out);
}
else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str());
nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true;
}
@ -1836,14 +1836,14 @@ NLMISC_COMMAND(disengage, "disengage from combat", "")
NLMISC_COMMAND(leaveTeam, "leave team", "")
{
// Create the message for the server to execute a phrase.
const string msgName = "TEAM:LEAVE";
const char *msgName = "TEAM:LEAVE";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
NetMngr.push(out);
}
else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str());
nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true;
}
@ -1851,14 +1851,14 @@ NLMISC_COMMAND(leaveTeam, "leave team", "")
NLMISC_COMMAND(joinTeam, "join the specified team", "")
{
// Create the message for the server to execute a phrase.
const string msgName = "TEAM:JOIN";
const char *msgName = "TEAM:JOIN";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
NetMngr.push(out);
}
else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str());
nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true;
}
@ -1866,14 +1866,14 @@ NLMISC_COMMAND(joinTeam, "join the specified team", "")
NLMISC_COMMAND(joinTeamProposal, "propose to current target to join the team", "")
{
// Create the message for the server to execute a phrase.
const string msgName = "TEAM:JOIN_PROPOSAL";
const char *msgName = "TEAM:JOIN_PROPOSAL";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
NetMngr.push(out);
}
else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str());
nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true;
}
@ -1881,14 +1881,14 @@ NLMISC_COMMAND(joinTeamProposal, "propose to current target to join the team", "
NLMISC_COMMAND(joinTeamDecline, "decline a join team proposal", "")
{
// 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;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
NetMngr.push(out);
}
else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str());
nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true;
}
@ -1896,14 +1896,14 @@ NLMISC_COMMAND(joinTeamDecline, "decline a join team proposal", "")
NLMISC_COMMAND(kickTeammate, "kick someone from your team", "")
{
// Create the message for the server to execute a phrase.
const string msgName = "TEAM:KICK";
const char *msgName = "TEAM:KICK";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
NetMngr.push(out);
}
else
nlwarning("mainLoop : unknown message name : '%s'", msgName.c_str());
nlwarning("mainLoop : unknown message name : '%s'", msgName);
return true;
}
@ -1913,14 +1913,14 @@ NLMISC_COMMAND(cancelCurrentSentence, "cancel the sentence being executed", "")
// no parameter needed
// 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;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
NetMngr.push(out);
}
else
nlwarning("command : unknown message name : '%s'", msgName.c_str());
nlwarning("command : unknown message name : '%s'", msgName);
return true;
}
@ -1952,7 +1952,7 @@ NLMISC_COMMAND(drop,"drop an item to the ground","<id>")
sint32 z = (sint32)UserEntity->pos().z * 1000;
CBitMemStream bms;
string msgType = "ITEM:DROP";
const char *msgType = "ITEM:DROP";
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
{
bms.serial( itemId );
@ -3769,7 +3769,7 @@ NLMISC_COMMAND( createPerso, "create a new character", "Parameters:\n-Character
fromString(args[4], level);
CBitMemStream bms;
string msgType = "CHEAT:CREATE_CHARACTER";
const char *msgType = "CHEAT:CREATE_CHARACTER";
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
{
bms.serial( characterName );
@ -3800,7 +3800,7 @@ NLMISC_COMMAND( add_role, "add role to character", "<Role( MeleeFighter, RangeFi
fromString(args[1], level);
CBitMemStream bms;
string msgType = "CHEAT:ADD_ROLE";
const char *msgType = "CHEAT:ADD_ROLE";
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
{
bms.serialEnum( role );
@ -4130,11 +4130,11 @@ NLMISC_COMMAND(browseRingAdmin, "Browse a HTML document with the ring web browse
NLMISC_COMMAND(GUCreate, "create a guild", "<guild name>")
{
if (args.size() != 1) return false;
const string msgName = "GUILD:CREATE";
const char *msgName = "GUILD:CREATE";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
string buf = args[0];
ucstring buf = ucstring::makeFromUtf8(args[0]); // FIXME: UTF-8 (serial)
out.serial( buf );
NetMngr.push(out);
}
@ -4144,7 +4144,7 @@ NLMISC_COMMAND(GUCreate, "create a guild", "<guild name>")
NLMISC_COMMAND(GUQuit, "quit a guild", "")
{
if (args.size() != 0) return false;
const string msgName = "GUILD:QUIT";
const char *msgName = "GUILD:QUIT";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4156,7 +4156,7 @@ NLMISC_COMMAND(GUQuit, "quit a guild", "")
NLMISC_COMMAND(GULeaveLeadership, "abandon leadership of a guild", "")
{
if (args.size() != 0) return false;
const string msgName = "GUILD:ABANDON_LEADERSHIP";
const char *msgName = "GUILD:ABANDON_LEADERSHIP";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4167,7 +4167,7 @@ NLMISC_COMMAND(GULeaveLeadership, "abandon leadership of a guild", "")
NLMISC_COMMAND(GULeaveOfficerTitle, "abandon officer title", "")
{
if (args.size() != 0) return false;
const string msgName = "GUILD:ABANDON_OFFICER_TITLE";
const char *msgName = "GUILD:ABANDON_OFFICER_TITLE";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4179,7 +4179,7 @@ NLMISC_COMMAND(GULeaveOfficerTitle, "abandon officer title", "")
NLMISC_COMMAND(GUNameOfficer, "name an officer", "<player name>")
{
if (args.size() != 1) return false;
const string msgName = "GUILD:NAME_OFFICER";
const char *msgName = "GUILD:NAME_OFFICER";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4193,7 +4193,7 @@ NLMISC_COMMAND(GUNameOfficer, "name an officer", "<player name>")
NLMISC_COMMAND(GUDismissOfficer, "dismiss an officer", "<player name>")
{
if (args.size() != 1) return false;
const string msgName = "GUILD:DISMISS_OFFICER";
const char *msgName = "GUILD:DISMISS_OFFICER";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4207,7 +4207,7 @@ NLMISC_COMMAND(GUDismissOfficer, "dismiss an officer", "<player name>")
NLMISC_COMMAND(GUKick, "kick a member", "<player name>")
{
if (args.size() != 1) return false;
const string msgName = "GUILD:KICK_MEMBER";
const char *msgName = "GUILD:KICK_MEMBER";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4234,7 +4234,7 @@ NLMISC_COMMAND(GURefuse, "refuse an invitation", "")
NLMISC_COMMAND(GUFriend, "invite a player to become a friend of the guild", "<player name>")
{
if (args.size() != 1) return false;
const string msgName = "GUILD:FRIEND_INVITATION";
const char *msgName = "GUILD:FRIEND_INVITATION";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4248,7 +4248,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", "")
{
if (args.size() != 0) return false;
const string msgName = "GUILD:ACCEPT_FRIEND_INVITATION";
const char *msgName = "GUILD:ACCEPT_FRIEND_INVITATION";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4260,7 +4260,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", "")
{
if (args.size() != 0) return false;
const string msgName = "GUILD:REFUSE_FRIEND_INVITATION";
const char *msgName = "GUILD:REFUSE_FRIEND_INVITATION";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4272,7 +4272,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>")
{
if (args.size() != 1) return false;
const string msgName = "GUILD:SET_SUCCESSOR";
const char *msgName = "GUILD:SET_SUCCESSOR";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4286,7 +4286,7 @@ NLMISC_COMMAND(GUSetSuccessor, "set the successor of the guild leader", "<player
NLMISC_COMMAND(GUInfos, "get information on a guild", "<guild name>")
{
if (args.size() != 1) return false;
const string msgName = "GUILD:GET_INFOS";
const char *msgName = "GUILD:GET_INFOS";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4300,7 +4300,7 @@ NLMISC_COMMAND(GUInfos, "get information on a guild", "<guild name>")
NLMISC_COMMAND(GUJournal, "get the guild journal", "")
{
if (args.size() != 0) return false;
const string msgName = "GUILD:GET_LOG";
const char *msgName = "GUILD:GET_LOG";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4314,7 +4314,7 @@ NLMISC_COMMAND(buildingTeleport, "teleport to a building", "building index")
if (args.size() != 1) return false;
uint16 index;
fromString(args[0], index);
const string msgName = "GUILD:TELEPORT";
const char *msgName = "GUILD:TELEPORT";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{

@ -1706,7 +1706,7 @@ public:
string sCharSumPath = getParam(Params, "charsum");
SCharacter3DSetup::setupCharacterSummaryFromDB(CS, sCharSumPath);
CS.Mainland = MainlandSelected;
CS.Name = sFirstName;
CS.Name = ucstring::makeFromUtf8(sFirstName); // FIXME: UTF-8 (serial)
//CS.Surname = sSurName;
// Create the message to send to the server from the character summary

@ -1010,13 +1010,13 @@ void CFarTP::hookNextFarTPForEditor()
*/
void CFarTP::requestReturnToPreviousSession(TSessionId rejectedSessionId)
{
const string msgName = "CONNECTION:RET_MAINLAND";
const char *msgName = "CONNECTION:RET_MAINLAND";
CBitMemStream out;
nlverify(GenericMsgHeaderMngr.pushNameToStream(msgName, out));
out.serial(PlayerSelectedSlot);
out.serial(rejectedSessionId);
NetMngr.push(out);
nlinfo("%s sent", msgName.c_str());
nlinfo("%s sent", msgName);
}
/*

@ -1166,7 +1166,7 @@ public:
game_exit_request = true;
ryzom_exit_request = true;
const string msgName = "CONNECTION:CLIENT_QUIT_REQUEST";
const char *msgName = "CONNECTION:CLIENT_QUIT_REQUEST";
CBitMemStream out;
nlverify(GenericMsgHeaderMngr.pushNameToStream(msgName, out));
bool bypassDisconnectionTimer = FarTP.isFastDisconnectGranted() && (!IsInRingSession); // no need on a ring shard, as it's very short
@ -1489,7 +1489,7 @@ void beastOrder (const std::string &orderStr, const std::string &beastIndexStr,
else
{
// execute the order.
const string msgName = "ANIMALS:BEAST";
const char *msgName = "ANIMALS:BEAST";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -1500,7 +1500,7 @@ void beastOrder (const std::string &orderStr, const std::string &beastIndexStr,
NetMngr.push(out);
}
else
nlwarning("<beastOrder> : unknown message name : '%s'.", msgName.c_str());
nlwarning("<beastOrder> : unknown message name : '%s'.", msgName);
}
}
@ -4530,7 +4530,7 @@ public:
if( sCustomPhrase.empty() )
{
// Create the message and send.
static const string msgName = "COMMAND:EMOTE";
static const char *msgName = "COMMAND:EMOTE";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4540,12 +4540,12 @@ public:
//nlinfo("impulseCallBack : %s %d %d sent", msgName.c_str(), (uint32)behavToSend, phraseNbToSend);
}
else
nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str());
nlwarning("command 'emote': unknown message named '%s'.", msgName);
}
else
{
// Create the message and send.
static const string msgName = "COMMAND:CUSTOM_EMOTE";
static const char *msgName = "COMMAND:CUSTOM_EMOTE";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
@ -4575,7 +4575,7 @@ public:
//nlinfo("impulseCallBack : %s %d %s sent", msgName.c_str(), (uint32)behavToSend, sCustomPhrase.c_str());
}
else
nlwarning("command 'emote': unknown message named '%s'.", msgName.c_str());
nlwarning("command 'emote': unknown message named '%s'.", msgName);
}
}
};

@ -3706,17 +3706,17 @@ public:
sint n = PeopleInterraction.TeamList.getIndexFromName(selection->getEntityName());
if (n >= 0)
{
const string msgName = "TEAM:KICK";
const char *msgName = "TEAM:KICK";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
uint8 teamMember = (uint8)n;
out.serialEnum(teamMember);
NetMngr.push(out);
//nlinfo("impulseCallBack : %s %d sent", msgName.c_str(), teamMember);
//nlinfo("impulseCallBack : %s %d sent", msgName, teamMember);
}
else
nlwarning("unknown message named '%s'.", msgName.c_str());
nlwarning("unknown message named '%s'.", msgName);
}
}
}

@ -417,10 +417,10 @@ void CInterfaceItemEdition::CItemEditionWindow::validate()
if (textValid)
{
CBitMemStream out;
const string msgName = "EVENT:SET_ITEM_CUSTOM_TEXT";
const char *msgName = "EVENT:SET_ITEM_CUSTOM_TEXT";
if (!GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{
nlwarning ("don't know message name %s", msgName.c_str());
nlwarning ("don't know message name %s", msgName);
}
else
{
@ -456,7 +456,7 @@ static void checkItemCommand(const CItemSheet *itemSheet);
static void sendSwapItemMsg(const CDBCtrlSheet *pCSSrc, const CDBCtrlSheet *pCSDst, sint32 quantitySrc)
{
CBitMemStream out;
const string sMsg = "ITEM:SWAP";
const char *sMsg = "ITEM:SWAP";
if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
{
// Swap all the Src (quantity= quantitySrc) to dest
@ -489,7 +489,7 @@ static void sendSwapItemMsg(const CDBCtrlSheet *pCSSrc, const CDBCtrlSheet *pCSD
//nlinfo("impulseCallBack : %s %d %d %d %d %d sent", sMsg.c_str(), srcInvId, srcSlotId, dstInvId, dstSlotId, quantity);
}
else
nlwarning(" unknown message name '%s'",sMsg.c_str());
nlwarning(" unknown message name '%s'",sMsg);
}
/** Display the popup to ask item quantity
@ -567,7 +567,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CBitMemStream out;
const string sMsg = "EXCHANGE:ADD";
const char *sMsg = "EXCHANGE:ADD";
if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
{
// Swap all the Src (quantity= quantitySrc) to dest
@ -580,7 +580,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet
//nlinfo("impulseCallBack : %s %d %d %d sent", sMsg.c_str(), srcSlotIndex, destSlotIndex, quantitySrc);
}
else
nlwarning(" unknown message name '%s'",sMsg.c_str());
nlwarning(" unknown message name '%s'",sMsg);
}
//=====================================================================================================================
@ -636,8 +636,8 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet
// send msg to server
CBitMemStream out;
const string sMsg = "EXCHANGE:REMOVE";
if(GenericMsgHeaderMngr.pushNameToStream(sMsg.c_str(), out))
const char *sMsg = "EXCHANGE:REMOVE";
if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
{
// Swap all the Src (quantity= quantitySrc) to dest
uint16 slotIndex = (uint16) exchangeSlot->getIndexInDB();
@ -647,7 +647,7 @@ static void openStackItem(CCtrlBase *pCaller, CDBCtrlSheet *pCSSrc, CDBCtrlSheet
//nlinfo("impulseCallBack : %s %d sent", sMsg.c_str(), slotIndex);
}
else
nlwarning(" unknown message name '%s'",sMsg.c_str());
nlwarning(" unknown message name '%s'",sMsg);
}
@ -1658,7 +1658,7 @@ REGISTER_ACTION_HANDLER( CHandlerDragNDrop, "drag_n_drop" );
static void sendToServerEnchantMessage(uint8 invent, uint16 slot)
{
CBitMemStream out;
const string sMsg = "ITEM:ENCHANT";
const char *sMsg = "ITEM:ENCHANT";
if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
{
@ -1667,7 +1667,7 @@ static void sendToServerEnchantMessage(uint8 invent, uint16 slot)
NetMngr.push(out);
}
else
nlinfo("unknown message %s", sMsg.c_str());
nlinfo("unknown message %s", sMsg);
}
// **********************************************************************************************************
@ -2230,7 +2230,7 @@ static void sendMsgUseItem(uint16 slot)
if(!ClientCfg.Local)
{
CBitMemStream out;
const string sMsg = "ITEM:USE_ITEM";
const char *sMsg = "ITEM:USE_ITEM";
if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
{
@ -2238,7 +2238,7 @@ static void sendMsgUseItem(uint16 slot)
NetMngr.push(out);
}
else
nlinfo("unknown message %s", sMsg.c_str());
nlinfo("unknown message %s", sMsg);
}
}
@ -2248,7 +2248,7 @@ static void sendMsgStopUseXpCat( bool isRingCatalyser )
if(!ClientCfg.Local)
{
CBitMemStream out;
const string sMsg = "ITEM:STOP_USE_XP_CAT";
const char *sMsg = "ITEM:STOP_USE_XP_CAT";
if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
{
@ -2256,7 +2256,7 @@ static void sendMsgStopUseXpCat( bool isRingCatalyser )
NetMngr.push(out);
}
else
nlinfo("unknown message %s", sMsg.c_str());
nlinfo("unknown message %s", sMsg);
}
}

@ -471,7 +471,7 @@ public:
startAttackTime= node->getValue32();
// send a DECLARE_WAR_VALIDATE message to server
string sMsg= "OUTPOST:DECLARE_WAR_VALIDATE";
const char *sMsg= "OUTPOST:DECLARE_WAR_VALIDATE";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
{
@ -483,7 +483,7 @@ public:
}
else
{
nlwarning("command : unknown message name : '%s'.", sMsg.c_str());
nlwarning("command : unknown message name : '%s'.", sMsg);
}
}
@ -508,7 +508,7 @@ public:
// Send a msg to server
if(outpostSheet)
{
string sMsg= "OUTPOST:SELECT";
const char *sMsg= "OUTPOST:SELECT";
CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(sMsg, out))
{
@ -518,7 +518,7 @@ public:
}
else
{
nlwarning("command : unknown message name : '%s'.", sMsg.c_str());
nlwarning("command : unknown message name : '%s'.", sMsg);
}
}
}

@ -79,7 +79,7 @@ class CHandlerGuildCreate : public IActionHandler
uint64 icon = CGuildManager::iconMake((uint8)pCS->getGuildBack(), (uint8)pCS->getGuildSymbol(),
pCS->getInvertGuildSymbol(), pCS->getGuildColor1(), pCS->getGuildColor2());
const string msgName = "GUILD:CREATE";
const char *msgName = "GUILD:CREATE";
NLMISC::CBitMemStream out;
if(GenericMsgHeaderMngr.pushNameToStream(msgName, out))
{

Loading…
Cancel
Save