[Server] Document script functions, part 3

Also reorder functions in Cells and CharClass so they are consistent with the rest.
0.6.1
David Cernat 8 years ago
parent 3d1458b5a2
commit 8b79cdd4f4

@ -75,73 +75,487 @@ class ActorFunctions
{
public:
/**
* \brief Use the last actor list received by the server as the one being read.
*
* \return void
*/
static void ReadLastActorList() noexcept;
/**
* \brief Use the temporary actor list stored for a cell as the one being read.
*
* This type of actor list is used to store actor positions and dynamic stats and is deleted
* when the cell is unloaded.
*
* \param cellDescription The description of the cell whose actor list should be read.
* \return void
*/
static void ReadCellActorList(const char* cellDescription) noexcept;
/**
* \brief Clear the data from the last actor list sent by the server.
*
* This is used to initialize the sending of new Actor packets.
*
* \param pid The player ID to whom the actor list should be attached.
* \return void
*/
static void InitializeActorList(unsigned short pid) noexcept;
/**
* \brief Get the number of indexes in the read actor list.
*
* \return The number of indexes.
*/
static unsigned int GetActorListSize() noexcept;
/**
* \brief Get the action type used in the read actor list.
*
* \return The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST).
*/
static unsigned char GetActorListAction() noexcept;
/**
* \brief Get the cell description of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The cell description.
*/
static const char *GetActorCell(unsigned int i) noexcept;
/**
* \brief Get the refId of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The refId.
*/
static const char *GetActorRefId(unsigned int i) noexcept;
/**
* \brief Get the refNumIndex of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The refNumIndex.
*/
static int GetActorRefNumIndex(unsigned int i) noexcept;
/**
* \brief Get the mpNum of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The mpNum.
*/
static int GetActorMpNum(unsigned int i) noexcept;
/**
* \brief Get the X position of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The X position.
*/
static double GetActorPosX(unsigned int i) noexcept;
/**
* \brief Get the Y position of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The Y position.
*/
static double GetActorPosY(unsigned int i) noexcept;
/**
* \brief Get the Z position of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The Z position.
*/
static double GetActorPosZ(unsigned int i) noexcept;
/**
* \brief Get the X rotation of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The X rotation.
*/
static double GetActorRotX(unsigned int i) noexcept;
/**
* \brief Get the Y rotation of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The Y rotation.
*/
static double GetActorRotY(unsigned int i) noexcept;
/**
* \brief Get the Z rotation of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The Z rotation.
*/
static double GetActorRotZ(unsigned int i) noexcept;
/**
* \brief Get the base health of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The base health.
*/
static double GetActorHealthBase(unsigned int i) noexcept;
/**
* \brief Get the current health of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The current health.
*/
static double GetActorHealthCurrent(unsigned int i) noexcept;
/**
* \brief Get the modified health of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The modified health.
*/
static double GetActorHealthModified(unsigned int i) noexcept;
/**
* \brief Get the base magicka of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The base magicka.
*/
static double GetActorMagickaBase(unsigned int i) noexcept;
/**
* \brief Get the current magicka of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The current magicka.
*/
static double GetActorMagickaCurrent(unsigned int i) noexcept;
/**
* \brief Get the modified magicka of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The modified magicka.
*/
static double GetActorMagickaModified(unsigned int i) noexcept;
/**
* \brief Get the base fatigue of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The base fatigue.
*/
static double GetActorFatigueBase(unsigned int i) noexcept;
/**
* \brief Get the current fatigue of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The current fatigue.
*/
static double GetActorFatigueCurrent(unsigned int i) noexcept;
/**
* \brief Get the modified fatigue of the actor at a certain index in the read actor list.
*
* \param i The index of the actor.
* \return The modified fatigue.
*/
static double GetActorFatigueModified(unsigned int i) noexcept;
/**
* \brief Get the refId of the item in a certain slot of the equipment of the actor at a
* certain index in the read actor list.
*
* \param i The index of the actor.
* \param slot The slot of the equipment item.
* \return The refId.
*/
static const char *GetActorEquipmentItemRefId(unsigned int i, unsigned short slot) noexcept;
/**
* \brief Get the count of the item in a certain slot of the equipment of the actor at a
* certain index in the read actor list.
*
* \param i The index of the actor.
* \param slot The slot of the equipment item.
* \return The item count.
*/
static int GetActorEquipmentItemCount(unsigned int i, unsigned short slot) noexcept;
/**
* \brief Get the charge of the item in a certain slot of the equipment of the actor at a
* certain index in the read actor list.
*
* \param i The index of the actor.
* \param slot The slot of the equipment item.
* \return The charge.
*/
static int GetActorEquipmentItemCharge(unsigned int i, unsigned short slot) noexcept;
/**
* \brief Check whether there is any positional data for the actor at a certain index in
* the read actor list.
*
* This is only useful when reading the actor list data recorded for a particular cell.
*
* \param i The index of the actor.
* \return Whether the read actor list contains positional data.
*/
static bool DoesActorHavePosition(unsigned int i) noexcept;
/**
* \brief Check whether there is any dynamic stats data for the actor at a certain index in
* the read actor list.
*
* This is only useful when reading the actor list data recorded for a particular cell.
*
* \param i The index of the actor.
* \return Whether the read actor list contains dynamic stats data.
*/
static bool DoesActorHaveStatsDynamic(unsigned int i) noexcept;
/**
* \brief Set the cell of the temporary actor list stored on the server.
*
* The cell is determined to be an exterior cell if it fits the pattern of a number followed
* by a comma followed by another number.
*
* \param cellDescription The description of the cell.
* \return void
*/
static void SetActorListCell(const char* cellDescription) noexcept;
/**
* \brief Set the action type of the temporary actor list stored on the server.
*
* \param action The action type (0 for SET, 1 for ADD, 2 for REMOVE, 3 for REQUEST).
* \return void
*/
static void SetActorListAction(unsigned char action) noexcept;
/**
* \brief Set the cell of the temporary actor stored on the server.
*
* Used for ActorCellChange packets, where a specific actor's cell now differs from that of the
* actor list.
*
* The cell is determined to be an exterior cell if it fits the pattern of a number followed
* by a comma followed by another number.
*
* \param cellDescription The description of the cell.
* \return void
*/
static void SetActorCell(const char* cellDescription) noexcept;
/**
* \brief Set the refId of the temporary actor stored on the server.
*
* \param refId The refId.
* \return void
*/
static void SetActorRefId(const char* refId) noexcept;
/**
* \brief Set the refNumIndex of the temporary actor stored on the server.
*
* \param refNumIndex The refNumIndex.
* \return void
*/
static void SetActorRefNumIndex(int refNumIndex) noexcept;
/**
* \brief Set the mpNum of the temporary actor stored on the server.
*
* \param mpNum The mpNum.
* \return void
*/
static void SetActorMpNum(int mpNum) noexcept;
/**
* \brief Set the position of the temporary actor stored on the server.
*
* \param x The X position.
* \param y The Y position.
* \param z The Z position.
* \return void
*/
static void SetActorPosition(double x, double y, double z) noexcept;
/**
* \brief Set the rotation of the temporary actor stored on the server.
*
* \param x The X rotation.
* \param y The Y rotation.
* \param z The Z rotation.
* \return void
*/
static void SetActorRotation(double x, double y, double z) noexcept;
/**
* \brief Set the base health of the temporary actor stored on the server.
*
* \param value The new value.
* \return void
*/
static void SetActorHealthBase(double value) noexcept;
/**
* \brief Set the current health of the temporary actor stored on the server.
*
* \param value The new value.
* \return void
*/
static void SetActorHealthCurrent(double value) noexcept;
/**
* \brief Set the modified health of the temporary actor stored on the server.
*
* \param value The new value.
* \return void
*/
static void SetActorHealthModified(double value) noexcept;
/**
* \brief Set the base magicka of the temporary actor stored on the server.
*
* \param value The new value.
* \return void
*/
static void SetActorMagickaBase(double value) noexcept;
/**
* \brief Set the current magicka of the temporary actor stored on the server.
*
* \param value The new value.
* \return void
*/
static void SetActorMagickaCurrent(double value) noexcept;
/**
* \brief Set the modified magicka of the temporary actor stored on the server.
*
* \param value The new value.
* \return void
*/
static void SetActorMagickaModified(double value) noexcept;
/**
* \brief Set the base fatigue of the temporary actor stored on the server.
*
* \param value The new value.
* \return void
*/
static void SetActorFatigueBase(double value) noexcept;
/**
* \brief Set the current fatigue of the temporary actor stored on the server.
*
* \param value The new value.
* \return void
*/
static void SetActorFatigueCurrent(double value) noexcept;
/**
* \brief Set the modified fatigue of the temporary actor stored on the server.
*
* \param value The new value.
* \return void
*/
static void SetActorFatigueModified(double value) noexcept;
/**
* \brief Equip an item in a certain slot of the equipment of the temporary actor stored
* on the server.
*
* \param slot The equipment slot.
* \param refId The refId of the item.
* \param count The count of the item.
* \param charge The charge of the item.
* \return void
*/
static void EquipActorItem(unsigned short slot, const char* refId, unsigned int count, int charge) noexcept;
/**
* \brief Unequip the item in a certain slot of the equipment of the temporary actor stored
* on the server.
*
* \param slot The equipment slot.
* \return void
*/
static void UnequipActorItem(unsigned short slot) noexcept;
/**
* \brief Add a copy of the server's temporary actor to the server's temporary actor list.
*
* In the process, the server's temporary actor will automatically be cleared so a new
* one can be set up.
*
* \return void
*/
static void AddActor() noexcept;
/**
* \brief Send an ActorList packet.
*
* It is sent only to the player for whom the current actor list was initialized.
*
* \return void
*/
static void SendActorList() noexcept;
/**
* \brief Send an ActorAuthority packet.
*
* The player for whom the current actor list was initialized is recorded in the server memory
* as the new actor authority for the actor list's cell.
*
* The packet is sent to that player as well as all other players who have the cell loaded.
*
* \return void
*/
static void SendActorAuthority() noexcept;
/**
* \brief Send an ActorPosition packet.
*
* It is sent only to the player for whom the current actor list was initialized.
*
* \return void
*/
static void SendActorPosition() noexcept;
/**
* \brief Send an ActorStatsDynamic packet.
*
* It is sent only to the player for whom the current actor list was initialized.
*
* \return void
*/
static void SendActorStatsDynamic() noexcept;
/**
* \brief Send an ActorEquipment packet.
*
* It is sent only to the player for whom the current actor list was initialized.
*
* \return void
*/
static void SendActorEquipment() noexcept;
/**
* \brief Send an ActorCellChange packet.
*
* It is sent only to the player for whom the current actor list was initialized.
*
* \return void
*/
static void SendActorCellChange() noexcept;
};

