- Main Page
- Classes
- Files

- File List
- File Members

# E:/uas2/Server/Shared.h

Go to the documentation of this file.

    00001 /*
    00002 * This file is part of UAS2.
    00003 *
    00004 * UAS2 is free software; you can redistribute it and/or modify
    00005 * it under the terms of the GNU General Public License as published by
    00006 * the Free Software Foundation; either version 2 of the License, or
    00007 * (at your option) any later version.
    00008 *
    00009 * UAS2 is distributed in the hope that it will be useful,
    00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012 * GNU General Public License for more details.
    00013
    00014 * You should have received a copy of the GNU General Public License
    00015 * along with UASv1; if not, write to the Free Software
    00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00017 */
    00018
    00024 #ifndef __SHARED_H
    00025 #define __SHARED_H
    00026 #pragma once
    00027
    00028 #include <winsock2.h>
    00029 #include <time.h>
    00030 #include <list>
    00031 #include <math.h>
    00032
    00033 #define WM_CLEAROBJECTS                 WM_APP+1
    00034
    00035 #define MAX_PACKET_SIZE         0x1E4
    00036 #define MAX_FRAGMENT_SIZE       0x1D0
    00037 #define MAX_DATA_SIZE           0x1C0
    00038
    00039 #define MAX_CORPSES                     1000
    00040 #define MAX_MONSTERS            5000
    00041 #define MAX_PETS                        5000
    00042 #define DELAY                           120
    00043 #define CORPSE_DELAY            60
    00044 #define ACTION_DELAY            1
    00045 #define TICKS_PER_SEC           10
    00046 #define MAX_LEVEL                       126
    00047
    00048 //Allegiance
    00049 #define OLD_PASSUP                      true    // XP share based upon number of fellows (vassal factor)
    00050 #define PASSED_XP_MULT          1               // XP passup multiplier
    00051 #define RECEIVED_XP_MULT        1               // XP reception multiplier
    00052 #define MAX_VASSALS                     12              // maximum number of vassals
    00053 #define MAX_RANK                        10              // maximum rank
    00054
    00055 //Fellowship
    00056 #define OLD_PASSTHROUGH         true    // XP share based upon number of fellows (fellow factor)
    00057 #define SHARED_XP_MULT          1               // XP sharing multiplier
    00058 #define OLD_FELLOW_RANGE        true    // maximum distance for 100% XP share
    00059 #define FELLOW_RANGE_MULT       1               // XP share distance multiplier
    00060 #define MAX_FELLOW_SIZE         9               // maximum number of fellows
    00061
    00062 #ifdef _DEBUG
    00063 #define SAFEDELETE( p )                         \
    00064         {                                                               \
    00065                 try {                                           \
    00066                         delete (p);                             \
    00067                         (p) = NULL;                             \
    00068                 }                                                       \
    00069                 catch ( ... ) {                         \
    00070                         UpdateConsole( "\r\n Bad deletion attempt detected at %s %lu!!\r\n", __FILE__, __LINE__ );      \
    00071                 }                                                       \
    00072         }
    00073 #else
    00074 #define SAFEDELETE( p )                 \
    00075         {                                                       \
    00076                 delete (p);                             \
    00077                 (p) = NULL;                             \
    00078         }
    00079 #endif
    00080
    00081 #ifdef _DEBUG
    00082 #define SAFEDELETE_ARRAY( a )           \
    00083         {                                                               \
    00084                 try {                                           \
    00085                         delete[] (a);                   \
    00086                         (a) = NULL;                             \
    00087                 }                                                       \
    00088                 catch ( ... ) {                         \
    00089                         UpdateConsole( "\r\n Bad array deletion attempt detected at %s %lu!!\r\n", __FILE__, __LINE__ );        \
    00090                 }                                                       \
    00091         }
    00092 #else
    00093 #define SAFEDELETE_ARRAY( a )   \
    00094         {                                                       \
    00095                 delete[] (a);                   \
    00096                 (a) = NULL;                             \
    00097         }
    00098 #endif
    00099
    00100
    00101 #define         CHECKRETURN(ExitOnError, hType, hName, ReturnOnError)                                   \
    00102                         if (!(retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO || retcode == SQL_NO_DATA))            \
    00103                         {                                                                                                                                               \
    00104                                 UpdateConsole( " <SQL> %s: Error on line %lu: ", __FILE__, __LINE__ );\
    00105                                 cDatabase::GetError(hType, &hName);                                                                     \
    00106                                 if (ExitOnError)                                                                                                        \
    00107                                 {                                                                                                                                       \
    00108                                         UpdateConsole(" <SQL> Function has been aborted.\r\n");                 \
    00109                                         /*return ReturnOnError; */                                                                              \
    00110                                 }                                                                                                                                       \
    00111                                 else                                                                                                                            \
    00112                                         UpdateConsole(" <SQL> Function has been continued normally.\r\n");      \
    00113                         }
    00114
    00115 class cClient;
    00116 typedef std::list< cClient * >::iterator iterClient_lst;
    00117
    00118 class cObject;
    00119 typedef std::list< cObject * >::iterator iterObject_lst;
    00120
    00121 class cModels;
    00122 typedef std::list< cModels * >::iterator iterModel_lst;
    00123
    00124 class cMagicModels;
    00125 typedef std::list< cMagicModels * >::iterator iterMagicModel_lst;
    00126
    00127 class cEnchantment;
    00128 typedef std::list< cEnchantment * >::iterator iterEnchantment_lst;
    00129
    00130 class cNPC;
    00131 typedef std::list< cNPC * >::iterator iterNPCs_lst;
    00132
    00133 #pragma pack( push, 1 )
    00134 typedef struct
    00135 {
    00136         DWORD   m_dwSequence;
    00137         DWORD   m_dwFlags;
    00138         DWORD   m_dwCRC;
    00139         WORD    m_wLogicalID;
    00140         WORD    m_wTime;
    00141         WORD    m_wTotalSize;
    00142         WORD    m_wTable;
    00143 } cTransportHeader;
    00144
    00145 typedef struct
    00146 {
    00147         DWORD   m_dwSequence;
    00148         DWORD   m_dwObjectID;
    00149         WORD    m_wFragmentCount;
    00150         WORD    m_wFragmentLength;
    00151         WORD    m_wFragmentIndex;
    00152         WORD    m_wFragmentGroup;
    00153 } cFragmentHeader;
    00154 #pragma pack( pop )
    00155
    00156 #pragma pack( push, 1 )
    00157 typedef struct cLocation
    00158 {
    00159         //std::string Name;
    00160         DWORD   m_dwLandBlock;
    00161         float   m_flX;
    00162         float   m_flY;
    00163         float   m_flZ;
    00164         float   m_flA;
    00165         float   m_flB;
    00166         float   m_flC;
    00167         float   m_flW;
    00168
    00169         cLocation( )
    00170         {
    00171                 m_dwLandBlock   = 0x00;
    00172                 m_flA                   = 0.624711f;
    00173                 m_flB                   = 0.000000f;
    00174                 m_flC                   = 0.000000f;
    00175                 m_flW                   = 0.000000f;
    00176         }
    00177 } cLocation;
    00178 #pragma pack( pop )
    00179
    00180 #pragma pack( push, 1 )
    00181 typedef struct cVelocity
    00182 {
    00183         float m_dx, m_dy, m_dz;
    00184
    00185         cVelocity( )
    00186         {
    00187                 m_dx            = 0.0f;
    00188                 m_dy            = 0.0f;
    00189                 m_dz            = 0.0f;
    00190         }
    00191 } cVelocity;
    00192 #pragma pack( pop )
    00193
    00194 typedef struct{
    00195         BYTE bLow;
    00196         BYTE bOO;
    00197         BYTE bLo;
    00198         BYTE bHi;
    00199 } lb;
    00200
    00201 #pragma pack( push,1)
    00202 typedef struct sPaletteChange
    00203 {
    00204         WORD m_wNewPalette;
    00205         BYTE m_ucOffset;
    00206         BYTE m_ucLength;
    00207         sPaletteChange()
    00208         {
    00209                 m_wNewPalette   = 0x0;
    00210                 m_ucOffset              = 0x0;
    00211                 m_ucLength              = 0x0;
    00212         }
    00213 } sPaletteChange;
    00214 #pragma pack( pop)
    00215
    00216 #pragma pack( push,1)
    00217 typedef struct sTextureChange
    00218 {
    00219         BYTE m_bModelIndex;
    00220         WORD m_wOldTexture;
    00221         WORD m_wNewTexture;
    00222         sTextureChange()
    00223         {
    00224                 m_bModelIndex   = 0x0;
    00225                 m_wOldTexture   = 0x0;
    00226                 m_wNewTexture   = 0x0;
    00227         }
    00228 } sTextureChange;
    00229 #pragma pack( pop)
    00230
    00231 #pragma pack( push,1)
    00232 typedef struct sModelChange
    00233 {
    00234         BYTE m_bModelIndex;
    00235         WORD m_wNewModel;
    00236         sModelChange()
    00237         {
    00238                 m_bModelIndex   = 0x0;
    00239                 m_wNewModel             = 0x0;
    00240         }
    00241 } sModelChange;
    00242 #pragma pack( pop)
    00243
    00244 #pragma pack( push, 1 )
    00245 typedef struct cMonStats
    00246 {
    00247         DWORD   m_dwLevel;
    00248         DWORD   m_dwStr;
    00249         DWORD   m_dwEnd;
    00250         DWORD   m_dwQuick;
    00251         DWORD   m_dwCoord;
    00252         DWORD   m_dwFocus;
    00253         DWORD   m_dwSelf;
    00254         DWORD   m_dwSpecies;
    00255
    00256
    00257         cMonStats( )
    00258         {
    00259                 m_dwLevel       = 0x1;
    00260                 m_dwStr         = 0x0;
    00261                 m_dwEnd         = 0x0;
    00262                 m_dwQuick       = 0x0;
    00263                 m_dwCoord       = 0x0;
    00264                 m_dwFocus       = 0x0;
    00265                 m_dwSelf        = 0x0;
    00266                 m_dwSpecies     = 0x0;
    00267         }
    00268 } cMonStats;
    00269 #pragma pack( pop )
    00270
    00271 enum eColors
    00272 {
    00273         ColorGreen              = 1,
    00274         ColorWhite              = 2,
    00275         ColorYellow             = 3,
    00276         ColorBrown              = 4,
    00277         ColorMagenta    = 5,
    00278         ColorRed                = 6,
    00279         ColorGreen2             = 7,
    00280         ColorPink               = 8,
    00281         ColorLightPink  = 9,
    00282         ColorYellow2    = 10,
    00283         ColorBrown2             = 11,
    00284         ColorGrey               = 12,
    00285         ColorCyan               = 13,
    00286         ColorAquamarine = 14,
    00287         ColorRed2               = 15,
    00288         ColorGreen3             = 16,
    00289         ColorBlue               = 17,
    00290         ColorGreen4             = 18
    00291 };
    00292
    00293 struct cAvatarList
    00294 {
    00295         DWORD           m_dwGUID;
    00296         DWORD           m_dwOwnerID;
    00297         std::string     m_strName;
    00298 };
    00299
    00300 enum eAccessLevels
    00301 {
    00302         eDeveloper      = 0,
    00303         eAdmin          = 1,
    00304         eSentinel       = 2,
    00305         eAdvocate       = 3,
    00306         eStaff          = 4,
    00307         eUeber          = 5,
    00308         eVIP            = 6,
    00309         eNormal         = 7
    00310 };
    00311
    00312 struct ConfirmPanel
    00313 {
    00314         DWORD           m_dwSequence;
    00315         DWORD           m_dwType;
    00316         std::string     m_szText;
    00317
    00318         DWORD           m_dwSenderGUID;
    00319         DWORD           m_dwReceiptGUID;
    00320 };
    00321
    00322 struct cTeleTownList
    00323 {
    00324         std::string     m_teleString;
    00325         DWORD           m_dwLandblock;
    00326         FLOAT           m_flPosX;
    00327         FLOAT           m_flPosY;
    00328         FLOAT           m_flPosZ;
    00329         FLOAT           m_flOrientW;
    00330         FLOAT           m_flOrientX;
    00331         FLOAT           m_flOrientY;
    00332         FLOAT           m_flOrientZ;
    00333 };
    00334
    00335 struct cDungeonList
    00336 {
    00337         INT                     m_intID;
    00338         std::string     m_strName;
    00339         DWORD           m_dwLandblock;
    00340         FLOAT           m_flLocX;
    00341         FLOAT           m_flLocY;
    00342         FLOAT           m_flLocZ;
    00343         FLOAT           m_flHeading;
    00344 };
    00345
    00346 typedef struct cAnimates
    00347 {
    00348         WORD    m_wStance[10];
    00349         WORD    m_wAttack[10];
    00350         WORD    m_wIdle[10];
    00351         WORD    m_wReact[10];
    00352         WORD    m_wDeath;
    00353         WORD    m_wStand;
    00354         cAnimates( )
    00355         {
    00356                 for (int i = 0; i < 10; i++)
    00357                 {
    00358                         m_wStance[i] = 0x0000;
    00359                         m_wAttack[i] = 0x0000;
    00360                         m_wIdle[i]       = 0x0000;
    00361                         m_wReact[i]      = 0x0000;
    00362                 }
    00363                 m_wDeath        =       0x0011;
    00364                 m_wStand        =       0x0001;
    00365         }
    00366 } cAnimates;
    00367
    00369 // Define the Various Spell Structures
    00371 typedef struct cSpellBook
    00372 {
    00373         DWORD   dwSpell_ID;
    00374         float   flCharge;
    00375         DWORD   dwUnknownA;
    00376         DWORD   dwUnknownB;
    00377         WORD    wSpellType;
    00378
    00379         cSpellBook()
    00380         {
    00381                 dwSpell_ID = 0;
    00382                 flCharge = 1.0f;
    00383                 dwUnknownA = 0;
    00384                 dwUnknownB = 0;
    00385                 wSpellType = 0;
    00386         }
    00387 } cSpellBook;
    00388
    00389 typedef struct cSpellTab
    00390 {
    00391         DWORD   dwTabCount;
    00392         DWORD   dwSpell_ID[40];
    00393
    00394         cSpellTab()
    00395         {
    00396                 dwTabCount = 0;
    00397                 for(int i = 0;i < 41;i++)
    00398                 {
    00399                         dwSpell_ID[i] = 0;
    00400                 }
    00401         }
    00402 } cSpellTab;
    00403
    00404
    00405 // cs_CastMagic (Packet F7B1:004A - Group ??)
    00406 // - Cast Magic Spell
    00407 typedef struct cs_CastMagic
    00408 {
    00409         DWORD   dwWorldEvent;
    00410         DWORD   dwSequence;
    00411         DWORD   dwGameEvent;
    00412         float   flHeading;
    00413         DWORD   dwSpellID;
    00414 } cs_CastMagic;
    00415
    00417 // Define the Inventory Sturcture
    00419
    00420 typedef struct vInventory
    00421 {
    00422         DWORD   dwObjectGUID;
    00423         DWORD   dwIsContainer;
    00424         DWORD   fEquipped;
    00425         DWORD   dwItemModelNumber;
    00426         std::string     strName;
    00427
    00428         vInventory()
    00429         {
    00430                 dwObjectGUID = 0;
    00431                 dwIsContainer = 0;
    00432                 fEquipped = 0;
    00433                 dwItemModelNumber = 0;
    00434                 strName = " ";
    00435         }
    00436 } vInventory;
    00437
    00438 #pragma pack( push,1)
    00439 typedef struct sMonsters
    00440 {
    00441         DWORD           m_dwGUID;
    00442         DWORD           m_dwLastAttacker;
    00443         time_t          m_TimeNextAction;
    00444         DWORD           m_dwEvent;
    00445
    00446         sMonsters()
    00447         {
    00448                 m_dwGUID                        = 0x0L;
    00449                 m_dwLastAttacker        = 0x0L;
    00450                 time(&m_TimeNextAction + 30);
    00451                 m_dwEvent                       = 0x0L;
    00452         }
    00453 } sMonsters;
    00454 #pragma pack( pop)
    00455
    00456 #define Race 3
    00457 #define Gender 2
    00458 #define TexType 3
    00459 #define TexIndex 45
    00460
    00461 extern short    g_nCharPort;
    00462 extern short    g_nWorldPort;
    00463 extern HWND             g_hWndMain;
    00464 extern char             g_szLocalIP[16];
    00465 extern WORD             g_wAvatarTexturesList[Race][Gender][TexType][TexIndex];
    00466 extern WORD             g_wAvatarTexturesBaldList[Race][Gender][TexIndex];
    00467
    00468 void UpdateConsole( const char *szBuff );
    00469 long UpdateConsole( char *szBuff, long nErr );
    00470 void UpdateConsole( char *szMessage, ... );
    00471
    00472 #endif  // #ifndef __SHARED_H