Planeshift
psserver.h
Go to the documentation of this file.
1 /*
2  * psserver.h
3  *
4  * Copyright (C) 2001 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef __PSSERVER_H__
21 #define __PSSERVER_H__
22 #include "psstdint.h"
23 
24 //=============================================================================
25 // Crystal Space Includes
26 //=============================================================================
27 #include <csutil/ref.h>
28 #include <csutil/randomgen.h>
29 #include <csutil/csstring.h>
30 
31 //=============================================================================
32 // Project Includes
33 //=============================================================================
34 #include "util/psconst.h"
35 
36 //=============================================================================
37 // Local Includes
38 //=============================================================================
39 
40 
41 struct iObjectRegistry;
42 struct iConfigManager;
43 class NetManager;
44 struct iChat;
45 class EntityManager;
46 class MsgHandler; // Receive and distributes incoming messages.
48 class ChatManager;
49 class GuildManager;
50 class GroupManager;
51 class AdminManager;
52 class UserManager;
53 class WeatherManager;
54 class psTimerThread;
55 class psDatabase;
56 class ServerCharManager;
57 class SpawnManager;
58 class EventManager;
59 class TutorialManager;
60 class ServerStatus;
61 class psMarriageManager;
62 class CombatManager;
63 class SpellManager;
64 class ExchangeManager;
65 class ProgressionManager;
66 class NPCManager;
67 class CacheManager;
68 class psCharacterLoader;
69 class csRandomGen;
71 class QuestManager;
72 class EconomyManager;
73 class WorkManager;
74 class QuestionManager;
76 class Client;
77 class MathScriptEngine;
78 class AdviceManager;
79 class ActionManager;
81 class ServerSongManager;
82 class MiniGameManager;
83 class LogCSV;
84 class iResultSet;
85 class csVector3;
86 struct iVFS;
87 class GMEventManager;
88 class BankManager;
89 class HireManager;
90 class ServerConsole;
91 class psQuitEvent;
92 
102 class psServer
103 {
104 public:
105 
111  psServer();
112 
119  ~psServer();
120 
149  bool Initialize(iObjectRegistry* objreg);
150 
162  void MainLoop();
163 
169  bool IsMapLoaded()
170  {
171  return MapLoaded;
172  }
173 
180  bool LoadMap(const char* mapname);
181 
188  bool IsReady();
189 
196  bool HasBeenReady();
197 
204  bool IsFull(size_t numclients, Client* client);
205 
217  void RemovePlayer(uint32_t clientnum,const char* reason);
218 
228  void MutePlayer(uint32_t clientnum,const char* reason);
229 
233  void UnmutePlayer(uint32_t clientnum,const char* reason);
234 
238  const char* GetMOTD()
239  {
240  return (const char*)motd.GetData();
241  }
242 
246  void SetMOTD(const char* str)
247  {
248  motd=str;
249  }
250 
257  {
258  return netmanager;
259  }
260 
267  {
268  return chatmanager;
269  }
270 
277  {
278  return advicemanager;
279  }
280 
287  {
288  return actionmanager;
289  }
290 
297  {
298  return npcmanager;
299  }
300 
307  {
308  return database;
309  }
310 
316  iConfigManager* GetConfig()
317  {
318  return configmanager;
319  }
320 
326  iObjectRegistry* GetObjectReg()
327  {
328  return objreg;
329  }
330 
337  {
338  return spawnmanager;
339  }
340 
347  {
348  return eventmanager;
349  }
350 
357  {
358  return weathermanager;
359  }
360 
367  {
368  return mathscriptengine;
369  }
370 
377  {
378  return adminmanager;
379  }
380 
388  {
389  return charmanager;
390  }
391 
398  {
399  return progression;
400  }
401 
406  {
407  return marriageManager;
408  }
409 
414  {
415  return exchangemanager;
416  }
417 
424  {
425  return combatmanager;
426  }
427 
435  {
436  return spellmanager;
437  }
438 
446  {
447  return workmanager;
448  }
449 
457  {
458  return guildmanager;
459  }
460 
468  {
469  return economymanager;
470  }
471 
479  {
480  return minigamemanager;
481  }
482 
490  {
491  return gmeventManager;
492  }
493 
500  {
501  return bankmanager;
502  }
503 
510  {
511  return hiremanager;
512  }
513 
520  {
521  return usermanager;
522  }
523 
530  {
531  return cachemanager;
532  }
533 
540  {
541  return intromanager;
542  }
543 
550  {
551  return songManager;
552  }
553 
560  {
561  return tutorialmanager;
562  }
563 
568  {
569  return authserver;
570  }
571 
578 
584  float GetRandom()
585  {
586  return rng->Get();
587  }
588 
594  float GetRandomRange(const float pos, const float range)
595  {
596  return (pos - range + GetRandom()*range*2);
597  }
598 
604  uint32 GetRandom(uint32 limit)
605  {
606  return rng->Get(limit);
607  }
608 
612  void SendSystemInfo(int clientnum, const char* fmt, ...);
613 
617  void SendSystemBaseInfo(int clientnum, const char* fmt, ...);
618 
622  void SendSystemResult(int clientnum,const char* fmt, ...);
623 
627  void SendSystemOK(int clientnum,const char* fmt, ...);
628 
632  void SendSystemError(int clientnum, const char* fmt, ...);
633 
635  {
636  return logcsv;
637  }
638 
642  void LoadLogSettings();
643 
647  void SaveLogSettings();
648 
660  bool AddBuddy(PID self, PID buddy);
661 
672  bool RemoveBuddy(PID self, PID buddy);
673 
692  void UpdateDialog(const char* area, const char* trigger,
693  const char* response, int num);
694 
707  void UpdateDialog(const char* area, const char* trigger,
708  const char* prohim, const char* proher,
709  const char* it, const char* them);
710 
719  iResultSet* GetAllTriggersInArea(csString data);
720 
734  iResultSet* GetSuperclientNPCs(int superclientID);
735 
743  bool GetServerOption(const char* option_name,csString &value);
744 
752  bool SetServerOption(const char* option_name,const csString &value);
753 
754  iResultSet* GetAllResponses(csString &trigger);
755 
765  bool CheckAccess(Client* client, const char* command, bool returnError=true);
766 
773  void QuitServer(int time, Client* client);
774 
779  {
780  return --unused_pid;
781  }
782 
786  {
787  return questmanager;
788  }
789 
790 
792 
796  csRandomGen* rng;
799  csRef<GuildManager> guildmanager;
800  csRef<QuestionManager> questionmanager;
801  csRef<GroupManager> groupmanager;
806  csRef<iVFS> vfs;
807 
808 protected:
809 
816  csRef<EventManager> eventmanager;
827  iObjectRegistry* objreg;
828  csRef<iConfigManager> configmanager;
829  csRef<ChatManager> chatmanager;
830  csRef<AdviceManager> advicemanager;
831  csRef<ActionManager> actionmanager;
832  csRef<AuthenticationServer> authserver;
834  bool MapLoaded;
835  csString motd;
839 
840  psQuitEvent* server_quit_event;
841 
846  uint32_t unused_pid;
847 };
848 
851 #endif
852 
853 
854 
IntroductionManager * intromanager
Definition: psserver.h:824
CombatManager * combatmanager
Definition: psserver.h:795
csString motd
Definition: psserver.h:835
TutorialManager * tutorialmanager
Definition: psserver.h:822
WorkManager * GetWorkManager()
Returns the work manager.
Definition: psserver.h:445
psDatabase * database
Definition: psserver.h:813
This class controls loading and saving Characters and Character specific data to and from an iDatabas...
WorkManager * workmanager
Definition: psserver.h:820
Manages CEL entities on the server.
Definition: entitymanager.h:77
iResultSet * GetAllTriggersInArea(csString data)
Gets all the triggers from a particular knowledge area.
Manager class that handles loading/searching/casting spells.
Definition: spellmanager.h:51
csRef< EventManager > eventmanager
Definition: psserver.h:816
bool Initialize(iObjectRegistry *objreg)
Initialize the server.
bool CheckAccess(Client *client, const char *command, bool returnError=true)
Check if a client is authorized to execute a command.
bool GetServerOption(const char *option_name, csString &value)
Check for options in table &#39;server_options&#39;.
bool MapLoaded
Definition: psserver.h:834
HireManager * hiremanager
Definition: psserver.h:838
AdminManager * GetAdminManager()
Returns the Administration Manager.
Definition: psserver.h:376
SpawnManager * spawnmanager
Definition: psserver.h:815
NetManager * GetNetManager()
Returns the server&#39;s network thread.
Definition: psserver.h:256
ProgressionManager * GetProgressionManager()
Returns the Progression Manager.
Definition: psserver.h:397
CombatManager * GetCombatManager()
Returns the Combat Manager.
Definition: psserver.h:423
Used to manage incoming user commands from a client.
Definition: usermanager.h:53
LogCSV * logcsv
Definition: psserver.h:833
psServer()
Default constructor.
void SendSystemError(int clientnum, const char *fmt,...)
Convenience command to send a client an error psSystemMessage.
SpellManager * GetSpellManager()
Returns the spell manager.
Definition: psserver.h:434
SpellManager * spellmanager
Definition: psserver.h:818
BankManager * bankmanager
Definition: psserver.h:837
static psCharacterLoader CharacterLoader
Definition: psserver.h:791
This manager catches events posted by the rest of the server and decides whether each client needs to...
csRef< GroupManager > groupmanager
Definition: psserver.h:801
bool LoadMap(const char *mapname)
Loads a map and changes the MapLoaded.
CacheManager * cachemanager
Definition: psserver.h:805
MiniGameManager * GetMiniGameManager()
Returns the minigame manager.
Definition: psserver.h:478
BankManager * GetBankManager()
Returns the Bank Manager.
Definition: psserver.h:499
ProgressionManager * progression
Definition: psserver.h:819
UserManager * usermanager
Definition: psserver.h:802
void MutePlayer(uint32_t clientnum, const char *reason)
Mutes a player from the world.
This class generates logs at a particular interval that has information that can be displayed later o...
Definition: serverstatus.h:64
AdminManager * adminmanager
Definition: psserver.h:812
The main server class.
Definition: psserver.h:102
void RemovePlayer(uint32_t clientnum, const char *reason)
Removes a player from the world.
Main PlayerGroup Manager that holds all the groups.
Definition: groupmanager.h:56
uint32_t unused_pid
Unused PID.
Definition: psserver.h:846
csRef< AuthenticationServer > authserver
Definition: psserver.h:832
iObjectRegistry * GetObjectReg()
Returns the object registry.
Definition: psserver.h:326
AdviceManager * GetAdviceManager()
Returns the Advice manager.
Definition: psserver.h:276
ServerConsole * serverconsole
Definition: psserver.h:810
void QuitServer(int time, Client *client)
Quits the server and sends informative messages.
bool SetServerOption(const char *option_name, const csString &value)
Set an option in table &#39;server_options&#39;.
Manages character details over the net.
Definition: psserverchar.h:58
bool HasBeenReady()
Checks to see if a world has loaded in the past.
QuestionManager keeps track of all the questions of any kind that are pending.
float GetRandom()
Returns a random number.
Definition: psserver.h:584
QuestManager * GetQuestManager()
Return the quest manager.
Definition: psserver.h:785
GuildManager * GetGuildManager()
Returns the guild manager.
Definition: psserver.h:456
csRef< QuestionManager > questionmanager
Definition: psserver.h:800
Definition: log.h:306
ExchangeManager * GetExchangeManager()
Returns the Exchange Manager.
Definition: psserver.h:413
bool AddBuddy(PID self, PID buddy)
Adds a buddy to this players list of buddies.
GameMaster Events manager class.
MiniGameManager * minigamemanager
Definition: psserver.h:823
AuthenticationServer * GetAuthServer()
Returns a pointer to the AuthenticationServer.
Definition: psserver.h:567
This class manages all marriage related stuff.
void SendSystemInfo(int clientnum, const char *fmt,...)
Convenience command to send a client a psSystemMessage.
Admin manager that handles GM commands and general game control.
Authentication handling.
Definition: authentserver.h:76
EconomyManager * economymanager
Definition: psserver.h:821
iObjectRegistry * objreg
Definition: psserver.h:827
csRef< ActionManager > actionmanager
Definition: psserver.h:831
psQuitEvent * server_quit_event
Used to keep track of the shut down event.
Definition: psserver.h:840
EventManager * GetEventManager()
Returns the event manager.
Definition: psserver.h:346
const char * GetMOTD()
Gets the MOTD string.
Definition: psserver.h:238
WeatherManager * GetWeatherManager()
Returns the Weather manager.
Definition: psserver.h:356
This class handles all calculations around combat, using statistics and information from the pspcchar...
Definition: combatmanager.h:55
void MainLoop()
Runs a script file to set up server and goes to the consoles main loop.
CacheManager * GetCacheManager()
Returns the Chace Manager.
Definition: psserver.h:529
bool RemoveBuddy(PID self, PID buddy)
Removes a buddy from this character&#39;s list of buddies.
iConfigManager * GetConfig()
Returns the configuration manager.
Definition: psserver.h:316
iResultSet * GetSuperclientNPCs(int superclientID)
Return a list of NPCs (with their info) managed by a particular superclient.
void SaveLogSettings()
Used to save the log settings.
csRef< GuildManager > guildmanager
Definition: psserver.h:799
IntroductionManager * GetIntroductionManager()
Returns the Introduction Manager.
Definition: psserver.h:539
SpawnManager * GetSpawnManager()
Returns the spawn manager.
Definition: psserver.h:336
void SetMOTD(const char *str)
Sets the MOTD string.
Definition: psserver.h:246
CharCreationManager * charCreationManager
Definition: psserver.h:798
MathScriptEngine * GetMathScriptEngine()
Returns the Math Scripting Engine.
Definition: psserver.h:366
ClientConnectionSet * GetConnections()
Gets a list of all connected clients.
ExchangeManager * exchangemanager
Definition: psserver.h:803
ServerCharManager * GetCharManager()
Returns the character manager.
Definition: psserver.h:387
psMarriageManager * GetMarriageManager()
Returns the Marriage Manager.
Definition: psserver.h:405
ServerCharManager * charmanager
Definition: psserver.h:814
This class collects data of a netclient.
Definition: client.h:95
QuestManager * questmanager
Definition: psserver.h:797
MathScriptEngine * mathscriptengine
Definition: psserver.h:826
csRef< iVFS > vfs
Definition: psserver.h:806
void SendSystemBaseInfo(int clientnum, const char *fmt,...)
Similar to SendSystemInfo(), but the message is shown also on the "Main" tab.
psDatabase * GetDatabase()
Returns the database manager.
Definition: psserver.h:306
This class is implements the user input and output console for the server.
Definition: serverconsole.h:67
The Hire Manager will manage all aspects related to hiring of NPCs.
Definition: hiremanager.h:49
This class is the client&#39;s and server&#39;s main interface for either sending network messages out or get...
Definition: msghandler.h:106
This class takes care of played songs and players&#39; ranking for musical instruments skills...
Handles the map interaction system.
NPCManager * npcmanager
Definition: psserver.h:793
This is the network thread handling packets sending/receiving to/from network other threads can regis...
Definition: netmanager.h:49
HireManager * GetHireManager()
Returns the Hire Manager.
Definition: psserver.h:509
Server manager for character creation.
bool IsMapLoaded()
Checks to see if a world is loaded.
Definition: psserver.h:169
psMarriageManager * marriageManager
Definition: psserver.h:794
This class manages the caching of data that is unchanging during server operation.
Definition: cachemanager.h:234
csRef< ChatManager > chatmanager
Definition: psserver.h:829
csRandomGen * rng
Definition: psserver.h:796
csRef< AdviceManager > advicemanager
Definition: psserver.h:830
TutorialManager * GetTutorialManager()
Returns the Tutorial Manager.
Definition: psserver.h:559
ActionManager * GetActionManager()
Returns the Advice manager.
Definition: psserver.h:286
void SendSystemOK(int clientnum, const char *fmt,...)
Convenience command to send a client a psSystemMessage with the MSG_OK type.
bool IsFull(size_t numclients, Client *client)
Checks if the server is full.
AdviceManager keeps track of all the invitations of any kind that are pending, using a collection of ...
Definition: advicemanager.h:77
This class handles generation of any and all weather events in the game, including rain...
void SendSystemResult(int clientnum, const char *fmt,...)
Convenience command to send a client a psSystemMessage with the MSG_RESULT type.
Handles minigame sessions.
ChatManager * GetChatManager()
Returns the Chat manager.
Definition: psserver.h:266
This class handles all calculations around work, using statistics and information from the pspccharac...
Definition: workmanager.h:159
This class is a list of several CLient objects, it&#39;s designed for finding clients very fast based on ...
Definition: clients.h:58
This holds all the formulas loaded from the MathScript table and provides a container for them...
Definition: mathscript.h:51
csRef< iConfigManager > configmanager
Definition: psserver.h:828
LogCSV * GetLogCSV()
Definition: psserver.h:634
This class handles quest management for the player, tracking who has what quests assigned, etc.
Definition: questmanager.h:52
uint32 GetRandom(uint32 limit)
Returns a random number with a limit.
Definition: psserver.h:604
NetManager * netmanager
Definition: psserver.h:811
GMEventManager * GetGMEventManager()
Returns the GM Event Manager.
Definition: psserver.h:489
PID GetUnusedPID()
Return a unused PID for temporary usage.
Definition: psserver.h:778
iResultSet * GetAllResponses(csString &trigger)
void UnmutePlayer(uint32_t clientnum, const char *reason)
Unmutes player.
GMEventManager * gmeventManager
Definition: psserver.h:836
ServerSongManager * GetSongManager()
Returns the Song Manager.
Definition: psserver.h:549
~psServer()
Destructor.
void UpdateDialog(const char *area, const char *trigger, const char *response, int num)
Change the dialog responses for that trigger in the area.
WeatherManager * weathermanager
Definition: psserver.h:817
EconomyManager * GetEconomyManager()
Returns the economy manager.
Definition: psserver.h:467
This class handles all queueing and invoking of timed events, such as combat, spells, NPC dialog responses, range weapons, or NPC respawning.
Definition: eventmanager.h:40
EntityManager * entitymanager
Definition: psserver.h:804
float GetRandomRange(const float pos, const float range)
Returns a random position within a range.
Definition: psserver.h:594
ServerSongManager * songManager
Definition: psserver.h:825
UserManager * GetUserManager()
Returns the User Manager.
Definition: psserver.h:519
NPCManager * GetNPCManager()
Returns the NPC Superclient manager.
Definition: psserver.h:296
This class is periodically called by the engine to ensure that monsters (and other NPCs) are respawne...
Definition: spawnmanager.h:283
bool IsReady()
Checks to see if a world is loaded ready to go.
void LoadLogSettings()
Used to load the log settings.