@ -55,45 +55,17 @@ const char *CellFunctions::GetCell(unsigned short pid) noexcept
return tempCellDescription.c_str();
}
void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Script is moving %s from %s to %s", player->npc.mName.c_str(),
player->cell.getDescription().c_str(), cellDescription);
player->cell = Utils::getCellFromDescription(cellDescription);
}
void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Script is moving %s from %s to %i,%i", player->npc.mName.c_str(),
player->cell.getDescription().c_str(), x, y);
// If the player is currently in an interior, turn off the interior flag
// from the cell
if (!player->cell.isExterior())
player->cell.mData.mFlags &= ~ESM::Cell::Interior;
player->cell.mData.mX = x;
player->cell.mData.mY = y;
}
int CellFunctions::GetExteriorX(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,0);
GET_PLAYER(pid, player, 0);
return player->cell.mData.mX;
}
int CellFunctions::GetExteriorY(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,0);
GET_PLAYER(pid, player, 0);
return player->cell.mData.mY;
}
@ -121,6 +93,34 @@ bool CellFunctions::IsChangingRegion(unsigned short pid) noexcept
return player->isChangingRegion;
}
void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Script is moving %s from %s to %s", player->npc.mName.c_str(),
player->cell.getDescription().c_str(), cellDescription);
player->cell = Utils::getCellFromDescription(cellDescription);
}
void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Script is moving %s from %s to %i,%i", player->npc.mName.c_str(),
player->cell.getDescription().c_str(), x, y);
// If the player is currently in an interior, turn off the interior flag
// from the cell
if (!player->cell.isExterior())
player->cell.mData.mFlags &= ~ESM::Cell::Interior;
player->cell.mData.mX = x;
player->cell.mData.mY = y;
}
void CellFunctions::AddCellExplored(unsigned short pid, const char* cellDescription) noexcept
{
Player *player;

@ -12,8 +12,6 @@
{"GetCellStateDescription", CellFunctions::GetCellStateDescription},\
\
{"GetCell", CellFunctions::GetCell},\
{"SetCell", CellFunctions::SetCell},\
{"SetExteriorCell", CellFunctions::SetExteriorCell},\
{"GetExteriorX", CellFunctions::GetExteriorX},\
{"GetExteriorY", CellFunctions::GetExteriorY},\
{"IsInExterior", CellFunctions::IsInExterior},\
@ -21,6 +19,9 @@
{"GetRegion", CellFunctions::GetRegion},\
{"IsChangingRegion", CellFunctions::IsChangingRegion},\
\
{"SetCell", CellFunctions::SetCell},\
{"SetExteriorCell", CellFunctions::SetExteriorCell},\
\
{"AddCellExplored", CellFunctions::AddCellExplored},\
\
{"SendCell", CellFunctions::SendCell},\
@ -31,26 +32,147 @@ class CellFunctions
{
public:
/**
* \brief Clear the last recorded map changes for a player.
*
* This is used to initialize the sending of new PlayerMap packets.
*
* \param pid The player ID whose map changes should be used.
* \return void
*/
static void InitializeMapChanges(unsigned short pid) noexcept;
/**
* \brief Get the number of indexes in a player's latest cell state changes.
*
* \param pid The player ID whose cell state changes should be used.
* \return The number of indexes.
*/
static unsigned int GetCellStateChangesSize(unsigned short pid) noexcept;
/**
* \brief Get the cell state type at a certain index in a player's latest cell state changes.
*
* \param pid The player ID whose cell state changes should be used.
* \param i The index of the cell state.
* \return The cell state type (0 for LOAD, 1 for UNLOAD).
*/
static unsigned int GetCellStateType(unsigned short pid, unsigned int i) noexcept;
/**
* \brief Get the cell description at a certain index in a player's latest cell state changes.
*
* \param pid The player ID whose cell state changes should be used.
* \param i The index of the cell state.
* \return The cell description.
*/
static const char *GetCellStateDescription(unsigned short pid, unsigned int i) noexcept;
/**
* \brief Get the cell description of a player's cell.
*
* \param pid The player ID.
* \return The cell description.
*/
static const char *GetCell(unsigned short pid) noexcept;
static void SetCell(unsigned short pid, const char *cellDescription) noexcept;
static void SetExteriorCell(unsigned short pid, int x, int y) noexcept;
/**
* \brief Get the X coordinate of the player's exterior cell.
*
* \param pid The player ID.
* \return The X coordinate of the cell.
*/
static int GetExteriorX(unsigned short pid) noexcept;
/**
* \brief Get the Y coordinate of the player's exterior cell.
*
* \param pid The player ID.
* \return The Y coordinate of the cell.
*/
static int GetExteriorY(unsigned short pid) noexcept;
/**
* \brief Check whether the player is in an exterior cell or not.
*
* \param pid The player ID.
* \return Whether the player is in an exterior cell.
*/
static bool IsInExterior(unsigned short pid) noexcept;
/**
* \brief Get the region of the player's exterior cell.
*
* A blank value will be returned if the player is in an interior.
*
* \param pid The player ID.
* \return The region.
*/
static const char *GetRegion(unsigned short pid) noexcept;
/**
* \brief Check whether the player's last cell change has involved a region change.
*
* \param pid The player ID.
* \return Whether the player has changed their region.
*/
static bool IsChangingRegion(unsigned short pid) noexcept;
/**
* \brief Set the cell of a player.
*
* This changes the cell recorded for that player in the server memory, but does not by itself
* send a packet.
*
* The cell is determined to be an exterior cell if it fits the pattern of a number followed
* by a comma followed by another number.
*
* \param pid The player ID.
* \param cellDescription The cell description.
* \return void
*/
static void SetCell(unsigned short pid, const char *cellDescription) noexcept;
/**
* \brief Set the cell of a player to an exterior cell.
*
* This changes the cell recorded for that player in the server memory, but does not by itself
* send a packet.
*
* \param pid The player ID.
* \param x The X coordinate of the cell.
* \param y The Y coordinate of the cell.
* \return void
*/
static void SetExteriorCell(unsigned short pid, int x, int y) noexcept;
/**
* \brief Add a new explored cell to the map changes for a player.
*
* \param pid The player ID whose map changes should be used.
* \param cellDescription The cell description of the explored cell.
* \return void
*/
static void AddCellExplored(unsigned short pid, const char* cellDescription) noexcept;
/**
* \brief Send a PlayerCellChange packet about a player.
*
* It is only sent to the affected player.
*
* \param pid The player ID.
* \return void
*/
static void SendCell(unsigned short pid) noexcept;
/**
* \brief Send a PlayerMap packet with a player's recorded map changes.
*
* \param pid The player ID whose map changes should be used.
* \param toOthers Whether this packet should be sent only to other players or
* only to the player it is about.
* \return void
*/
static void SendMapChanges(unsigned short pid, bool toOthers = false) noexcept;
};

@ -10,126 +10,126 @@
using namespace std;
using namespace ESM;
void CharClassFunctions::SendClass(unsigned short pid) noexcept
const char *CharClassFunctions::GetDefaultClass(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CHARCLASS)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CHARCLASS)->Send(false);
GET_PLAYER(pid, player, "");
return player->charClass.mId.c_str();
}
void CharClassFunctions::SetDefaultClass(unsigned short pid, const char *id) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mId = id;
}
void CharClassFunctions::SetClassName(unsigned short pid, const char *name) noexcept
const char *CharClassFunctions::GetClassName(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mName = name;
player->charClass.mId = "";
GET_PLAYER(pid, player, "");
return player->charClass.mName.c_str();
}
void CharClassFunctions::SetClassDesc(unsigned short pid, const char *desc) noexcept
const char *CharClassFunctions::GetClassDesc(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mDescription = desc;
GET_PLAYER(pid, player, "");
return player->charClass.mDescription.c_str();
}
void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept
int CharClassFunctions::GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
GET_PLAYER(pid, player, 0);
if (slot > 1)
throw invalid_argument("Incorrect attribute slot id");
player->charClass.mData.mAttribute[slot] = attrId;
return player->charClass.mData.mAttribute[slot];
}
void CharClassFunctions::SetClassSpecialization(unsigned short pid, int spec) noexcept
int CharClassFunctions::GetClassSpecialization(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
player->charClass.mData.mSpecialization = spec;
GET_PLAYER(pid, player, 0);
return player->charClass.mData.mSpecialization;
}
void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept
int CharClassFunctions::GetClassMajorSkill(unsigned short pid, unsigned char slot) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
GET_PLAYER(pid, player, 0);
if (slot > 4)
throw invalid_argument("Incorrect skill slot id");
player->charClass.mData.mSkills[slot][1] = skillId;
return player->charClass.mData.mSkills[slot][1];
}
void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept
int CharClassFunctions::GetClassMinorSkill(unsigned short pid, unsigned char slot) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
GET_PLAYER(pid, player, 0);
if (slot > 4)
throw invalid_argument("Incorrect skill slot id");
player->charClass.mData.mSkills[slot][0] = skillId;
return player->charClass.mData.mSkills[slot][0];
}
int CharClassFunctions::IsClassDefault(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player,0);
GET_PLAYER(pid, player, 0);
return !player->charClass.mId.empty(); // true if default
}
const char *CharClassFunctions::GetDefaultClass(unsigned short pid) noexcept
void CharClassFunctions::SetDefaultClass(unsigned short pid, const char *id) noexcept
{
Player *player;
GET_PLAYER(pid, player,"");
return player->charClass.mId.c_str();
GET_PLAYER(pid, player,);
player->charClass.mId = id;
}
const char *CharClassFunctions::GetClassName(unsigned short pid) noexcept
void CharClassFunctions::SetClassName(unsigned short pid, const char *name) noexcept
{
Player *player;
GET_PLAYER(pid, player,"");
return player->charClass.mName.c_str();
GET_PLAYER(pid, player,);
player->charClass.mName = name;
player->charClass.mId = "";
}
const char *CharClassFunctions::GetClassDesc(unsigned short pid) noexcept
void CharClassFunctions::SetClassDesc(unsigned short pid, const char *desc) noexcept
{
Player *player;
GET_PLAYER(pid, player,"");
return player->charClass.mDescription.c_str();
GET_PLAYER(pid, player,);
player->charClass.mDescription = desc;
}
int CharClassFunctions::GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept
void CharClassFunctions::SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept
{
Player *player;
GET_PLAYER(pid, player,0);
GET_PLAYER(pid, player,);
if (slot > 1)
throw invalid_argument("Incorrect attribute slot id");
return player->charClass.mData.mAttribute[slot];
}
int CharClassFunctions::GetClassSpecialization(unsigned short pid) noexcept
player->charClass.mData.mAttribute[slot] = attrId;
}
void CharClassFunctions::SetClassSpecialization(unsigned short pid, int spec) noexcept
{
Player *player;
GET_PLAYER(pid, player,0);
return player->charClass.mData.mSpecialization;
GET_PLAYER(pid, player,);
player->charClass.mData.mSpecialization = spec;
}
int CharClassFunctions::GetClassMajorSkill(unsigned short pid, unsigned char slot) noexcept
void CharClassFunctions::SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player,0);
GET_PLAYER(pid, player,);
if (slot > 4)
throw invalid_argument("Incorrect skill slot id");
return player->charClass.mData.mSkills[slot][1];
player->charClass.mData.mSkills[slot][1] = skillId;
}
int CharClassFunctions::GetClassMinorSkill(unsigned short pid, unsigned char slot) noexcept
void CharClassFunctions::SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept
{
Player *player;
GET_PLAYER(pid, player,0);
GET_PLAYER(pid, player,);
if (slot > 4)
throw invalid_argument("Incorrect skill slot id");
return player->charClass.mData.mSkills[slot][0];
player->charClass.mData.mSkills[slot][0] = skillId;
}
void CharClassFunctions::SendClass(unsigned short pid) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CHARCLASS)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CHARCLASS)->Send(false);
}

