Fixed: #1449 Added missing header, fixed CMake configuration, fixed iterators. GUS builds fine without MFC extensions.

This commit is contained in:
sfb 2012-03-12 13:28:56 -05:00
parent ade9ab1689
commit 66d5b0b879
8 changed files with 300 additions and 99 deletions

View file

@ -0,0 +1,174 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// 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 TXT_COMMAND_H
#define TXT_COMMAND_H
//-------------------------------------------------------------------------------------------------
// includes
//-------------------------------------------------------------------------------------------------
#include "nel/misc/types_nl.h"
#include "nel/misc/common.h"
#include "nel/misc/debug.h"
#include "nel/misc/sstring.h"
//-------------------------------------------------------------------------------------------------
// MACRO TXT_COMMAND_SET
//-------------------------------------------------------------------------------------------------
#define TXT_COMMAND_SET(setName,CONTEXT_CLASS)\
class __CTxtCommandSet_##setName: public ITxtCommandSet<CONTEXT_CLASS>\
{\
public:\
static __CTxtCommandSet_##setName* getInstance()\
{\
static __CTxtCommandSet_##setName *p=NULL;\
if (p==NULL) p= new __CTxtCommandSet_##setName;\
return p;\
}\
};\
static CTxtCommandSetPtr<__CTxtCommandSet_##setName> setName;
//-------------------------------------------------------------------------------------------------
// MACRO TXT_COMMAND
//-------------------------------------------------------------------------------------------------
#define TXT_COMMAND(cmdName,setName,CONTEXT_CLASS)\
struct __CTxtCommand_##cmdName: public ITxtCommand<CONTEXT_CLASS>\
{\
static __CTxtCommand_##cmdName* getInstance()\
{\
static __CTxtCommand_##cmdName *p=NULL;\
if (p==NULL) p= new __CTxtCommand_##cmdName;\
return p;\
}\
virtual const char* getName() const {return #cmdName;}\
virtual CTxtCommandResult execute(CONTEXT_CLASS& context,const NLMISC::CVectorSString& args,const NLMISC::CSString& rawArgs,const NLMISC::CSString& fullCmdLine);\
private:\
__CTxtCommand_##cmdName() {}\
};\
static ITxtCommandRegisterer<__CTxtCommand_##cmdName,__CTxtCommandSet_##setName> __CTxtCommand_##cmdName##_Registerer;\
CTxtCommandResult __CTxtCommand_##cmdName::execute(CONTEXT_CLASS& context,const NLMISC::CVectorSString& args,const NLMISC::CSString& rawArgs,const NLMISC::CSString& fullCmdLine)
//-------------------------------------------------------------------------------------------------
// class CTxtCommandResult
//-------------------------------------------------------------------------------------------------
class CTxtCommandResult
{
public:
enum TType
{
SUCCESS, // command execution was successful
SYNTAX_ERROR, // there was a syntax error in the command line
BAD_PERMISSION, // the user doesn't have the right to run the given command
UNKNOWN_COMMAND, // behave as if the command was not recognised
EXECUTION_ERROR // there was an error during execution of the command
};
CTxtCommandResult(const bool& success): _Type(success?SUCCESS:SYNTAX_ERROR) {}
CTxtCommandResult(const TType& type): _Type(type) {}
CTxtCommandResult(const TType& type,const NLMISC::CSString& reason): _Type(type), _Reason(reason) {}
TType getType() const { return _Type; }
const NLMISC::CSString& getReason() const { return _Reason; }
private:
TType _Type;
NLMISC::CSString _Reason;
};
//-------------------------------------------------------------------------------------------------
// class ITxtCommand
//-------------------------------------------------------------------------------------------------
template <class CONTEXT_CLASS> class ITxtCommand
{
public:
virtual const char* getName() const =0;
virtual CTxtCommandResult execute(CONTEXT_CLASS& context,const NLMISC::CVectorSString& args,const NLMISC::CSString& rawArgs,const NLMISC::CSString& fullCmdLine) =0;
};
//-------------------------------------------------------------------------------------------------
// class ITxtCommandRegisterer
//-------------------------------------------------------------------------------------------------
template <class CMD,class SET> struct ITxtCommandRegisterer
{
ITxtCommandRegisterer()
{
SET::getInstance()->registerTxtCommand(CMD::getInstance());
}
};
//-------------------------------------------------------------------------------------------------
// class ITxtCommandSet
//-------------------------------------------------------------------------------------------------
template <class CONTEXT_CLASS> class ITxtCommandSet
{
public:
void registerTxtCommand(ITxtCommand<CONTEXT_CLASS>* txtCommand)
{
nlassert(_TxtCommands.find(txtCommand->getName())==_TxtCommands.end());
_TxtCommands[txtCommand->getName()]= txtCommand;
}
CTxtCommandResult execute(CONTEXT_CLASS& context,const NLMISC::CSString& cmdLine)
{
NLMISC::CSString cmdTail=cmdLine;
NLMISC::CSString keyword=cmdTail.firstWord(true);
typename TTxtCommands::iterator it= _TxtCommands.find(keyword);
if (it==_TxtCommands.end()) return CTxtCommandResult::UNKNOWN_COMMAND;
NLMISC::CVectorSString args;
cmdTail.splitWords(args);
return it->second->execute(context,args,cmdTail,cmdLine);
}
private:
typedef ITxtCommand<CONTEXT_CLASS> TTxtCommand;
typedef std::map<NLMISC::CSString,TTxtCommand*> TTxtCommands;
TTxtCommands _TxtCommands;
};
//-------------------------------------------------------------------------------------------------
// class ITxtCommandRegisterer
//-------------------------------------------------------------------------------------------------
template <class SET> struct CTxtCommandSetPtr
{
CTxtCommandSetPtr()
{
SET::getInstance();
}
SET& operator*()
{
return *SET::getInstance();
}
SET* operator->()
{
return SET::getInstance();
}
};
//-------------------------------------------------------------------------------------------------
#endif

View file

@ -34,7 +34,7 @@ ADD_SUBDIRECTORY(patchman_service)
#ADD_SUBDIRECTORY(ags_test)
#ADD_SUBDIRECTORY(ai_data_service)
#ADD_SUBDIRECTORY(entity_view_service)
#ADD_SUBDIRECTORY(general_utilities_service)
ADD_SUBDIRECTORY(general_utilities_service)
# Not sure, no longer used maybe?
#sabrina

View file

@ -11,9 +11,120 @@ LIST(REMOVE_ITEM SRC
${CMAKE_CURRENT_SOURCE_DIR}/re_repository_emitter.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rr_module_itf.cpp
${CMAKE_CURRENT_SOURCE_DIR}/rr_module_itf.h
${CMAKE_CURRENT_SOURCE_DIR}/rr_repository_reciever.cpp)
${CMAKE_CURRENT_SOURCE_DIR}/rr_repository_reciever.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mfc/*)
ADD_EXECUTABLE(ryzom_general_utilities_service ${SRC})
SOURCE_GROUP("Documentation" FILES ss_notes.txt
ce_notes.txt
ec_notes.txt
ee_notes.txt
em_notes.txt
merge_notes.txt
gus_module_notes.txt
gus_net_notes.txt
saves_notes.txt
rs_notes.txt
rsaves_notes.txt
stats_notes.txt
server control module notes.txt)
SOURCE_GROUP("GUS Modules\\Contest Control (CC)" FILES cc_commands.cpp cc_contest_ctrl_script.cpp cc_contest_ctrl_script.h cc_module_messages.h)
SOURCE_GROUP("GUS Modules\\Contest Executor (CE)" FILES ce_commands.cpp ce_contest_executor.cpp ce_module_messages.h ce_contest_executor.h)
SOURCE_GROUP("GUS Modules\\Contest Logger (CL)" FILES cl_contest_logger.cpp cl_module_messages.h)
SOURCE_GROUP("GUS Modules\\Event Chat (EC)" FILES ec_channel.cpp
ec_channel.h
ec_ctrl_channel.cpp
ec_ctrl_channel.h
ec_event_chat.cpp
ec_event_chat_module.cpp
ec_event_chat_module.h
ec_faction_channel.cpp
ec_faction_channel.h
ec_party_channel.cpp
ec_party_channel.h
ec_types.h)
SOURCE_GROUP("GUS Modules\\Event Executor (EE)" FILES ee_event_executor.cpp ee_event_executor.h ee_module_messages.h)
SOURCE_GROUP("GUS Modules\\Event Executor (EE)" FILES em_commands.cpp em_event_manager.cpp em_event_manager.h em_module_messages.h)
SOURCE_GROUP("GUS Modules\\Shard Merge (MERGE)" FILES merge_commands.cpp merge_shard_merger.cpp)
SOURCE_GROUP("GUS Modules\\Remote Saves (RSAVES)" FILES remote_saves_interface.cpp remote_saves_interface.h rs_remote_saves.cpp rs_remote_saves.h rs_module_messages.h)
SOURCE_GROUP("GUS Modules\\Shard Saves (SAVES)" FILES saves_module_messages.h saves_shard_saves.cpp saves_unit.cpp saves_unit.h)
SOURCE_GROUP("GUS Modules\\Shard Script (SS)" FILES ss_command_executor.cpp
ss_command_executor.h
ss_script_manager.cpp
ss_commands.cpp
ss_script_manager.h
ss_service_comms_manager.cpp
ss_service_comms_manager.h
ss_state_manager.cpp
ss_state_manager.h)
SOURCE_GROUP("GUS Modules\\Stats Scan (STATS)" FILES stats_guild_commands.cpp
stats_guild_scan_job.cpp
stats_guild_scan_job.h
stat_character.cpp
stat_character.h
stat_character_scan_job.cpp
stat_character_scan_job.h
stat_char_commands.cpp
stat_char_filter_factory.cpp
stat_char_filter_factory.h
stat_char_info_extractor_factory.cpp
stat_char_info_extractor_factory.h
stat_char_scan_script.cpp
stat_char_scan_script.h
stat_file_list_builder_factory.cpp
stat_file_list_builder_factory.h
stat_globals.cpp stat_globals.h
stat_guild_container.cp
stat_guild_container.h
stat_job_manager.cpp
stat_job_manager.h
stat_user_char_filters.cpp
stat_user_char_info_extractors.cpp
stat_user_file_list_builders.cpp)
SOURCE_GROUP("GUS Modules\\GUS Networking" FILES gus_net.cpp
gus_net.h
gus_net_commands.cpp
gus_net_connection.cpp
gus_net_connection.h
gus_net_hub.cpp
gus_net_hub.h
gus_net_implementation.cpp
gus_net_implementation.h
gus_net_messages.cpp
gus_net_messages.h
gus_net_remote_module.cpp
gus_net_remote_module.h
gus_net_types.h)
SOURCE_GROUP("GUS Modules" FILES gus_module.cpp gus_module.h gus_module_commands.cpp gus_module_factory.cpp gus_module_factory.h gus_module_manager.cpp gus_module_manager.h)
SOURCE_GROUP("GUS Core" FILES gus_chat.cpp
gus_chat.h
gus_client_manager.cpp
gus_client_manager.h
gus_mirror.cpp
gus_mirror.h
gus_text.cpp
gus_text.h
gus_utils.cpp
gus_utils.h
gus_util_commands.cpp)
ADD_EXECUTABLE(ryzom_general_utilities_service WIN32 ${SRC})
INCLUDE_DIRECTORIES(${RZ_SERVER_SRC_DIR} ${LIBXML2_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${NEL_INCLUDE_DIR})
@ -26,7 +137,7 @@ TARGET_LINK_LIBRARIES(ryzom_general_utilities_service
${ZLIB_LIBRARIES}
nelmisc
nelnet
nelgeorges}
nelgeorges
nelligo)
NL_DEFAULT_PROPS(ryzom_general_utilities_service "Ryzom, Services: General Utilities Service (GUS)")

View file

@ -312,7 +312,8 @@ NLMISC_CATEGORISED_COMMAND(EventManager,emUpdateTools,"update tools installed on
// Extra commands that open MFC windows
//-----------------------------------------------------------------------------
#ifdef _WINDOWS
//#ifdef _WINDOWS
#if 0
#include "mfc/stdafx.h"
#include "nel/misc/win_displayer.h"

View file

@ -358,7 +358,7 @@ void CEventManagerImplementation::displayModule() const
for (TShards::const_iterator it=_Shards.begin(); it!=_Shards.end(); ++it)
{
CSString s= (*it).first+ ": ";
for (TShardsMapEntry::iterator it2= (*it).second.begin(); it2!=(*it).second.end(); ++it2)
for (TShardsMapEntry::const_iterator it2= (*it).second.begin(); it2!=(*it).second.end(); ++it2)
{
s+= NLMISC::toString((*it2))+" ";
}
@ -478,7 +478,7 @@ void CEventManagerImplementation::startEvent(const NLMISC::CSString& shardName)
// build vector of destinations to send the module message to
TModuleIdVector moduleIds;
for (TShardsMapEntry::iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it)
for (TShardsMapEntry::const_iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it)
{
nlinfo("Sending event start request to event executor: %d",(*it));
moduleIds.push_back(*it);
@ -502,7 +502,7 @@ void CEventManagerImplementation::stopEvent(const NLMISC::CSString& shardName)
// build vector of destinations to send the module message to
TModuleIdVector moduleIds;
for (TShardsMapEntry::iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it)
for (TShardsMapEntry::const_iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it)
{
nlinfo("Sending event stop request to event executor: %d",(*it));
moduleIds.push_back(*it);
@ -569,7 +569,7 @@ void CEventManagerImplementation::peekInstalledEvent(const NLMISC::CSString& sha
// build vector of destinations to send the module message to
TModuleIdVector moduleIds;
for (TShardsMapEntry::iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it)
for (TShardsMapEntry::const_iterator it= (*shard).second.begin(); it!= (*shard).second.end(); ++it)
{
nlinfo("Sending history request to event executor: %d",(*it));
moduleIds.push_back(*it);

View file

@ -45,74 +45,6 @@ using namespace NLNET;
namespace GUS
{
//-----------------------------------------------------------------------------
// cleanPath - convert a path to standardised format
//-----------------------------------------------------------------------------
CSString cleanPath(const CSString& path,bool addTrailingSlash)
{
CSString result;
// split the path up into its component elements
CVectorSString pathComponents;
path.unquoteIfQuoted().splitByOneOfSeparators("/\\",pathComponents,false,false,true,false,true);
// iterate over path components collapsing '.' and '..' entries
for (uint32 i=0;i<pathComponents.size();++i)
{
// skip "." entries
if (pathComponents[i]==".")
{
pathComponents[i].clear();
continue;
}
// deal with ".."
if (pathComponents[i]=="..")
{
// run back through our component list looking for an element to remove
uint32 j;
for (j=i;j--;)
{
if (!pathComponents[j].empty())
break;
}
// if we found an element then remove it and the '..' as well
if (j!=~0u)
{
pathComponents[j].clear();
pathComponents[i].clear();
}
continue;
}
}
// treat the special case where oriinal path started with a '/' or '//'
if (path.left(1)=="/" || path.left(1)=="\\")
{
result= (path.left(2).right(1)=="/" || path.left(2).right(1)=="\\")? "//": "/";
}
// concatenate the path bits
for (uint32 i=0;i<pathComponents.size();++i)
{
if (!pathComponents[i].empty())
{
result+= pathComponents[i];
result+= '/';
}
}
// if we're not supposed to have a trailing slash then get rid of the one that's added by default
if (addTrailingSlash==false && path.right(1)!='/' && path.right(1)!='\\')
{
result.resize(result.size()-1);
}
return result;
}
//-----------------------------------------------------------------------------
// private routines for layer 5 service tracking
//-----------------------------------------------------------------------------

View file

@ -39,27 +39,6 @@ namespace GUS
// handy utilities
//-----------------------------------------------------------------------------
// Clean a path performing the following operations:
// - convert '\\' characters to '/'
// - replace '//' strings in the middle of the path with '/'
// - remove '.' directory entries
// - colapse '..' directory entries (removing parent entries)
// - append a final '/' (optionally)
//
// examples:
// - a:/bcd/efg/ => a:/bcd/efg/ (no change)
// - a:\bcd\efg => a:/bcd/efg/
// - \bcd\\efg => /bcd/efg/
// - \\bcd\efg => //bcd/efg/
// - \bcd\.\efg => /bcd/efg/
// - \bcd\..\efg => /efg/
// - bcd\..\efg => efg/
// - bcd\..\..\efg => ../efg/
// - \bcd\..\..\efg => /efg/ (NOTE: the redundant '..' entry is lost due to leading '\')
//
NLMISC::CSString cleanPath(const NLMISC::CSString& path,bool addTrailingSlash);
// execute a command on a remote service
void executeRemoteCommand(NLNET::TServiceId sid,const NLMISC::CSString& cmdLine);
void executeRemoteCommand(const char* serviceName,const NLMISC::CSString& cmdLine);

View file

@ -28,11 +28,15 @@
#include "game_share/ryzom_version.h"
#include "game_share/tick_event_handler.h"
#include "game_share/singleton_registry.h"
#include "game_share/handy_commands.h"
#include "server_share/handy_commands.h"
// local
#include "service_main.h"
#ifdef NL_OS_WINDOWS
# define NOMINMAX
# include <windows.h>
#endif // NL_OS_WINDOWS
//-----------------------------------------------------------------------------
// namespaces