diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/accounthandler.h | 4 | ||||
-rw-r--r-- | src/being.cpp | 25 | ||||
-rw-r--r-- | src/being.h | 96 | ||||
-rw-r--r-- | src/chathandler.h | 4 | ||||
-rw-r--r-- | src/client.cpp | 10 | ||||
-rw-r--r-- | src/connectionhandler.h | 4 | ||||
-rw-r--r-- | src/debug.h | 10 | ||||
-rw-r--r-- | src/messagehandler.h | 4 | ||||
-rw-r--r-- | src/messagein.h | 4 | ||||
-rw-r--r-- | src/messageout.cpp | 15 | ||||
-rw-r--r-- | src/messageout.h | 10 | ||||
-rw-r--r-- | src/netcomputer.h | 4 | ||||
-rw-r--r-- | src/netsession.h | 4 | ||||
-rw-r--r-- | src/packet.h | 4 | ||||
-rw-r--r-- | src/sqlitestorage.h | 6 |
15 files changed, 101 insertions, 103 deletions
diff --git a/src/accounthandler.h b/src/accounthandler.h index f0df51b8..14f13cf3 100644 --- a/src/accounthandler.h +++ b/src/accounthandler.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef _TMW_SERVER_ACCOUNTHANDLER_ -#define _TMW_SERVER_ACCOUNTHANDLER_ +#ifndef _TMWSERV_ACCOUNTHANDLER_H_ +#define _TMWSERV_ACCOUNTHANDLER_H_ #include "messagehandler.h" #include "netcomputer.h" diff --git a/src/being.cpp b/src/being.cpp index be0b312d..ce8462f3 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -273,7 +273,8 @@ Being::getRawStatistics(void) /** * Update the internal status. */ -void Being::update(void) +void +Being::update(void) { // computed stats. mStats.health = 20 + (20 * mRawStats.vitality); @@ -286,19 +287,22 @@ void Being::update(void) mNeedUpdate = false; } -void Being::setInventory(const std::vector<unsigned int> &inven) +void +Being::setInventory(const std::vector<unsigned int> &inven) { inventory = inven; } -bool Being::addInventory(unsigned int itemId) +bool +Being::addInventory(unsigned int itemId) { // If required weight could be tallied to see if player can pick up more. inventory.push_back(itemId); return true; } -bool Being::delInventory(unsigned int itemId) +bool +Being::delInventory(unsigned int itemId) { for (std::vector<unsigned int>::iterator i = inventory.begin(); i != inventory.end(); i++) { @@ -310,16 +314,20 @@ bool Being::delInventory(unsigned int itemId) return false; } -bool Being::hasItem(unsigned int itemId) { +bool +Being::hasItem(unsigned int itemId) +{ for (std::vector<unsigned int>::iterator i = inventory.begin(); - i != inventory.end(); i++) { + i != inventory.end(); i++) + { if (*i == itemId) return true; } return false; } -bool Being::equip(unsigned int itemId, unsigned char slot) +bool +Being::equip(unsigned int itemId, unsigned char slot) { // currently this is too simplistic and doesn't check enough // but until further functionality is implemented in the @@ -331,7 +339,8 @@ bool Being::equip(unsigned int itemId, unsigned char slot) return false; } -bool Being::unequip(unsigned char slot) +bool +Being::unequip(unsigned char slot) { // NOTE: 0 will be invalid item id (or we could use key/value pairs) equipment[slot] = 0; diff --git a/src/being.h b/src/being.h index cb1e5456..bbb86346 100644 --- a/src/being.h +++ b/src/being.h @@ -77,239 +77,223 @@ class Being: public Object const unsigned int money, const RawStatistics& stats); - /** * Destructor. */ ~Being(void) throw(); - /** - * Get the name. + * Gets the name. * * @return the name. */ const std::string& getName(void) const; - /** - * Get the gender. + * Gets the gender. * * @return the gender. */ Genders getGender(void) const; - /** - * Set the level. + * Sets the level. * * @param level the new level. */ void setLevel(const unsigned short level); - /** - * Get the level. + * Gets the level. * * @return the level. */ unsigned short getLevel(void) const; - /** - * Set the money. + * Sets the money. * * @param amount the new amount. */ void setMoney(const unsigned int amount); - /** - * Get the amount of money. + * Gets the amount of money. * * @return the amount of money. */ unsigned int getMoney(void) const; - /** - * Set the strength. + * Sets the strength. * * @param strength the new strength. */ void setStrength(const unsigned short strength); - /** - * Get the strength. + * Gets the strength. * * @return the strength. */ unsigned short getStrength(void) const; - /** - * Set the agility. + * Sets the agility. * * @param agility the new agility. */ void setAgility(const unsigned short agility); - /** - * Get the agility. + * Gets the agility. * * @return the agility. */ unsigned short getAgility(void) const; - /** - * Set the vitality. + * Sets the vitality. * * @param vitality the new vitality. */ void setVitality(const unsigned short vitality); - /** - * Get the vitality. + * Gets the vitality. * * @return the vitality. */ unsigned short getVitality(void) const; - /** - * Set the intelligence. + * Sets the intelligence. * * @param intelligence the new intelligence. */ void setIntelligence(const unsigned short intelligence); - /** - * Get the intelligence. + * Gets the intelligence. * * @return the intelligence. */ unsigned short getIntelligence(void) const; - /** - * Set the dexterity. + * Sets the dexterity. * * @param dexterity the new dexterity. */ void setDexterity(const unsigned short dexterity); - /** - * Get the dexterity. + * Gets the dexterity. * * @return the dexterity. */ unsigned short getDexterity(void) const; - /** - * Set the luck. + * Sets the luck. * * @param luck the new luck. */ void setLuck(const unsigned short luck); - /** - * Get the luck. + * Gets the luck. * * @return the luck. */ unsigned short getLuck(void) const; - /** - * Set the raw statistics. + * Sets the raw statistics. * * @param stats the new raw statistics. */ void setRawStatistics(const RawStatistics& stats); - /** - * Get the raw statistics. + * Gets the raw statistics. * * @return the raw statistics. */ RawStatistics& getRawStatistics(void); - /** - * Update the internal status. + * Updates the internal status. */ void update(void); /** - * Set inventory + * Sets inventory. */ - void setInventory(const std::vector<unsigned int> &inven); + void + setInventory(const std::vector<unsigned int> &inven); /** - * Add item with ID to inventory + * Adds item with ID to inventory. * * @return Item add success/failure */ - bool addInventory(unsigned int itemId); + bool + addInventory(unsigned int itemId); /** - * Remove item with ID from inventory + * Removes item with ID from inventory. * * @return Item delete success/failure */ - bool delInventory(unsigned int itemId); + bool + delInventory(unsigned int itemId); /** - * Check if character has an item + * Checks if character has an item. * * @return true if being has item, false otherwise */ - bool hasItem(unsigned int itemId); + bool + hasItem(unsigned int itemId); /** - * Equip item with ID in equipment slot + * Equips item with ID in equipment slot. * * @return Equip success/failure */ - bool equip(unsigned int itemId, unsigned char slot); + bool + equip(unsigned int itemId, unsigned char slot); /** - * Un-equip item + * Un-equips item. * * bool Un-equip success/failure */ - bool unequip(unsigned char slot); + bool + unequip(unsigned char slot); private: /** @@ -317,14 +301,12 @@ class Being: public Object */ Being(const Being& rhs); - /** * Assignment operator. */ Being& operator=(const Being& rhs); - private: std::string mName; /**< name of the being */ Genders mGender; /**< gender of the being */ diff --git a/src/chathandler.h b/src/chathandler.h index 5087cb0c..3f9b2307 100644 --- a/src/chathandler.h +++ b/src/chathandler.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef _TMW_SERVER_CHATHANDLER_ -#define _TMW_SERVER_CHATHANDLER_ +#ifndef _TMWSERV_CHATHANDLER_H_ +#define _TMWSERV_CHATHANDLER_H_ #include "messagehandler.h" #include "netcomputer.h" diff --git a/src/client.cpp b/src/client.cpp index c3870b49..be2424b8 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -5,7 +5,8 @@ #include "defines.h" #include "messageout.h" -int main(int argc, char *argv[]) { +int main(int argc, char *argv[]) +{ // Initialize SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) { printf("SDL_Init: %s\n", SDL_GetError()); @@ -40,11 +41,12 @@ int main(int argc, char *argv[]) { int answer = 1; char line[256] = ""; - - while (answer != 0) { + + while (answer != 0) + { bool responseRequired = true; MessageOut msg; - + printf ("0) Quit\n"); printf ("1) Register\n"); printf ("2) Login\n"); diff --git a/src/connectionhandler.h b/src/connectionhandler.h index bafdcdd6..944b1c6a 100644 --- a/src/connectionhandler.h +++ b/src/connectionhandler.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef _TMW_SERVER_CONNECTIONHANDLER_ -#define _TMW_SERVER_CONNECTIONHANDLER_ +#ifndef _TMWSERV_CONNECTIONHANDLER_H_ +#define _TMWSERV_CONNECTIONHANDLER_H_ #include "messagehandler.h" #include "netcomputer.h" diff --git a/src/debug.h b/src/debug.h index 37d191f0..65a95e36 100644 --- a/src/debug.h +++ b/src/debug.h @@ -21,14 +21,14 @@ * $Id$ */ -#ifndef _TMW_SERVER_DEBUG_ -#define _TMW_SERVER_DEBUG_ - +#ifndef _TMWSERV_DEBUG_H_ +#define _TMWSERV_DEBUG_H_ + // This file defines the return types for debugging /** * Returns a message on function failure if the debug flag is set to true. - */ + */ extern void debugCatch(int result); @@ -38,7 +38,7 @@ extern void debugCatch(int result); // GENERAL #define TMW_SUCCESS 1 // the function completed successfully - + // ACCOUNT #define TMW_ACCOUNTERROR_NOEXIST 100 #define TMW_ACCOUNTERROR_BANNED 101 diff --git a/src/messagehandler.h b/src/messagehandler.h index ccf2a8f1..1b7c4681 100644 --- a/src/messagehandler.h +++ b/src/messagehandler.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef _TMW_SERVER_MESSAGEHANDLER_ -#define _TMW_SERVER_MESSAGEHANDLER_ +#ifndef _TMWSERV_MESSAGEHANDLER_H_ +#define _TMWSERV_MESSAGEHANDLER_H_ #include "netcomputer.h" #include "messagein.h" diff --git a/src/messagein.h b/src/messagein.h index b2682fc1..02221efe 100644 --- a/src/messagein.h +++ b/src/messagein.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef _TMW_SERVER_MESSAGEIN_ -#define _TMW_SERVER_MESSAGEIN_ +#ifndef _TMWSERV_MESSAGEIN_H_ +#define _TMWSERV_MESSAGEIN_H_ #include "packet.h" #include <string> diff --git a/src/messageout.cpp b/src/messageout.cpp index a2faf33e..95e55a86 100644 --- a/src/messageout.cpp +++ b/src/messageout.cpp @@ -44,13 +44,15 @@ MessageOut::~MessageOut() } } -void MessageOut::expand(size_t bytes) +void +MessageOut::expand(size_t bytes) { mData = (char*)realloc(mData, bytes); mDataSize = bytes; } -void MessageOut::writeByte(char value) +void +MessageOut::writeByte(char value) { expand(mPos + sizeof(char)); mData[mPos] = value; @@ -64,14 +66,16 @@ void MessageOut::writeShort(short value) mPos += sizeof(short); } -void MessageOut::writeLong(long value) +void +MessageOut::writeLong(long value) { expand(mPos + sizeof(long)); SDLNet_Write32(value, &mData[mPos]); mPos += sizeof(long); } -void MessageOut::writeString(const std::string &string, int length) +void +MessageOut::writeString(const std::string &string, int length) { std::string toWrite = string; @@ -103,7 +107,8 @@ void MessageOut::writeString(const std::string &string, int length) } } -const Packet *MessageOut::getPacket() +const Packet* +MessageOut::getPacket() { if (!mPacket) { diff --git a/src/messageout.h b/src/messageout.h index 7d1da2f8..4480ec22 100644 --- a/src/messageout.h +++ b/src/messageout.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef _TMW_SERVER_MESSAGEOUT_ -#define _TMW_SERVER_MESSAGEOUT_ +#ifndef _TMWSERV_MESSAGEOUT_H_ +#define _TMWSERV_MESSAGEOUT_H_ #include <string> @@ -44,9 +44,9 @@ class MessageOut */ ~MessageOut(); - void writeByte(char value); /**< Reads a byte. */ - void writeShort(short value); /**< Reads a short. */ - void writeLong(long value); /**< Reads a long. */ + void writeByte(char value); /**< Writes a byte. */ + void writeShort(short value); /**< Writes a short. */ + void writeLong(long value); /**< Writes a long. */ /** * Writes a string. If a fixed length is not given (-1), it is stored diff --git a/src/netcomputer.h b/src/netcomputer.h index 1cecd719..c1a4bac5 100644 --- a/src/netcomputer.h +++ b/src/netcomputer.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef _TMW_SERVER_NETCOMPUTER_ -#define _TMW_SERVER_NETCOMPUTER_ +#ifndef _TMWSERV_NETCOMPUTER_H_ +#define _TMWSERV_NETCOMPUTER_H_ #include "packet.h" #include <SDL_net.h> diff --git a/src/netsession.h b/src/netsession.h index b313e2fc..36315177 100644 --- a/src/netsession.h +++ b/src/netsession.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef _TMW_SERVER_NETSESSION_ -#define _TMW_SERVER_NETSESSION_ +#ifndef _TMWSERV_NETSESSION_H_ +#define _TMWSERV_NETSESSION_H_ #include "netcomputer.h" #include "connectionhandler.h" diff --git a/src/packet.h b/src/packet.h index 4e1d48c5..888bfbce 100644 --- a/src/packet.h +++ b/src/packet.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef _TMW_SERVER_PACKET_ -#define _TMW_SERVER_PACKET_ +#ifndef _TMWSERV_PACKET_H_ +#define _TMWSERV_PACKET_H_ /** * A packet wraps a certain amount of bytes for sending and receiving. diff --git a/src/sqlitestorage.h b/src/sqlitestorage.h index 7f11e0f6..81c53f8c 100644 --- a/src/sqlitestorage.h +++ b/src/sqlitestorage.h @@ -21,8 +21,8 @@ * $Id$ */ -#ifndef TMWSERV_SQLITESTORAGE_H -#define TMWSERV_SQLITESTORAGE_H +#ifndef _TMWSERV_SQLITESTORAGE_H_ +#define _TMWSERV_SQLITESTORAGE_H_ #include "sqlite/SQLiteWrapper.h" #include "storage.h" @@ -69,4 +69,4 @@ class SQLiteStorage : public Storage void createTablesIfNecessary(); }; -#endif /* TMWSERV_SQLITESTORAGE_H */ +#endif // _TMWSERV_SQLITESTORAGE_H_ |