@ -8,13 +8,6 @@
#include "../Types.hpp"
#define CHARCLASSAPI \
{"SetDefaultClass", CharClassFunctions::SetDefaultClass},\
{"SetClassName", CharClassFunctions::SetClassName},\
{"SetClassDesc", CharClassFunctions::SetClassDesc},\
{"SetClassMajorAttribute", CharClassFunctions::SetClassMajorAttribute},\
{"SetClassSpecialization", CharClassFunctions::SetClassSpecialization},\
{"SetClassMajorSkill", CharClassFunctions::SetClassMajorSkill},\
{"SetClassMinorSkill", CharClassFunctions::SetClassMinorSkill},\
{"GetDefaultClass", CharClassFunctions::GetDefaultClass},\
{"GetClassName", CharClassFunctions::GetClassName},\
{"GetClassDesc", CharClassFunctions::GetClassDesc},\
@ -23,59 +16,165 @@
{"GetClassMajorSkill", CharClassFunctions::GetClassMajorSkill},\
{"GetClassMinorSkill", CharClassFunctions::GetClassMinorSkill},\
{"IsClassDefault", CharClassFunctions::IsClassDefault},\
\
{"SetDefaultClass", CharClassFunctions::SetDefaultClass},\
{"SetClassName", CharClassFunctions::SetClassName},\
{"SetClassDesc", CharClassFunctions::SetClassDesc},\
{"SetClassMajorAttribute", CharClassFunctions::SetClassMajorAttribute},\
{"SetClassSpecialization", CharClassFunctions::SetClassSpecialization},\
{"SetClassMajorSkill", CharClassFunctions::SetClassMajorSkill},\
{"SetClassMinorSkill", CharClassFunctions::SetClassMinorSkill},\
\
{"SendClass", CharClassFunctions::SendClass}
class CharClassFunctions
{
public:
CharClassFunctions() {}
static void SetDefaultClass(unsigned short pid, const char *id) noexcept;
static void SetClassName(unsigned short pid, const char *name) noexcept;
static void SetClassDesc(unsigned short pid, const char *desc) noexcept;
/**
* \param pid
* \param slot 0 = first, 1 = second
* \param attrId
*/
static void SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept;
/**
* \param pid
* \param spec 0 = Combat, 1 = Magic, 2 = Stealth
*/
static void SetClassSpecialization(unsigned short pid, int spec) noexcept;
/**
* \param pid
* \param slot 0 to 4
* \param skillId
*/
static void SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept;
static void SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept;
/**
* \brief Get the default class used by a player.
*
* \param pid The player ID.
* \return The ID of the default class.
*/
static const char *GetDefaultClass(unsigned short pid) noexcept;
/**
* \brief Get the name of the custom class used by a player.
*
* \param pid The player ID.
* \return The name of the custom class.
*/
static const char *GetClassName(unsigned short pid) noexcept;
/**
* \brief Get the description of the custom class used by a player.
*
* \param pid The player ID.
* \return The description of the custom class.
*/
static const char *GetClassDesc(unsigned short pid) noexcept;
/**
* \param pid
* \param slot 0 = first, 1 = second
* \return attrId
*/
* \brief Get the ID of one of the two major attributes of a custom class used by a player.
*
* \param pid The player ID.
* \param slot The slot of the major attribute (0 or 1).
* \return The ID of the major attribute.
*/
static int GetClassMajorAttribute(unsigned short pid, unsigned char slot) noexcept;
/**
* \param pid
* \return spec 0 = Combat, 1 = Magic, 2 = Stealth
*/
* \brief Get the specialization ID of the custom class used by a player.
*
* \param pid The player ID.
* \return The specialization ID of the custom class (0 for Combat, 1 for Magic, 2 for Stealth).
*/
static int GetClassSpecialization(unsigned short pid) noexcept;
/**
* \param pid
* \param slot 0 to 4
* \return skillId
*/
* \brief Get the ID of one of the five major skills of a custom class used by a player.
*
* \param pid The player ID.
* \param slot The slot of the major skill (0 to 4).
* \return The ID of the major skill.
*/
static int GetClassMajorSkill(unsigned short pid, unsigned char slot) noexcept;
/**
* \brief Get the ID of one of the five minor skills of a custom class used by a player.
*
* \param pid The player ID.
* \param slot The slot of the minor skill (0 to 4).
* \return The ID of the minor skill.
*/
static int GetClassMinorSkill(unsigned short pid, unsigned char slot) noexcept;
/**
* \brief Check whether the player is using a default class instead of a custom one.
*
* \param pid The player ID.
* \return Whether the player is using a default class.
*/
static int IsClassDefault(unsigned short pid) noexcept;
/**
* \brief Set the default class used by a player.
*
* If this is left blank, the custom class data set for the player will be used instead.
*
* \param pid The player ID.
* \param id The ID of the default class.
* \return void
*/
static void SetDefaultClass(unsigned short pid, const char *id) noexcept;
/**
* \brief Set the name of the custom class used by a player.
*
* \param pid The player ID.
* \param name The name of the custom class.
* \return void
*/
static void SetClassName(unsigned short pid, const char *name) noexcept;
/**
* \brief Set the description of the custom class used by a player.
*
* \param pid The player ID.
* \param desc The description of the custom class.
* \return void
*/
static void SetClassDesc(unsigned short pid, const char *desc) noexcept;
/**
* \brief Set the ID of one of the two major attributes of the custom class used by a player.
*
* \param pid The player ID.
* \param slot The slot of the major attribute (0 or 1).
* \param attrId The ID to use for the attribute.
* \return void
*/
static void SetClassMajorAttribute(unsigned short pid, unsigned char slot, int attrId) noexcept;
/**
* \brief Set the specialization of the custom class used by a player.
*
* \param pid The player ID.
* \param spec The specialization ID to use (0 for Combat, 1 for Magic, 2 for Stealth).
* \return void
*/
static void SetClassSpecialization(unsigned short pid, int spec) noexcept;
/**
* \brief Set the ID of one of the five major skills of the custom class used by a player.
*
* \param pid The player ID.
* \param slot The slot of the major skill (0 to 4).
* \param skillId The ID to use for the skill.
* \return void
*/
static void SetClassMajorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept;
/**
* \brief Set the ID of one of the five minor skills of the custom class used by a player.
*
* \param pid The player ID.
* \param slot The slot of the minor skill (0 to 4).
* \param skillId The ID to use for the skill.
* \return void
*/
static void SetClassMinorSkill(unsigned short pid, unsigned char slot, int skillId) noexcept;
/**
* \brief Send a PlayerCharClass packet about a player.
*
* It is only sent to the affected player.
*
* \param pid The player ID.
* \return void
*/
static void SendClass(unsigned short pid) noexcept;
};

