# cMasterServer Class Reference

List of all members.

## Static Public Member Functions

static void | WriteToFile (char *szMessage)
static void | Load ()
static BOOL | Unload ()
static void | StartThread ()
static void | StopThread (DWORD dwTimeOut)
static DWORD WINAPI | ServerThread (LPVOID lpVoid)
static void | ParseCommand (char *szCommand, WORD wSize, cClient *pcClient)
static void | LoadAvatar (cClient *pcClient)
static void | CreateNewAvatar (cAvatar **ppcAvatar, DWORD dwGUID)
static void | SendLoginData (cClient *pcClient)
static void | CreateInventory (cClient *pcClient)
static void | ServerMessage (DWORD dwColor, cClient *pcClient, char *szMessage,...)
static void | SendTell (char *szMessage, cClient *pcDestination, cClient *pcOrigin)
static void CALLBACK | ScavengeIdleSockets (HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
static void CALLBACK | Status_Update (HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
static BOOL | DisconnectClient (cClient *pcClient)
static BOOL | Corpse (cClient *pcClient)
static BOOL | DisconnectAllClients ()
static void | LoadMonsterModels ()
static void | LoadItemModels ()
static void | LoadWorldModels ()
static void | LoadMonsters ()
static void | LoadGroundSpawns ()
static void | LoadSpellModels ()
static void | LoadSpells ()
static void | LoadSpellComps ()
static void | LoadNPCs ()
static void | LoadAltars ()
static void | LoadCovenants ()
static void | LoadHousing ()
static void | LoadHooks ()
static void | LoadStorage ()
static void | LoadDoors ()
static void | LoadChests ()
static void | LoadLifestones ()
static void | LoadPortals ()
static void | LoadWorldObjects ()
static void | LoadWorldObjects2 ()
static void | LoadNPCModels ()
static void | LoadItem (cObject *pcItem)
static void | LoadSpawns (WORD LB)
static bool | SpawnMonster (char *szMonster, cLocation pcLoc, DWORD Respawn=0)
static bool | SpawnType (char *szMonster, cLocation pcLoc, DWORD dwModelNumber, DWORD dwExp_Value, DWORD dwHealth, DWORD dwStamina, DWORD dwMana)
static bool | SpawnSave (char *szMonster, cLocation pcLoc, bool bFacing, bool bOverride, DWORD Respawn, DWORD Decay, DWORD Chase, DWORD Influence)
static BOOL | FindHeaderInFile (FILE *fin, char *header)
static void | FixSpaces (char *str)
static void | FixName (char *str)
static void | LoadStartingLocation ()
static void | LoadTeleTownList ()
static void | LoadAllegiances ()
static void | ClearAllObjects ()
static BOOL | PKLite (cClient *pcClient, bool bState)
static void | FormatIP (SOCKADDR_IN &saSockAddr, char *szStore)
static void | FormatIP_Port (SOCKADDR_IN &saSockAddr, char *szStore)
static DWORD | NewFellowID ()

## Static Public Attributes

static CStatus * | cStatus = 0
static CorpseCleaner * | m_pcCorpse = 0
static SimpleAI * | m_pcSimpleAI = 0
static cJobPool * | m_pcJobPool = 0
static char | m_szServerName [64] = { ' ', }
static DWORD | m_dwNumUsers = 0
static DWORD | m_UserCount = 0
static std::list< cEnchantment * > | m_lstEnchantments
static std::vector< cTeleTownList > | m_TeleTownList
static std::vector< cAllegiance * > | m_AllegianceList
static std::vector< cFellowship * > | m_FellowshipList
static cLocation | m_HoltburgWest
static cLocation | m_HoltburgSouth
static cLocation | m_ShoushiSE
static cLocation | m_ShoushiWest
static cLocation | m_YaraqNorth
static cLocation | m_YaraqEast
static cLocation | m_LSHoltburgWest
static cLocation | m_LSHoltburgSouth
static cLocation | m_LSShoushiSE
static cLocation | m_LSShoushiWest
static cLocation | m_LSYaraqNorth
static cLocation | m_LSYaraqEast

## Static Protected Attributes

static DWORD | m_dwFellowID = 0

## Friends

class | cClient
class | cCommandParser
class | cAltar
class | cCovenant
class | cDatabase
class | cFellowship
class | cHouse
class | cMonsterServer

## Member Function Documentation

void cMasterServer::ClearAllObjects | ( |  | ) | `[static]`

Clears all spawned objects.

BOOL cMasterServer::Corpse | ( | cClient * | pcClient | ) | `[static]`

Creates a corpse upon user's death.

Parameters:

  | *pcClient | - A pointer to the client creating the corpse.

Author: G70mb2

void cMasterServer::CreateInventory | ( | cClient * | pcClient | ) | `[static]`

Initalizes an avatar's inventory by loading each item from the database.

This function should be called before the avatar's Create Message is formed. The information loaded here is used in the Create Message.

Parameters:

  | *pcClient | - A pointer to the client whose avatar's inventory is to be loaded.

void cMasterServer::CreateNewAvatar | ( | cAvatar ** | ppcAvatar,
|  | DWORD | dwGUID |
| ) |  |  | `[static]`

Obtains the avatar's information from the database and creates the client's avatar.

This function is called whenever a client logs in an avatar.

Note: Placeholder code until database code is done.

Parameters:

  | **ppcAvatar | - A pointer to the pointer to avatar to be created.
  | dwGUID | - The GUID of the avatar.

BOOL cMasterServer::DisconnectAllClients | ( |  | ) | `[static]`

Removes all clients in preparation for server shutdown.

BOOL cMasterServer::DisconnectClient | ( | cClient * | pcClient | ) | `[static]`

Removes a client after logout or loss of signal.

Parameters:

  | *pcClient | - A pointer to the client to be disconnected.

void cMasterServer::FixName | ( | char * | str | ) | `[static]`

Converts * into a ' (apostrophe).

void cMasterServer::FixSpaces | ( | char * | str | ) | `[static]`

Converts '_' into a space character.

void cMasterServer::Load | ( |  | ) | `[static]`

Loads the server process. Calls cMasterServer::StartThread( ).

This member function is called when the server is started.

void cMasterServer::LoadAllegiances | ( |  | ) | `[static]`

Loads currently existing allegiances from the database.

This data is updated as allegiances are altered in-game. The data is used to populate allegiance information sent to clients.

void cMasterServer::LoadAltars | ( |  | ) | `[static]`

Loads altars from the database.

Author: G70mb2

void cMasterServer::LoadChests | ( |  | ) | `[static]`

Loads chests from the database.

Author: Cubem0j0

void cMasterServer::LoadCovenants | ( |  | ) | `[static]`

Loads covenant crystals from the database.

Author: G70mb2

void cMasterServer::LoadDoors | ( |  | ) | `[static]`

Loads doors from the database.

Author: G70mb2

void cMasterServer::LoadGroundSpawns | ( |  | ) | `[static]`

Loads ground spawns from the database

Note: Use ModelNumber to reference pre-loaded model data.

Author: Cubem0j0

void cMasterServer::LoadHooks | ( |  | ) | `[static]`

Loads housing hooks from the database.

void cMasterServer::LoadHousing | ( |  | ) | `[static]`

Loads housing objects from database.

Author: G70mb2

void cMasterServer::LoadItem | ( | cObject * | pcItem | ) | `[static]`

Loads the data for the specific item.

This member function initializes the model information for the given item.

Parameters:

  | *pcItem | - A pointer to the item to load.

void cMasterServer::LoadItemModels | ( |  | ) | `[static]`

Loads predefined item models from the database.

An item model comprises the general characteristics of a given item.

Note: Used for items.

TODO: Load from the 0x10000000 entries in the portal.dat instead.

Author: Cubem0j0

void cMasterServer::LoadLifestones | ( |  | ) | `[static]`

Loads lifestones from the database.

Author: G70mb2

void cMasterServer::LoadMonsterModels | ( |  | ) | `[static]`

Loads pre-defined monster models from the database.

Note: Primarily used for monsters, since there are several copies of the same data. One model needs to be loaded for each creature, which may then be referenced by the Model Number as needed.

TODO: Load monster models from the portal.dat instead.

Author: G70mb2

void cMasterServer::LoadMonsters | ( |  | ) | `[static]`

Loads monsters from the database.

Note: Use ModelNumber to reference pre-loaded model data. This should become obsolete once spawn control is developed Spawn Generators will then be loaded instead of individual monsters, which will then spawn as needed.

Cube: Changing this: We will pull monsters for dungeons only from the monster table. This makes more sense, as dungeons are static spawns.

Author: G70mb2

void cMasterServer::LoadNPCModels | ( |  | ) | `[static]`

Loads pre-defined non-player character (NPC) models from the database.

Note: Used to speed up the loading of NPCs.

Author: G70mb2

void cMasterServer::LoadNPCs | ( |  | ) | `[static]`

Loads non-player characters (NPCs) from the database.

Author: G70mb2

void cMasterServer::LoadPortals | ( |  | ) | `[static]`

Loads portals from the database.

Author: G70mb2

void cMasterServer::LoadSpawns | ( | WORD | LB | ) | `[static]`

Loads monster spawn points from the database.

Author: G70mb2

void cMasterServer::LoadSpellComps | ( |  | ) | `[static]`

Loads magic components from the database.

This member function loads each spell component's characteristics from the database.

TODO: Load from the 0x0E00000F table in the portal.dat instead.

void cMasterServer::LoadSpellModels | ( |  | ) | `[static]`

Loads pre-defined magic models from database.

Author: G70mb2

void cMasterServer::LoadSpells | ( |  | ) | `[static]`

Loads magic from the database.

This member function loads each spell's characteristics from the database.

TODO: Load from the 0x0E00000E table in the portal.dat instead.

void cMasterServer::LoadStartingLocation | ( |  | ) | `[static]`

Obtains the default starting location from the database.

Author: G70mb2

void cMasterServer::LoadStorage | ( |  | ) | `[static]`

Loads housing storage chests from the database.

void cMasterServer::LoadTeleTownList | ( |  | ) | `[static]`

Obtains the locations used by the TeleTown command from the database.

void cMasterServer::LoadWorldModels | ( |  | ) | `[static]`

Loads pre-defined world object models from the database.

A world object model comprises the general characteristics of a world object item.

Author: Cubem0j0

void cMasterServer::LoadWorldObjects | ( |  | ) | `[static]`

Loads world objects from the database.

Author: Cubem0j0

void cMasterServer::LoadWorldObjects2 | ( |  | ) | `[static]`

Loads merchant signs from the database.

Author: Cubem0j0

void cMasterServer::ParseCommand | ( | char * | szCommand,
|  | WORD | wSize,
|  | cClient * | pcClient |
| ) |  |  | `[static]`

Parses commands from users and executes them.

Used for server-specific commands. Executes the proper cCommandParser function based upon the command.

Parameters:

  | *szCommand | - A pointer to the text that comprises the command.
  | wSize | - The length of the command (excluding the terminating character ('')
  | *pcClient | - A pointer to the client that should receive the data.

BOOL cMasterServer::PKLite | ( | cClient * | pcClient,
|  | bool | bState |
| ) |  |  | `[static]`

Changes a Client's PKLite status.

Parameters:

  | *pcClient | - A pointer to the client whose PKLite status is to be changed.
  | bState | - A boolean representation of whether the client is PKLite.

VOID CALLBACK cMasterServer::ScavengeIdleSockets | ( | HWND | hwnd,
|  | UINT | uMsg,
|  | UINT | idEvent,
|  | DWORD | dwTime |
| ) |  |  | `[static]`

Searches for and disconnects inactive clients.

void cMasterServer::SendLoginData | ( | cClient * | pcClient | ) | `[static]`

Obtains the data necessary from the database for login and sends it to the client.

This function is called whenever a client logs in an avatar. It is called after the database contents for the avatar have been loaded into memory.

Note: Placeholder code until database code is done.

Parameters:

  | *pcClient | - A pointer to the client that should receive the data.

void cMasterServer::SendTell | ( | char * | szMessage,
|  | cClient * | pcDestination,
|  | cClient * | pcOrigin |
| ) |  |  | `[static]`

Encapsulates functionality to send a private message to another user

This function is called whenever a client sends a "tell" to another client.

Parameters:

  | *szCommand | - A pointer to the text that comprises the command.
  | *pcDestination | - A pointer to the client that should receive the tell.
  | *pcOrigin | - A pointer to the client sending the the tell.

void cMasterServer::ServerMessage | ( | DWORD | dwColor,
|  | cClient * | pcClient,
|  | char * | szMessage,
|  |  | ... |
| ) |  |  | `[static]`

Sends a server message to the client.

Parameters:

  | dwColor | - The color in which the server message will be displayed.
  | *pcClient | - A pointer to the client who should receieve the message.
  | *szMessage | - A pointer to the text to be sent as the message.

DWORD WINAPI cMasterServer::ServerThread | ( | LPVOID | lpVoid | ) | `[static]`

The thread loop that checks for new packets and passes them on to the correct server.

bool cMasterServer::SpawnMonster | ( | char * | szMonster,
|  | cLocation | pcLoc,
|  | DWORD | Respawn = `0` |
| ) |  |  | `[static]`

Spawns a monster from database by name.

Note: Use ModelNumber to reference pre-loaded model data. This should become obsolete once spawn control is developed Spawn Generators will then be loaded instead of individual monsters, which will then spawn as needed.

Parameters:

  | *szMonster | - A pointer to the text representing the monster's name.
  | pcLoc | - A cLocation struct describing the avatar's present location.
  | Respawn | - A value describing whether the monster should be respawned (0 = No, 1 = Yes).

Author: G70mb2

bool cMasterServer::SpawnSave | ( | char * | szMonster,
|  | cLocation | pcLoc,
|  | bool | bFacing,
|  | bool | bOverride,
|  | DWORD | Respawn,
|  | DWORD | Decay,
|  | DWORD | Chase,
|  | DWORD | Influence |
| ) |  |  | `[static]`

Spawns a monster from the database and saves a copy into the auto-load database.

Parameters:

  | *szMonster | - A pointer to the text representing the monster's name.
  | pcLoc | - A cLocation struct describing the avatar's present location.
  | bFacing | - A boolean value for whether the monster should be facing the avatar.
  | bOverride | - A boolean value for whether the monster's default respawn, decay, and influence values should be overwriten.
  | Decay | -
  | Chase | -
  | Influence | -

Author: G70mb2

bool cMasterServer::SpawnType | ( | char * | szMonster,
|  | cLocation | pcLoc,
|  | DWORD | dwModelNumber,
|  | DWORD | dwExp_Value,
|  | DWORD | dwHealth,
|  | DWORD | dwStamina,
|  | DWORD | dwMana |
| ) |  |  | `[static]`

Spawn monster from the database by modelID only.

Parameters:

  | *szMonster | - A pointer to the text representing the monster's name.
  | pcLoc | - A cLocation struct describing the avatar's present location.
  | dwModelNumber | - The model number of the monster to be spawned.
  | dwExp_Value | - The experience value of the monster to be spawned.
  | dwHealth | - The Health of the monster to be spawned.
  | dwStamina | - The Stamina of the monster to be spawned.
  | dwMana | - The Mana of the monster to be spawned.

Author: G70mb2

void cMasterServer::StartThread | ( |  | ) | `[static]`

Starts the MasterServer thread.

This member function is called when the MasterServer thread is to be started.

VOID CALLBACK cMasterServer::Status_Update | ( | HWND | hwnd,
|  | UINT | uMsg,
|  | UINT | idEvent,
|  | DWORD | dwTime |
| ) |  |  | `[static]`

Updates the Master Server.

Author: G70mb2

void cMasterServer::StopThread | ( | DWORD | dwTimeOut | ) | `[static]`

Cleans up and closes the MasterServer thread.

This member function is called when the MasterServer thread is to be stopped.

BOOL cMasterServer::Unload | ( |  | ) | `[static]`

Unloads the server process. Calls cMasterServer::StopThread( ).

This member function is called when the server is stopped.

The documentation for this class was generated from the following files:

- E:/uas2/Server/MasterServer.h
- E:/uas2/Server/MasterServer.cpp