|
Odamex
Setting the Standard in Multiplayer Doom
|
00001 // Emacs style mode select -*- C++ -*- 00002 //----------------------------------------------------------------------------- 00003 // 00004 // $Id: p_mobj.h 2117 2011-02-22 20:33:04Z mike $ 00005 // 00006 // Copyright (C) 1993-1996 by id Software, Inc. 00007 // Copyright (C) 2006-2010 by The Odamex Team. 00008 // 00009 // This program is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU General Public License 00011 // as published by the Free Software Foundation; either version 2 00012 // of the License, or (at your option) any later version. 00013 // 00014 // This program is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // DESCRIPTION: 00020 // Map Objects, MObj, definition and handling. 00021 // 00022 //----------------------------------------------------------------------------- 00023 00024 00025 #ifndef __PMOBJ_H__ 00026 #define __PMOBJ_H__ 00027 00028 #define REMOVECORPSESTIC TICRATE*80 00029 00030 //----------------------------------------------------------------------------- 00031 // 00032 // denis - superior NetIDHandler 00033 // 00034 // Very simple, very fast. 00035 // Does not iterate when releasing a netid. 00036 // Does not iterate when obtaining a netid unless all pooled ids are taken. 00037 // (in which case does one allocation and does not iterate more than 00038 // MEMPOOLSIZE times) 00039 // Only downside is that it won't detect double-releasing, but shouldn't be 00040 // a problem. 00041 // 00042 // Thanks to [Dash|RD] for noticing the efficiency problem, hard work on other 00043 // versions of this class and giving me this great idea. 00044 // 00045 //----------------------------------------------------------------------------- 00046 00047 #define MAX_NETID 0xFFFF 00048 00049 class NetIDHandler 00050 { 00051 private: 00052 00053 int *allocation; 00054 00055 size_t NumAllocated; 00056 size_t NumUsed; 00057 00058 const size_t ChunkSize; 00059 00060 public: 00061 00062 NetIDHandler(size_t chunk_size = 256) 00063 : allocation(0), NumAllocated(0), NumUsed(0), ChunkSize(chunk_size) 00064 {} 00065 00066 ~NetIDHandler() 00067 { 00068 M_Free(allocation); 00069 } 00070 00071 int ObtainNetID() 00072 { 00073 if(NumUsed >= NumAllocated) 00074 { 00075 if(NumAllocated >= MAX_NETID - 1) 00076 I_Error("Exceeded maximum number of netids"); 00077 00078 int OldAllocated = NumAllocated; 00079 NumAllocated += ChunkSize; 00080 00081 if(NumAllocated >= MAX_NETID - 1) 00082 NumAllocated = MAX_NETID - 1; 00083 00084 allocation = (int *)Realloc(allocation, NumAllocated*sizeof(int)); 00085 00086 for(size_t i = OldAllocated; i < NumAllocated; i++) 00087 allocation[i] = i + 1; 00088 } 00089 00090 return allocation[NumUsed++]; 00091 } 00092 00093 void ReleaseNetID(int NetID) 00094 { 00095 if(!NumUsed || !NetID) 00096 I_Error("Released a non-existant netid %d", NetID); 00097 00098 allocation[--NumUsed] = NetID; 00099 } 00100 }; 00101 00102 extern NetIDHandler ServerNetID; 00103 00104 bool P_SetMobjState(AActor *mobj, statenum_t state); 00105 void P_XYMovement(AActor *mo); 00106 void P_ZMovement(AActor *mo); 00107 void PlayerLandedOnThing(AActor *mo, AActor *onmobj); // [CG] Used to be 'static' 00108 void P_NightmareRespawn(AActor *mo); 00109 void P_SpawnPuff(fixed_t x, fixed_t y, fixed_t z, angle_t dir, int updown); 00110 void P_SpawnBlood(fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage); 00111 bool P_CheckMissileSpawn(AActor* th); 00112 AActor* P_SpawnMissile(AActor *source, AActor *dest, mobjtype_t type); 00113 void P_SpawnPlayerMissile(AActor *source, mobjtype_t type); 00114 00115 // [ML] From EE 00116 int P_ThingInfoHeight(mobjinfo_t *mi); 00117 00118 #endif 00119