@ -22,7 +22,7 @@ public:
*
* This is based on the last PlayerShapeshift packet received or sent for that player.
*
* \param pid The player id.
* \param pid The player ID.
* \return The werewolf state.
*/
static bool IsWerewolf(unsigned short pid) noexcept;
@ -33,7 +33,7 @@ public:
* This changes the werewolf state recorded for that player in the server memory, but
* does not by itself send a packet.
*
* \param pid The player id.
* \param pid The player ID.
* \param bool The new werewolf state.
* \return void
*/
@ -45,7 +45,7 @@ public:
* This sends the packet to all players connected to the server. It is currently used
* only to communicate werewolf states.
*
* \param pid The player id.
* \param pid The player ID.
* \return void
*/
static void SendShapeshift(unsigned short pid);
@ -59,7 +59,7 @@ public:
* It is only sent to the player being jailed, as the other players will be informed of the
* jailing's actual consequences via other packets sent by the affected client.
*
* \param pid The player id.
* \param pid The player ID.
* \param jailDays The number of days to spend jailed, where each day affects one skill point.
* \param ignoreJailTeleportation Whether the player being teleported to the nearest jail
* marker should be overridden.
@ -78,7 +78,7 @@ public:
*
* This sends the packet to all players connected to the server.
*
* \param pid The player id.
* \param pid The player ID.
* \param type The type of resurrection (0 for REGULAR, 1 for IMPERIAL_SHRINE,
* 2 for TRIBUNAL_TEMPLE).
* \return void

@ -27,7 +27,7 @@ public:
* \brief Assign the player's positional coordinate values to the variables passed as
* parameters.
*
* \param pid The player id.
* \param pid The player ID.
* \param x The variable for the X position.
* \param y The variable for the Y position.
* \param z The variable for the Z position.
@ -38,7 +38,7 @@ public:
/**
* \brief Get the X position of a player.
*
* \param pid The player id.
* \param pid The player ID.
* \return The X position.
*/
static double GetPosX(unsigned short pid) noexcept;
@ -46,7 +46,7 @@ public:
/**
* \brief Get the Y position of a player.
*
* \param pid The player id.
* \param pid The player ID.
* \return The Y position.
*/
static double GetPosY(unsigned short pid) noexcept;
@ -54,7 +54,7 @@ public:
/**
* \brief Get the Z position of a player.
*
* \param pid The player id.
* \param pid The player ID.
* \return The Z position.
*/
static double GetPosZ(unsigned short pid) noexcept;
@ -63,7 +63,7 @@ public:
* \brief Assign the player's rotational coordinate values to the variables passed as
* parameters.
*
* \param pid The player id.
* \param pid The player ID.
* \param x The variable for the X rotation.
* \param y The variable for the Y rotation.
* \param z The variable for the Z rotation.
@ -74,7 +74,7 @@ public:
/**
* \brief Get the X rotation of a player.
*
* \param pid The player id.
* \param pid The player ID.
* \return The X rotation.
*/
static double GetRotX(unsigned short pid) noexcept;
@ -82,7 +82,7 @@ public:
/**
* \brief Get the Z rotation of a player.
*
* \param pid The player id.
* \param pid The player ID.
* \return The Z rotation.
*/
static double GetRotZ(unsigned short pid) noexcept;
@ -93,7 +93,7 @@ public:
* This changes the positional coordinates recorded for that player in the server memory, but
* does not by itself send a packet.
*
* \param pid The player id.
* \param pid The player ID.
* \param x The X position.
* \param y The Y position.
* \param z The Z position.
@ -109,7 +109,7 @@ public:
*
* A player's Y rotation is always 0, which is why there is no Y rotation parameter.
*
* \param pid The player id.
* \param pid The player ID.
* \param x The X position.
* \param z The Z position.
* \return void
@ -121,7 +121,7 @@ public:
*
* It is only sent to the affected player.
*
* \param pid The player id.
* \param pid The player ID.
* \return void
*/
static void SendPos(unsigned short pid) noexcept;

@ -19,7 +19,7 @@ public:
* This changes the console permission for that player in the server memory, but does not
* by itself send a packet.
*
* \param pid The player id.
* \param pid The player ID.
* \param bool The console permission state.
* \return void
*/
@ -31,7 +31,7 @@ public:
* This changes the difficulty for that player in the server memory, but does not by itself
* send a packet.
*
* \param pid The player id.
* \param pid The player ID.
* \param bool The difficulty.
* \return void
*/

@ -86,7 +86,7 @@ public:
*
* This is used to initialize the sending of new Object packets.
*
* \param pid The player ID to whom the event should later be sent.
* \param pid The player ID to whom the event should be attached.
* \return void
*/
static void InitializeEvent(unsigned short pid) noexcept;
@ -300,7 +300,7 @@ public:
* The cell is determined to be an exterior cell if it fits the pattern of a number followed
* by a comma followed by another number.
*
* \param cellDescription The cellDescription.
* \param cellDescription The description of the cell.
* \return void
*/
static void SetEventCell(const char* cellDescription) noexcept;
@ -586,7 +586,7 @@ public:
/**
* \brief Set the game hour for a player and send a GameTime packet to that player.
*
* \param pid The player id.
* \param pid The player ID.
* \param hour The hour.
* \return void
*/
@ -595,7 +595,7 @@ public:
/**
* \brief Set the game month for a player and send a GameTime packet to that player.
*
* \param pid The player id.
* \param pid The player ID.
* \param month The month.
* \return void
*/
@ -604,7 +604,7 @@ public:
/**
* \brief Set the game day for a player and send a GameTime packet to that player.
*
* \param pid The player id.
* \param pid The player ID.
* \param day The day.
* \return void
*/

@ -15,6 +15,7 @@ void mwmp::PacketPlayerClass::Packet(RakNet::BitStream *bs, bool send)
PlayerPacket::Packet(bs, send);
RW(player->charClass.mId, send);
if (player->charClass.mId.empty()) // custom class
{
RW(player->charClass.mName, send, 1);

Loading…
Cancel
Save