- Timestamp:
- 06/01/04 19:34:12 (21 years ago)
- Location:
- ps/trunk/source
- Files:
-
- 41 edited
-
graphics/MapReader.cpp (modified) (2 diffs)
-
graphics/MapWriter.cpp (modified) (2 diffs)
-
graphics/Terrain.cpp (modified) (2 diffs)
-
graphics/Terrain.h (modified) (1 diff)
-
gui/CGUI.h (modified) (1 diff)
-
gui/GUItext.cpp (modified) (5 diffs)
-
gui/IGUIScrollBar.h (modified) (1 diff)
-
lib/detect.h (modified) (2 diffs)
-
lib/lib.cpp (modified) (2 diffs)
-
lib/lib.h (modified) (4 diffs)
-
lib/misc.cpp (modified) (1 diff)
-
lib/misc.h (modified) (1 diff)
-
lib/precompiled.h (modified) (3 diffs)
-
lib/res/file.cpp (modified) (2 diffs)
-
lib/res/font.cpp (modified) (2 diffs)
-
lib/res/h_mgr.cpp (modified) (3 diffs)
-
lib/res/h_mgr.h (modified) (2 diffs)
-
lib/res/mem.cpp (modified) (5 diffs)
-
lib/res/mem.h (modified) (1 diff)
-
lib/res/tex.cpp (modified) (9 diffs)
-
lib/res/tex.h (modified) (2 diffs)
-
lib/res/vfs.cpp (modified) (26 diffs)
-
lib/sysdep/win/waio.cpp (modified) (1 diff)
-
lib/sysdep/win/wdetect.cpp (modified) (1 diff)
-
lib/sysdep/win/wposix.cpp (modified) (7 diffs)
-
lib/sysdep/win/wposix.h (modified) (3 diffs)
-
lib/sysdep/win/wsdl.cpp (modified) (1 diff)
-
lib/sysdep/win/wsock.cpp (modified) (1 diff)
-
lib/sysdep/win/wsock.h (modified) (4 diffs)
-
lib/sysdep/x.cpp (modified) (2 diffs)
-
lib/timer.cpp (modified) (1 diff)
-
lib/types.h (modified) (2 diffs)
-
main.cpp (modified) (7 diffs)
-
ps/Config.h (modified) (1 diff)
-
ps/Overlay.cpp (modified) (4 diffs)
-
ps/Overlay.h (modified) (8 diffs)
-
ps/Singleton.h (modified) (1 diff)
-
ps/ThreadUtil.h (modified) (1 diff)
-
renderer/PatchRData.cpp (modified) (1 diff)
-
simulation/EntityProperties.cpp (modified) (1 diff)
-
terrain/terrainMain.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/graphics/MapReader.cpp
r316 r334 1 // switch off warnings before including stl files 2 #pragma warning(disable : 4786) // identifier truncated to 255 chars 1 #include "precompiled.h" 3 2 4 3 #include "Types.h" … … 17 16 extern CLightEnv g_LightEnv; 18 17 19 #include <set>20 #include <stdio.h>21 18 22 19 -
ps/trunk/source/graphics/MapWriter.cpp
r306 r334 1 // switch off warnings before including stl files 2 #pragma warning(disable : 4786) // identifier truncated to 255 chars 1 #include "precompiled.h" 3 2 4 3 #include "Types.h" … … 13 12 extern CTerrain g_Terrain; 14 13 extern CLightEnv g_LightEnv; 15 16 #include <set>17 #include <stdio.h>18 14 19 15 /////////////////////////////////////////////////////////////////////////////////////////////////// -
ps/trunk/source/graphics/Terrain.cpp
r306 r334 129 129 // GetPatch: return the patch at (x,z) in patch space, or null if the patch is 130 130 // out of bounds 131 CPatch* CTerrain::GetPatch(int32 x,int32z)132 { 133 if (x<0 || x>=int32 (m_MapSizePatches)) return 0;134 if (z<0 || z>=int32 (m_MapSizePatches)) return 0;131 CPatch* CTerrain::GetPatch(int32_t x,int32_t z) 132 { 133 if (x<0 || x>=int32_t(m_MapSizePatches)) return 0; 134 if (z<0 || z>=int32_t(m_MapSizePatches)) return 0; 135 135 return &m_Patches[(z*m_MapSizePatches)+x]; 136 136 } … … 140 140 // GetPatch: return the tile at (x,z) in tile space, or null if the tile is out 141 141 // of bounds 142 CMiniPatch* CTerrain::GetTile(int32 x,int32z)143 { 144 if (x<0 || x>=int32 (m_MapSize)-1) return 0;145 if (z<0 || z>=int32 (m_MapSize)-1) return 0;142 CMiniPatch* CTerrain::GetTile(int32_t x,int32_t z) 143 { 144 if (x<0 || x>=int32_t(m_MapSize)-1) return 0; 145 if (z<0 || z>=int32_t(m_MapSize)-1) return 0; 146 146 147 147 CPatch* patch=GetPatch(x/16,z/16); -
ps/trunk/source/graphics/Terrain.h
r306 r334 52 52 // get patch at given coordinates, expressed in patch-space; return 0 if 53 53 // coordinates represent patch off the edge of the map 54 CPatch* GetPatch(int32 x,int32z);54 CPatch* GetPatch(int32_t x,int32_t z); 55 55 // get tile at given coordinates, expressed in tile-space; return 0 if 56 56 // coordinates represent tile off the edge of the map 57 CMiniPatch* GetTile(int32 x,int32z);57 CMiniPatch* GetTile(int32_t x,int32_t z); 58 58 59 59 // calculate the position of a given vertex -
ps/trunk/source/gui/CGUI.h
r290 r334 419 419 /// Used when reading in XML files 420 420 // TODO Gee: Used? 421 int16 m_Errors;421 int16_t m_Errors; 422 422 423 423 //@} -
ps/trunk/source/gui/GUItext.cpp
r291 r334 217 217 Parser.InputTaskType("end", "/$ident"); 218 218 219 _long position = 0;220 _long from=0; // the position in the raw string where the last tag ended221 _long from_nonraw=0; // like from only in position of the REAL string, with tags.222 _long curpos = 0;219 long position = 0; 220 long from=0; // the position in the raw string where the last tag ended 221 long from_nonraw=0; // like from only in position of the REAL string, with tags. 222 long curpos = 0; 223 223 224 224 // Current Text Chunk … … 247 247 // First check if there is another TagStart before a TagEnd, 248 248 // in that case it's just a regular TagStart and we can continue. 249 _long pos_left = str.Find(curpos+1, TagStart);250 _long pos_right = str.Find(curpos+1, TagEnd);249 long pos_left = str.Find(curpos+1, TagStart); 250 long pos_right = str.Find(curpos+1, TagEnd); 251 251 252 252 if (pos_right == -1) … … 429 429 { 430 430 // Find the next word-delimiter. 431 _long dl = m_RawString.Find(position, ' ');431 long dl = m_RawString.Find(position, ' '); 432 432 433 433 if (dl == -1) … … 442 442 { 443 443 // Find the next word-delimiter. 444 _long dl = m_RawString.Find(position, '-');444 long dl = m_RawString.Find(position, '-'); 445 445 446 446 if (dl == -1) … … 455 455 { 456 456 // Find the next word-delimiter. 457 _long dl = m_RawString.Find(position, '\n');457 long dl = m_RawString.Find(position, '\n'); 458 458 459 459 if (dl == -1) -
ps/trunk/source/gui/IGUIScrollBar.h
r290 r334 229 229 * @param width Width 230 230 */ 231 void SetWidth(const int16 &width) { m_Width = width; }231 void SetWidth(const int16_t &width) { m_Width = width; } 232 232 233 233 /** -
ps/trunk/source/lib/detect.h
r266 r334 20 20 #define __DETECT_H__ 21 21 22 #include " misc.h"22 #include "lib.h" 23 23 24 24 #ifdef __cplusplus … … 29 29 // useful for choosing a video mode. not called by detect(). 30 30 // if we fail, outputs are unchanged (assumed initialized to defaults) 31 extern int get_cur_ resolution(int& xres, int& yres);31 extern int get_cur_vmode(int* xres, int* yres, int* bpp, int* freq); 32 32 33 33 // useful for determining aspect ratio. not called by detect(). -
ps/trunk/source/lib/lib.cpp
r277 r334 37 37 // so we may have shut down something important already). 38 38 39 const int MAX_EXIT_FUNCS = 64;39 static const int MAX_EXIT_FUNCS = 32; 40 40 41 41 … … 112 112 atexit(call_exit_funcs); 113 113 } 114 115 116 117 118 119 120 121 122 123 124 // FNV1-A hash - good for strings. 125 // if len = 0 (default), treat buf as a C-string; 126 // otherwise, hash <len> bytes of buf. 127 u32 fnv_hash(const void* buf, const size_t len) 128 { 129 u32 h = 0x811c9dc5; 130 // give distinct values for different length 0 buffers. 131 // value taken from FNV; it has no special significance. 132 133 const u8* p = (const u8*)buf; 134 135 // expected case: string 136 if(!len) 137 { 138 while(*p) 139 { 140 h ^= *p++; 141 h *= 0x01000193; 142 } 143 } 144 else 145 { 146 size_t bytes_left = len; 147 while(bytes_left != 0) 148 { 149 h ^= *p++; 150 h *= 0x01000193; 151 152 bytes_left--; 153 } 154 } 155 156 return h; 157 } 158 159 160 // FNV1-A hash - good for strings. 161 // if len = 0 (default), treat buf as a C-string; 162 // otherwise, hash <len> bytes of buf. 163 u64 fnv_hash64(const void* buf, const size_t len) 164 { 165 u64 h = 0xCBF29CE484222325ull; 166 // give distinct values for different length 0 buffers. 167 // value taken from FNV; it has no special significance. 168 169 const u8* p = (const u8*)buf; 170 171 // expected case: string 172 if(!len) 173 { 174 while(*p) 175 { 176 h ^= *p++; 177 h *= 0x100000001B3; 178 } 179 } 180 else 181 { 182 size_t bytes_left = len; 183 while(bytes_left != 0) 184 { 185 h ^= *p++; 186 h *= 0x100000001B3; 187 188 bytes_left--; 189 } 190 } 191 192 return h; 193 } 194 195 196 197 198 bool is_pow2(const long n) 199 { 200 return (n != 0) && !(n & (n-1)); 201 } 202 203 204 // return -1 if not an integral power of 2, 205 // otherwise the base2 logarithm 206 207 int ilog2(const int n) 208 { 209 #ifdef _M_IX86 210 211 __asm 212 { 213 mov ecx, [n] 214 or eax, -1 // return value 215 lea edx, [ecx-1] 216 test ecx, edx // power of 2? 217 jnz $ret 218 bsf eax, ecx 219 $ret: 220 mov [n], eax 221 } 222 223 return n; 224 225 #else 226 227 if(n || n & (n-1)) 228 return -1; 229 230 int i = 1, j = 0; 231 for(; i != n; i += i, j++) 232 ; 233 return j; 234 235 #endif 236 } 237 238 239 int ilog2(const float x) 240 { 241 u32 i = (u32&)x; 242 u32 exp = (i >> 23) & 0xff; 243 return (int)exp - 127; 244 } 245 246 247 uintptr_t round_up(const uintptr_t n, const uintptr_t multiple) 248 { 249 assert(multiple != 0); 250 const uintptr_t padded = n + multiple-1; 251 const uintptr_t remainder = padded % multiple; 252 const uintptr_t result = padded - remainder; 253 assert(n <= result && result < n+multiple); 254 return result; 255 } 256 257 258 u16 addusw(u16 x, u16 y) 259 { 260 u32 t = x; 261 return (u16)MIN(t+y, 0xffff); 262 } 263 264 265 u16 subusw(u16 x, u16 y) 266 { 267 long t = x; 268 return (u16)(MAX(t-y, 0)); 269 } 270 271 272 // provide fminf for non-C99 compilers 273 #ifndef HAVE_C99 274 275 float fminf(float a, float b) 276 { 277 return (a < b)? a : b; 278 } 279 280 #endif 281 282 283 284 long round(double x) 285 { 286 return (long)(x + 0.5); 287 } 288 289 290 // input in [0, 1); convert to u8 range 291 u8 fp_to_u8(double in) 292 { 293 if(!(0 <= in && in < 1.0)) 294 { 295 debug_warn("clampf not in [0,1)"); 296 return 255; 297 } 298 299 int l = round(in * 255.0); 300 assert((unsigned int)l <= 255); 301 return (u8)l; 302 } 303 304 305 // input in [0, 1); convert to u16 range 306 u16 fp_to_u16(double in) 307 { 308 if(!(0 <= in && in < 1.0)) 309 { 310 debug_warn("clampf not in [0,1)"); 311 return 65535; 312 } 313 314 long l = round(in * 65535.0); 315 assert((unsigned long)l <= 65535); 316 return (u16)l; 317 } 318 319 320 321 // big endian! 322 void base32(const int len, const u8* in, u8* out) 323 { 324 int bits = 0; 325 u32 pool = 0; 326 327 static u8 tbl[33] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; 328 329 for(int i = 0; i < len; i++) 330 { 331 if(bits < 5) 332 { 333 pool <<= 8; 334 pool |= *in++; 335 bits += 8; 336 } 337 338 bits -= 5; 339 int c = (pool >> bits) & 31; 340 *out++ = tbl[c]; 341 } 342 } 343 /* 344 #ifndef _WIN32 345 346 char *_itoa(int value, char *out, int radix) 347 { 348 return _ltoa(value, out, radix); 349 } 350 351 static const char digits[]="0123456789abcdef"; 352 353 char *_ultoa(unsigned long int value, char *out, int radix) 354 { 355 char buf[21]; 356 char *p=buf+21; 357 358 do 359 { 360 *(--p)=digits[value % radix]; 361 value /= radix; 362 } 363 while (value); 364 365 memcpy(out, p, (buf+21)-p); 366 out[(buf+21)-p]=0; 367 return out; 368 } 369 370 char *_ltoa(long val, char *out, int radix) 371 { 372 char buf[21]; 373 char *p=buf+21; 374 bool sign=val < 0; 375 if (sign) val=-val; 376 377 do 378 { 379 *(--p)=digits[val % radix]; 380 val /= radix; 381 } 382 while (val); 383 384 if (sign) *(--p) = '-'; 385 386 memcpy(out, p, (buf+21)-p); 387 out[(buf+21)-p]=0; 388 return out; 389 } 390 391 #endif 392 */ 393 394 -
ps/trunk/source/lib/lib.h
r293 r334 21 21 22 22 #include "config.h" 23 24 #include "misc.h" 23 #include "posix.h" 25 24 #include "types.h" 26 25 27 26 #include "sysdep/sysdep.h" 28 29 30 // yikes! avoid template warning spew on VC631 #if _MSC_VER <= 120032 #pragma warning(disable:4786)33 #endif34 27 35 28 … … 46 39 47 40 41 48 42 #define STMT(STMT_code__) do { STMT_code__; } while(0) 49 43 … … 51 45 #define ONCE(ONCE_code__)\ 52 46 STMT(\ 53 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;\ 47 /* static pthread_mutex_t ONCE_mutex__ = PTHREAD_MUTEX_INITIALIZER;\ 48 if(pthread_mutex_trylock(&ONCE_mutex__) == 0)\*/\ 54 49 static bool ONCE_done__ = false;\ 55 if( pthread_mutex_trylock(&(mutex)) == 0 &&!ONCE_done__)\50 if(!ONCE_done__)\ 56 51 {\ 57 52 ONCE_done__ = true;\ … … 192 187 extern int atexit2(void* func); 193 188 194 #include "posix.h" 189 190 191 192 193 194 195 196 197 198 199 // FNV1-A hash - good for strings. 200 // if len = 0 (default), treat buf as a C-string; 201 // otherwise, hash <len> bytes of buf. 202 extern u32 fnv_hash(const void* buf, const size_t len = 0); 203 extern u64 fnv_hash64(const void* buf, const size_t len); 204 205 // hash (currently FNV) of a filename 206 typedef u32 FnHash; 207 208 209 #ifndef min 210 inline int min(int a, int b) 211 { 212 return (a < b)? a : b; 213 } 214 215 inline int max(int a, int b) 216 { 217 return (a > b)? a : b; 218 } 219 #endif 220 221 extern u16 addusw(u16 x, u16 y); 222 extern u16 subusw(u16 x, u16 y); 223 224 225 226 227 static inline u16 read_le16(const void* p) 228 { 229 #ifdef BIG_ENDIAN 230 const u8* _p = (const u8*)p; 231 return (u16)_p[0] | (u16)_p[1] << 8; 232 #else 233 return *(u16*)p; 234 #endif 235 } 236 237 238 static inline u32 read_le32(const void* p) 239 { 240 #ifdef BIG_ENDIAN 241 u32 t = 0; 242 for(int i = 0; i < 4; i++) 243 { 244 t <<= 8; 245 t |= *((const u8*)p)++; 246 } 247 return t; 248 #else 249 return *(u32*)p; 250 #endif 251 } 252 253 254 extern bool is_pow2(long n); 255 256 257 // return -1 if not an integral power of 2, 258 // otherwise the base2 logarithm 259 extern int ilog2(const int n); 260 261 262 extern uintptr_t round_up(uintptr_t val, uintptr_t multiple); 263 264 265 // provide fminf for non-C99 compilers 266 #ifndef HAVE_C99 267 extern float fminf(float, float); 268 #endif 269 270 271 272 extern long round(double); 273 extern u16 fp_to_u16(double in); 274 275 // big endian! 276 extern void base32(const int len, const u8* in, u8* out); 277 278 #ifndef _WIN32 279 280 char *_itoa(int, char *, int radix); 281 char *_ultoa(unsigned long int, char*, int radix); 282 char *_ltoa(long, char *, int radix); 283 284 #endif 285 286 287 195 288 196 289 -
ps/trunk/source/lib/misc.cpp
r293 r334 22 22 #include "misc.h" 23 23 24 25 // FNV1-A hash - good for strings.26 // if len = 0 (default), treat buf as a C-string;27 // otherwise, hash <len> bytes of buf.28 u32 fnv_hash(const void* buf, const size_t len)29 {30 u32 h = 0x811c9dc5;31 // give distinct values for different length 0 buffers.32 // value taken from FNV; it has no special significance.33 34 const u8* p = (const u8*)buf;35 36 // expected case: string37 if(!len)38 {39 while(*p)40 {41 h ^= *p++;42 h *= 0x01000193;43 }44 }45 else46 {47 size_t bytes_left = len;48 while(bytes_left != 0)49 {50 h ^= *p++;51 h *= 0x01000193;52 53 bytes_left--;54 }55 }56 57 return h;58 }59 60 61 // FNV1-A hash - good for strings.62 // if len = 0 (default), treat buf as a C-string;63 // otherwise, hash <len> bytes of buf.64 u64 fnv_hash64(const void* buf, const size_t len)65 {66 u64 h = 0xCBF29CE484222325ull;67 // give distinct values for different length 0 buffers.68 // value taken from FNV; it has no special significance.69 70 const u8* p = (const u8*)buf;71 72 // expected case: string73 if(!len)74 {75 while(*p)76 {77 h ^= *p++;78 h *= 0x100000001B3;79 }80 }81 else82 {83 size_t bytes_left = len;84 while(bytes_left != 0)85 {86 h ^= *p++;87 h *= 0x100000001B3;88 89 bytes_left--;90 }91 }92 93 return h;94 }95 96 97 98 99 bool is_pow2(const long n)100 {101 return (n != 0) && !(n & (n-1));102 }103 104 105 // return -1 if not an integral power of 2,106 // otherwise the base2 logarithm107 108 int ilog2(const int n)109 {110 #ifdef _M_IX86111 112 __asm113 {114 mov ecx, [n]115 or eax, -1 // return value116 lea edx, [ecx-1]117 test ecx, edx // power of 2?118 jnz $ret119 bsf eax, ecx120 $ret:121 mov [n], eax122 }123 124 return n;125 126 #else127 128 if(n || n & (n-1))129 return -1;130 131 int i = 1, j = 0;132 for(; i != n; i += i, j++)133 ;134 return j;135 136 #endif137 }138 139 140 int ilog2(const float x)141 {142 u32 i = (u32&)x;143 u32 exp = (i >> 23) & 0xff;144 return (int)exp - 127;145 }146 147 148 uintptr_t round_up(uintptr_t val, uintptr_t multiple)149 {150 val += multiple-1;151 val -= val % multiple;152 return val;153 }154 155 156 u16 addusw(u16 x, u16 y)157 {158 u32 t = x;159 return (u16)MIN(t+y, 0xffff);160 }161 162 163 u16 subusw(u16 x, u16 y)164 {165 long t = x;166 return (u16)(MAX(t-y, 0));167 }168 169 170 // provide fminf for non-C99 compilers171 #ifndef HAVE_C99172 173 float fminf(float a, float b)174 {175 return (a < b)? a : b;176 }177 178 #endif179 180 181 182 long round(double x)183 {184 return (long)(x + 0.5);185 }186 187 188 // input in [0, 1); convert to u8 range189 u8 fp_to_u8(double in)190 {191 if(!(0 <= in && in < 1.0))192 {193 debug_warn("clampf not in [0,1)");194 return 255;195 }196 197 int l = round(in * 255.0);198 assert((unsigned int)l <= 255);199 return (u8)l;200 }201 202 203 // input in [0, 1); convert to u16 range204 u16 fp_to_u16(double in)205 {206 if(!(0 <= in && in < 1.0))207 {208 debug_warn("clampf not in [0,1)");209 return 65535;210 }211 212 long l = round(in * 65535.0);213 assert((unsigned long)l <= 65535);214 return (u16)l;215 }216 217 218 219 // big endian!220 void base32(const int len, const u8* in, u8* out)221 {222 int bits = 0;223 u32 pool = 0;224 225 static u8 tbl[33] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";226 227 for(int i = 0; i < len; i++)228 {229 if(bits < 5)230 {231 pool <<= 8;232 pool |= *in++;233 bits += 8;234 }235 236 bits -= 5;237 int c = (pool >> bits) & 31;238 *out++ = tbl[c];239 }240 }241 /*242 #ifndef _WIN32243 244 char *_itoa(int value, char *out, int radix)245 {246 return _ltoa(value, out, radix);247 }248 249 static const char digits[]="0123456789abcdef";250 251 char *_ultoa(unsigned long int value, char *out, int radix)252 {253 char buf[21];254 char *p=buf+21;255 256 do257 {258 *(--p)=digits[value % radix];259 value /= radix;260 }261 while (value);262 263 memcpy(out, p, (buf+21)-p);264 out[(buf+21)-p]=0;265 return out;266 }267 268 char *_ltoa(long val, char *out, int radix)269 {270 char buf[21];271 char *p=buf+21;272 bool sign=val < 0;273 if (sign) val=-val;274 275 do276 {277 *(--p)=digits[val % radix];278 val /= radix;279 }280 while (val);281 282 if (sign) *(--p) = '-';283 284 memcpy(out, p, (buf+21)-p);285 out[(buf+21)-p]=0;286 return out;287 }288 289 #endif290 */291 -
ps/trunk/source/lib/misc.h
r293 r334 20 20 #define __MISC_H__ 21 21 22 #include "types.h"23 #include "config.h"24 25 #ifdef __cplusplus26 extern "C" {27 #endif28 29 30 // FNV1-A hash - good for strings.31 // if len = 0 (default), treat buf as a C-string;32 // otherwise, hash <len> bytes of buf.33 extern u32 fnv_hash(const void* buf, const size_t len = 0);34 extern u64 fnv_hash64(const void* buf, const size_t len);35 36 // hash (currently FNV) of a filename37 typedef u32 FnHash;38 39 40 #ifndef min41 inline int min(int a, int b)42 {43 return (a < b)? a : b;44 }45 46 inline int max(int a, int b)47 {48 return (a > b)? a : b;49 }50 #endif51 52 extern u16 addusw(u16 x, u16 y);53 extern u16 subusw(u16 x, u16 y);54 55 56 57 58 static inline u16 read_le16(const void* p)59 {60 #ifdef BIG_ENDIAN61 const u8* _p = (const u8*)p;62 return (u16)_p[0] | (u16)_p[1] << 8;63 #else64 return *(u16*)p;65 #endif66 }67 68 69 static inline u32 read_le32(const void* p)70 {71 #ifdef BIG_ENDIAN72 u32 t = 0;73 for(int i = 0; i < 4; i++)74 {75 t <<= 8;76 t |= *((const u8*)p)++;77 }78 return t;79 #else80 return *(u32*)p;81 #endif82 }83 84 85 extern bool is_pow2(long n);86 87 88 // return -1 if not an integral power of 2,89 // otherwise the base2 logarithm90 extern int ilog2(const int n);91 92 93 extern uintptr_t round_up(uintptr_t val, uintptr_t multiple);94 95 96 // provide fminf for non-C99 compilers97 #ifndef HAVE_C9998 extern float fminf(float, float);99 #endif100 101 102 103 extern long round(double);104 extern u16 fp_to_u16(double in);105 106 // big endian!107 extern void base32(const int len, const u8* in, u8* out);108 109 #ifndef _WIN32110 111 char *_itoa(int, char *, int radix);112 char *_ultoa(unsigned long int, char*, int radix);113 char *_ltoa(long, char *, int radix);114 115 #endif116 117 118 22 119 23 -
ps/trunk/source/lib/precompiled.h
r258 r334 1 1 #include <string.h> 2 2 #include <stdlib.h> 3 4 3 #include <stdio.h> 5 4 … … 9 8 #include <limits.h> 10 9 #include <time.h> 11 12 10 #include <wchar.h> 13 14 11 15 12 #include <list> … … 18 15 #include <stack> 19 16 #include <string> 17 #include <set> 18 #include <deque> 20 19 21 20 #include <functional> 22 21 #include <algorithm> 23 24 22 #include <numeric> 25 23 26 #pragma warning(disable:4996) 24 #ifdef _MSC_VER 25 #pragma warning(disable:4996) // function is deprecated 26 #pragma warning(disable:4786) // identifier truncated to 255 chars 27 #endif -
ps/trunk/source/lib/res/file.cpp
r276 r334 754 754 755 755 // free all allocated IOs, so they aren't seen as resource leaks. 756 static void io_ cleanup(void)756 static void io_shutdown(void) 757 757 { 758 758 std::for_each(all_ios.begin(), all_ios.end(), Free()); … … 762 762 static Handle io_alloc() 763 763 { 764 ONCE(atexit(io_ cleanup));764 ONCE(atexit(io_shutdown)); 765 765 /* 766 766 // grab from freelist -
ps/trunk/source/lib/res/font.cpp
r266 r334 22 22 23 23 #include "lib.h" 24 #include "mem.h" 25 #include "font.h" 26 #include "h_mgr.h" 27 #include "vfs.h" 28 #include "tex.h" 24 #include "res.h" 29 25 #include "ogl.h" 30 #include "misc.h"31 26 32 27 /* … … 109 104 struct Font 110 105 { 111 Handle ht; 106 Handle ht; // handle to font texture 112 107 uint list_base; 113 108 }; -
ps/trunk/source/lib/res/h_mgr.cpp
r323 r334 20 20 21 21 #include "lib.h" 22 #include "misc.h"23 22 #include "h_mgr.h" 24 23 #include "mem.h" … … 236 235 237 236 238 static void cleanup(void)237 void h_mgr_shutdown(void) 239 238 { 240 239 // close open handles … … 373 372 Handle h_alloc(H_Type type, const char* fn, uint flags, ...) 374 373 { 375 ONCE(atexit2( cleanup));374 ONCE(atexit2(h_mgr_shutdown)); 376 375 377 376 Handle err; -
ps/trunk/source/lib/res/h_mgr.h
r292 r334 20 20 #define H_MGR_H__ 21 21 22 #ifdef __cplusplus23 extern "C" {24 #endif25 22 26 23 #include <stdarg.h> // type init routines get va_list of args 27 24 28 #include " ../types.h"25 #include "lib.h" 29 26 30 27 31 28 // handle type (for 'type safety' - can't use a texture handle as a sound) 29 30 32 31 // 33 32 // rationale: we could use the destructor passed to h_alloc to identify … … 185 184 extern int res_cur_scope; 186 185 187 #ifdef __cplusplus188 }189 #endif190 191 186 192 187 #endif // #ifndef H_MGR_H__ -
ps/trunk/source/lib/res/mem.cpp
r227 r334 4 4 5 5 #include "lib.h" 6 #include "types.h" 7 #include "mem.h" 6 #include "res.h" 8 7 #include "h_mgr.h" 9 #include "misc.h"10 11 #include <map>12 13 14 8 15 9 … … 24 18 25 19 26 static void* heap_alloc(const size_t size, const int align, uintptr_t& ctx, MEM_DTOR& dtor)20 static void* heap_alloc(const size_t size, const size_t align, uintptr_t& ctx, MEM_DTOR& dtor) 27 21 { 28 22 u8* org_p = (u8*)malloc(size+align-1); … … 56 50 57 51 58 static void* pool_alloc(const size_t size, const uint align, uintptr_t& ctx, MEM_DTOR& dtor)52 static void* pool_alloc(const size_t size, const size_t align, uintptr_t& ctx, MEM_DTOR& dtor) 59 53 { 60 54 if(!pool) … … 209 203 // we've already allocated that pointer - returns its handle 210 204 Handle hm = find_alloc(p); 211 if(hm )205 if(hm > 0) 212 206 return hm; 213 207 … … 234 228 235 229 236 void* mem_alloc(size_t size, const uint align, uint flags, Handle* phm)230 void* mem_alloc(size_t size, const size_t align, uint flags, Handle* phm) 237 231 { 238 232 if(phm) -
ps/trunk/source/lib/res/mem.h
r167 r334 20 20 }; 21 21 22 extern void* mem_alloc(size_t size, uint align = 1, uint flags = 0, Handle* ph = 0);22 extern void* mem_alloc(size_t size, size_t align = 1, uint flags = 0, Handle* ph = 0); 23 23 24 24 #define mem_free(p) mem_free_p((void*&)p) -
ps/trunk/source/lib/res/tex.cpp
r322 r334 22 22 23 23 #include "lib.h" 24 #include "vfs.h" 25 #include "tex.h" 26 #include "mem.h" 24 #include "res.h" 27 25 #include "ogl.h" 28 #include "h_mgr.h"29 #include "misc.h"30 26 31 27 … … 38 34 #endif 39 35 40 36 // libpng includes windows.h - prevent that, and define what it needs. 41 37 #define _WINDOWS_ 42 38 #define WINAPI __stdcall … … 44 40 45 41 #ifndef NO_PNG 46 #include <libpng10/png.h> 47 #pragma comment(lib, "libpng10.lib") 42 # include <libpng10/png.h> 43 # ifdef _MSC_VER 44 # pragma comment(lib, "libpng10.lib") 45 # endif 48 46 #endif 49 47 … … 470 468 471 469 472 static void png_read_fn(png_struct* png_ptr, u8* data,png_size_t length)470 static void png_read_fn(png_struct* const png_ptr, u8* const data, const png_size_t length) 473 471 { 474 472 MemRange* const mr = (MemRange*)png_ptr->io_ptr; … … 478 476 memcpy(data, mr->p, length); 479 477 mr->p += length; 480 mr->size -= length; // > 0 due to test above478 mr->size -= length; // >= 0 due to test above 481 479 } 482 480 … … 513 511 } 514 512 515 u8** rows; 513 const u8** rows; 514 // freed in cleanup code; need scoping on VC6 due to goto 516 515 517 516 { … … 525 524 png_get_IHDR(png_ptr, info_ptr, &w, &h, &prec, &color_type, 0, 0, 0); 526 525 527 size_t pitch = png_get_rowbytes(png_ptr, info_ptr);526 const size_t pitch = png_get_rowbytes(png_ptr, info_ptr); 528 527 529 528 const u32 fmts[8] = { 0, ~0, GL_RGB, ~0, GL_LUMINANCE_ALPHA, ~0, GL_RGBA, ~0 }; … … 543 542 544 543 // allocate mem for image - rows point into buffer (sequential) 545 rows = ( u8**)malloc((h+1)*sizeof(void*));544 rows = (const u8**)malloc(h*sizeof(void*)); 546 545 if(!rows) 547 546 goto fail; 548 size_t img_size = pitch * (h+1);547 const size_t img_size = pitch * h; 549 548 Handle img_hm; 550 u8* img = (u8*)mem_alloc(img_size, 64*KB, 0, &img_hm);549 const u8* img = (const u8*)mem_alloc(img_size, 64*KB, 0, &img_hm); 551 550 if(!img) 552 551 goto fail; 553 u8* pos = img;554 for( u32 i = 0; i < h+1; i++)552 const u8* pos = img; 553 for(size_t i = 0; i < h; i++) 555 554 { 556 555 rows[i] = pos; … … 558 557 } 559 558 560 png_read_image(png_ptr, rows);559 png_read_image(png_ptr, (png_bytepp)rows); 561 560 562 561 png_read_end(png_ptr, info_ptr); 563 564 562 565 563 mem_free_h(t->hm); -
ps/trunk/source/lib/res/tex.h
r322 r334 20 20 #define __TEX_H__ 21 21 22 #include "types.h"23 22 #include "h_mgr.h" 24 #include "misc.h"25 23 26 24 // load and return a handle to the texture given in <fn>. … … 33 31 extern int tex_info(Handle ht, int* w, int* h, int *fmt, int *bpp, void** p); 34 32 35 extern int tex_filter; // GL values; default: GL_LINEAR36 extern u int tex_bpp; // 16 or 32; default: 3233 extern int tex_filter; // GL values; default: GL_LINEAR 34 extern unsigned int tex_bpp; // 16 or 32; default: 32 37 35 38 36 // upload the specified texture to OpenGL. Texture filter and internal format -
ps/trunk/source/lib/res/vfs.cpp
r292 r334 21 21 22 22 #include "lib.h" 23 #include "file.h" 24 #include "zip.h" 25 #include "misc.h" 26 #include "vfs.h" 27 #include "mem.h" 23 #include "res.h" 28 24 #include "adts.h" 29 25 … … 184 180 // when opening a file (slow). 185 181 // 186 // one Loc is allocated for each archive or directory mounted.187 // therefore, files only /point/ to a (possibly shared) Loc.182 // one FileLoc is allocated for each archive or directory mounted. 183 // therefore, files only /point/ to a (possibly shared) FileLoc. 188 184 // if a file's location changes (e.g. after mounting a higher-priority 189 // directory), the VFS entry will point to the new Loc; the priority185 // directory), the VFS entry will point to the new FileLoc; the priority 190 186 // of both locations is unchanged. 191 187 // … … 198 194 199 195 // not many instances => don't worry about struct size / alignment. 200 struct Loc196 struct FileLoc 201 197 { 202 198 Handle archive; 203 204 199 std::string dir; 205 206 200 uint pri; 207 201 208 Loc() {}209 Loc(Handle _archive, const char* _dir, uint _pri)202 FileLoc() {} 203 FileLoc(Handle _archive, const char* _dir, uint _pri) 210 204 : archive(_archive), dir(_dir), pri(_pri) {} 211 205 }; 212 206 213 207 214 struct TreeDir; 215 216 typedef std::map<std::string, TreeDir*> SubDirs; 208 // rationale for separate file / subdir containers: 209 // problems: 210 // - more code for insertion (oh well); 211 // - makes ordered output of all dirents difficult 212 // (but dirs and files are usually displayed separately) 213 // advantages: 214 // - simplifies lookup code: it can just check if a path is there, 215 // no need to check if the entry is actually a directory 216 // - storing Dir objects directly in the map means less 217 // memory allocations / no need to free them. 218 // 219 // *_add guard against a subdir and file of the same name. 220 221 typedef std::map<const std::string, FileLoc*> Files; 222 typedef Files::iterator FileIt; 223 // notes: 224 // - FileLoc is allocated and owned by caller (the mount code) 225 // - priority is accessed by following the FileLoc pointer. 226 // keeping a copy in the map would lead to better cache coherency, 227 // but it's a bit more clumsy (map filename to struct {pri, FileLoc*}). 228 // revisit if file lookup open is too slow (unlikely). 229 230 struct Dir; 231 typedef std::pair<const std::string, Dir> SubDir; 232 typedef std::map<const std::string, Dir> SubDirs; 217 233 typedef SubDirs::iterator SubDirIt; 218 234 219 typedef std::map<std::string, const Loc*> Files; 220 typedef Files::iterator FileIt; 221 // note: priority is accessed by following the Loc pointer. 222 // keeping a copy in the map would lead to better cache coherency, 223 // but it's a bit more clumsy (map filename to struct {pri, Loc*}). 224 // revisit if file lookup open is too slow (unlikely). 225 226 struct TreeDir 227 { 228 std::string v_name; 229 230 void* watch; 231 232 233 int file_add(const char* const fn, const uint pri, const Loc* const loc) 234 { 235 std::string _fn(fn); 236 237 typedef std::pair<std::string, const Loc*> Ent; 238 Ent ent = std::make_pair(_fn, loc); 239 std::pair<FileIt, bool> ret; 240 ret = files.insert(ent); 241 // file already in dir 242 if(!ret.second) 243 { 244 FileIt it = ret.first; 245 const Loc*& old_loc = it->second; 246 247 // new Loc is of higher priority; replace pointer 248 if(old_loc->pri <= loc->pri) 249 { 250 old_loc = loc; 251 return 0; 252 } 253 // new Loc is of lower priority; keep old pointer 254 else 255 return 1; 256 } 257 235 struct Dir 236 { 237 int file_add(const char* name, const FileLoc* loc); 238 FileLoc* file_find(const char* name); 239 240 int subdir_add(const char* name); 241 Dir* subdir_find(const char* name); 242 243 void clearR(); 244 245 SubDirs subdirs; 246 Files files; 247 }; 248 249 250 int Dir::subdir_add(const char* const fn) 251 { 252 if(file_find(fn) || subdir_find(fn)) 253 { 254 debug_warn("dir_add: file or subdirectory of same name already exists"); 255 return -1; 256 } 257 258 subdirs[fn]; 259 // side effect: maps <fn> to a newly constructed Dir() 260 // non-const => cannot be optimized away. 261 return 0; 262 } 263 264 265 Dir* Dir::subdir_find(const char* const fn) 266 { 267 SubDirIt it = subdirs.find(fn); 268 if(it == subdirs.end()) 258 269 return 0; 259 } 260 261 const Loc* file_find(const char* fn) 262 { 263 std::string _fn(fn); 264 FileIt it = files.find(_fn); 265 if(it == files.end()) 266 return 0; 267 return it->second; 268 } 269 270 TreeDir* subdir_add(const char* name) 271 { 272 TreeDir* vdir = new TreeDir; 273 const std::string _name(name); 274 vdir->v_name = _name; 275 276 std::pair<std::string, TreeDir*> item = std::make_pair(_name, vdir); 277 std::pair<SubDirIt, bool> res; 278 res = subdirs.insert(item); 279 // already in container 280 if(!res.second) 281 debug_warn("already in subdir"); 282 283 SubDirIt it = res.first; 284 return it->second; 285 } 286 287 TreeDir* subdir_find(const char* name) 288 { 289 const std::string _name(name); 290 SubDirIt it = subdirs.find(_name); 291 if(it == subdirs.end()) 292 return 0; 293 return it->second; 294 } 295 296 void subdir_clear() 297 { 298 for(SubDirIt it = subdirs.begin(); it != subdirs.end(); ++it) 299 delete(it->second); 300 subdirs.clear(); 301 } 302 303 friend void tree_clearR(TreeDir*); 304 305 SubDirs subdirs; // can't make private; needed for iterator 306 Files files; 307 308 309 private:; 310 311 312 }; 313 314 315 static TreeDir vfs_root; 270 return &it->second; 271 } 272 273 274 int Dir::file_add(const char* const fn, const FileLoc* const loc) 275 { 276 if(subdir_find(fn)) 277 { 278 debug_warn("dir_add: file of same name already exists"); 279 return -1; 280 } 281 282 // default pointer ctor sets it to 0 => 283 // if fn wasn't already in the container, old_loc is 0. 284 const FileLoc*& old_loc = files[fn]; 285 // old loc exists and is higher priority - keep it. 286 if(old_loc && old_loc->pri > loc->pri) 287 return 1; 288 289 old_loc = loc; 290 return 0; 291 } 292 293 294 FileLoc* Dir::file_find(const char* const fn) 295 { 296 FileIt it = files.find(fn); 297 if(it == files.end()) 298 return 0; 299 return it->second; 300 } 301 302 303 void Dir::clearR() 304 { 305 SubDirIt it; 306 for(it = subdirs.begin(); it != subdirs.end(); ++it) 307 { 308 Dir& subdir = it->second; 309 subdir.clearR(); 310 } 311 312 subdirs.clear(); 313 files.clear(); 314 } 315 316 317 318 319 static Dir vfs_root; 316 320 317 321 … … 325 329 // starts in VFS root directory (path = ""). 326 330 // path doesn't need to, and shouldn't, start with '/'. 327 static int tree_lookup(const char* path, const Loc** const loc = 0, TreeDir** const dir = 0, LookupFlags flags = LF_DEFAULT)331 static int tree_lookup(const char* path, const FileLoc** const loc = 0, Dir** const dir = 0, LookupFlags flags = LF_DEFAULT) 328 332 { 329 333 CHECK_PATH(path); … … 338 342 const bool create_missing_components = flags & LF_CREATE_MISSING_COMPONENTS; 339 343 340 TreeDir* cur_dir = &vfs_root; 341 344 Dir* cur_dir = &vfs_root; 345 346 // for each path component: 342 347 for(;;) 343 348 { 344 349 char* slash = strchr(cur_component, '/'); 345 // we have followed all path components. 346 // cur_component is the filename or "" 350 // done, cur_component is the filename or "" if <path> is a directory 347 351 if(!slash) 348 { 349 // caller wants pointer to file location returned 350 if(loc) 351 { 352 const char* fn = cur_component; 353 *loc = cur_dir->file_find(fn); 354 355 // user wanted its loc, but it's not found - fail 356 if(!*loc) 357 return ERR_FILE_NOT_FOUND; 358 } 359 // caller wants pointer to this dir returned 360 if(dir) 361 *dir = cur_dir; 362 return 0; 363 } 364 // cur_component is a subdirectory name; change to it 365 else 366 { 367 const char* subdir_name = cur_component; 368 *slash = 0; 369 370 TreeDir* subdir = cur_dir->subdir_find(subdir_name); 371 if(!subdir) 372 { 373 if(create_missing_components) 374 subdir = cur_dir->subdir_add(subdir_name); 375 else 376 return ERR_PATH_NOT_FOUND; 377 } 378 379 cur_dir = subdir; 380 cur_component = slash+1; 381 } 382 } 383 } 384 385 386 static void tree_clearR(TreeDir* const dir) 387 { 388 SubDirIt it; 389 for(it = dir->subdirs.begin(); it != dir->subdirs.end(); ++it) 390 { 391 TreeDir* subdir = it->second; 392 tree_clearR(subdir); 393 } 394 395 dir->files.clear(); 396 dir->subdir_clear(); 352 break; 353 *slash = 0; // 0-terminate cur_component 354 const char* subdir_name = cur_component; 355 356 // create <subdir_name> 357 // (note: no-op if it already exists 358 if(create_missing_components) 359 cur_dir->subdir_add(subdir_name); 360 361 // switch to <subdir_name> 362 Dir* subdir = cur_dir->subdir_find(subdir_name); 363 if(!subdir) 364 return ERR_PATH_NOT_FOUND; 365 366 // next component 367 cur_dir = subdir; 368 cur_component = slash+1; 369 } 370 371 // we have followed all path components. 372 373 // caller wants pointer to file location returned 374 if(loc) 375 { 376 *loc = cur_dir->file_find(cur_component); 377 // .. but the file doesn't exist 378 if(!*loc) 379 return ERR_FILE_NOT_FOUND; 380 } 381 // caller wants pointer to this dir returned 382 if(dir) 383 *dir = cur_dir; 384 return 0; 397 385 } 398 386 … … 400 388 static inline void tree_clear() 401 389 { 402 tree_clearR(&vfs_root); 403 } 390 vfs_root.clearR(); 391 } 392 393 404 394 405 395 406 396 struct FileCBParams 407 397 { 408 TreeDir*dir;409 const Loc* loc;398 Dir* const dir; 399 const FileLoc* loc; 410 400 }; 411 401 … … 424 414 { 425 415 const FileCBParams* const params = (FileCBParams*)user; 426 TreeDir* const cur_dir = params->dir; 427 const Loc* const cur_loc = params->loc; 416 Dir* const cur_dir = params->dir; 417 const FileLoc* const cur_loc = params->loc; 418 419 int err; 428 420 429 421 // directory 430 422 if(flags & LOC_DIR) 431 cur_dir->subdir_add(fn);423 err = cur_dir->subdir_add(fn); 432 424 // file 433 425 else 434 CHECK_ERR(cur_dir->file_add(fn, cur_loc->pri, cur_loc)); 435 436 return 0; 437 } 438 439 440 static int tree_add_dirR(TreeDir* const vdir, const char* const f_path, const Loc* const loc) 426 err = cur_dir->file_add(fn, cur_loc); 427 428 if(err < 0) 429 return -EEXIST; 430 return 0; 431 } 432 433 434 static int tree_add_dirR(Dir* const dir, const char* const f_path, const FileLoc* const loc) 441 435 { 442 436 CHECK_PATH(f_path); 443 437 444 // add watch445 if(!vdir->watch)446 vdir->watch = 0;447 448 438 // add files and subdirs to vdir 449 const FileCBParams params = { vdir, loc };439 const FileCBParams params = { dir, loc }; 450 440 file_enum(f_path, add_dirent_cb, (uintptr_t)¶ms); 451 441 452 for(SubDirIt it = vdir->subdirs.begin(); it != vdir->subdirs.end(); ++it) 453 { 454 TreeDir* const vsubdir = it->second; 442 for(SubDirIt it = dir->subdirs.begin(); it != dir->subdirs.end(); ++it) 443 { 444 Dir* const subdir = &it->second; 445 const char* const subdir_name_c = (it->first).c_str(); 455 446 456 447 char f_subdir_path[VFS_MAX_PATH]; 457 const char* const v_subdir_name_c = vsubdir->v_name.c_str(); 458 CHECK_ERR(path_append(f_subdir_path, f_path, v_subdir_name_c)); 459 460 tree_add_dirR(vsubdir, f_subdir_path, loc); 461 } 462 463 return 0; 464 } 465 466 467 static int tree_add_loc(TreeDir* const vdir, const Loc* const loc) 448 CHECK_ERR(path_append(f_subdir_path, f_path, subdir_name_c)); 449 450 tree_add_dirR(subdir, f_subdir_path, loc); 451 } 452 453 return 0; 454 } 455 456 457 static int tree_add_loc(Dir* const dir, const FileLoc* const loc) 468 458 { 469 459 if(loc->archive > 0) 470 460 { 471 FileCBParams params = { vdir, loc };461 FileCBParams params = { dir, loc }; 472 462 return zip_enum(loc->archive, add_dirent_cb, (uintptr_t)¶ms); 473 463 } … … 475 465 { 476 466 const char* f_path_c = loc->dir.c_str(); 477 return tree_add_dirR( vdir, f_path_c, loc);467 return tree_add_dirR(dir, f_path_c, loc); 478 468 } 479 469 } … … 490 480 // (we keep and pass around pointers to Mount.archive_locs elements) 491 481 // see below. 492 typedef std::list< Loc> Locs;482 typedef std::list<FileLoc> Locs; 493 483 typedef Locs::iterator LocIt; 494 484 … … 506 496 507 497 // storage for all Locs ensuing from this mounting. 508 // the VFS tree only holds pointers to Loc, which is why the498 // the VFS tree only holds pointers to FileLoc, which is why the 509 499 // Locs container must not invalidate its contents after adding, 510 500 // and also why the VFS tree must be rebuilt after unmounting something. 511 Loc dir_loc;501 FileLoc dir_loc; 512 502 Locs archive_locs; 513 // if not is_single_archive, contains one Loc for every archive503 // if not is_single_archive, contains one FileLoc for every archive 514 504 // in the directory (but not its children - see remount()). 515 // otherwise, contains exactly one Loc for the single archive.505 // otherwise, contains exactly one FileLoc for the single archive. 516 506 517 507 // is f_name an archive filename? if not, it's a directory. … … 547 537 uint pri; 548 538 549 // will add one Loc to this container for539 // will add one FileLoc to this container for 550 540 // every archive successfully opened. 551 541 Locs* archive_locs; … … 574 564 const Handle archive = zip_archive_open(f_path); 575 565 if(archive > 0) 576 archive_locs->push_back( Loc(archive, "", pri));566 archive_locs->push_back(FileLoc(archive, "", pri)); 577 567 578 568 // only add archive to list; don't add its files into the VFS yet, … … 593 583 const char* const f_name = m.f_name.c_str(); 594 584 const uint pri = m.pri; 595 Loc& dir_loc= m.dir_loc;585 FileLoc& dir_loc = m.dir_loc; 596 586 Locs& archive_locs = m.archive_locs; 597 587 598 TreeDir* vdir;599 CHECK_ERR(tree_lookup(v_path, 0, & vdir, LF_CREATE_MISSING_COMPONENTS));588 Dir* dir; 589 CHECK_ERR(tree_lookup(v_path, 0, &dir, LF_CREATE_MISSING_COMPONENTS)); 600 590 601 591 // check if target is a single Zip archive … … 605 595 { 606 596 m.is_single_archive = true; 607 archive_locs.push_back( Loc(archive, "", pri));608 const Loc* loc = &archive_locs.front();609 return tree_add_loc( vdir, loc);597 archive_locs.push_back(FileLoc(archive, "", pri)); 598 const FileLoc* loc = &archive_locs.front(); 599 return tree_add_loc(dir, loc); 610 600 } 611 601 … … 616 606 for(LocIt it = archive_locs.begin(); it != archive_locs.end(); ++it) 617 607 { 618 const Loc* const loc = &*it;619 tree_add_loc( vdir, loc);608 const FileLoc* const loc = &*it; 609 tree_add_loc(dir, loc); 620 610 } 621 611 622 612 623 613 dir_loc.dir = f_name; 624 err = tree_add_loc( vdir, &dir_loc);614 err = tree_add_loc(dir, &dir_loc); 625 615 if(err < 0) 626 616 err = err; … … 634 624 for(LocIt it = m.archive_locs.begin(); it != m.archive_locs.end(); ++it) 635 625 { 636 Loc& loc = *it;626 FileLoc& loc = *it; 637 627 zip_archive_close(loc.archive); 638 628 } … … 650 640 651 641 652 static void cleanup(void)642 void vfs_shutdown(void) 653 643 { 654 644 tree_clear(); … … 659 649 int vfs_mount(const char* const vfs_mount_point, const char* const name, const uint pri) 660 650 { 661 ONCE(atexit2( cleanup));651 ONCE(atexit2(vfs_shutdown)); 662 652 663 653 // make sure it's not already mounted, i.e. in mounts … … 716 706 /////////////////////////////////////////////////////////////////////////////// 717 707 // 718 // 708 // directory 719 709 // 720 710 /////////////////////////////////////////////////////////////////////////////// 721 711 722 // OLD723 // rationale for n-archives per PATH entry:724 // We need to be able to unmount specific paths (e.g. when switching mods).725 // Don't want to remount everything (slow), or specify a mod tag when mounting726 // (not this module's job). Instead, we include all archives in one path entry;727 // the game keeps track of what path(s) it mounted for a mod,728 // and unmounts those when needed.729 730 712 731 713 int vfs_realpath(const char* fn, char* full_path) 732 714 { 733 const Loc* loc;715 const FileLoc* loc; 734 716 CHECK_ERR(tree_lookup(fn, &loc)); 735 717 … … 752 734 int vfs_stat(const char* fn, struct stat* s) 753 735 { 754 const Loc* loc;736 const FileLoc* loc; 755 737 CHECK_ERR(tree_lookup(fn, &loc)); 756 738 … … 767 749 struct VDir 768 750 { 769 TreeDir* dir; 770 FileIt it; 751 // we need to cache the complete contents of the directory: 752 // 753 SubDirs* subdirs; 754 SubDirIt subdir_it; 755 Files* files; 756 FileIt file_it; 771 757 }; 772 758 773 759 H_TYPE_DEFINE(VDir); 774 760 775 776 777 761 static void VDir_init(VDir* vd, va_list args) 778 762 { … … 781 765 static void VDir_dtor(VDir* vd) 782 766 { 783 // remove reference to TreeDir, unlock it for further use 767 delete vd->subdirs; 768 delete vd->files; 784 769 } 785 770 … … 787 772 { 788 773 // check if actually reloaded, and why it happened? 789 // hmm, if TreeDir changes while handle is open, we are screwed. 790 // need a lock. 791 792 CHECK_ERR(tree_lookup(path, 0, &vd->dir)); 793 794 vd->it = vd->dir->files.begin(); 774 775 Dir* dir; 776 CHECK_ERR(tree_lookup(path, 0, &dir)); 777 778 vd->subdirs = new SubDirs(dir->subdirs); 779 vd->subdir_it = vd->subdirs->begin(); 780 vd->files = new Files(dir->files); 781 vd->file_it = vd->files->begin(); 795 782 return 0; 796 783 } … … 802 789 } 803 790 791 804 792 int vfs_close_dir(Handle& hd) 805 793 { … … 807 795 } 808 796 797 798 // filter: 799 // 0: any file 800 // ".": file without extension (filename doesn't contain '.') 801 // ".ext": file with extension <ext> (which must not contain '.') 802 // "/": subdirectory 809 803 int vfs_next_dirent(const Handle hd, vfsDirEnt* ent, const char* const filter) 810 804 { 811 // make sure filter is valid 812 // interpret filter, decide if they want files or subdirs 813 814 // until no more entries, or one matches filter 805 H_DEREF(hd, VDir, vd); 806 807 // interpret filter 808 bool filter_dir = false; 809 bool filter_no_ext = false; 810 if(filter) 811 { 812 if(filter[0] == '/') 813 { 814 if(filter[1] != '\0') 815 goto invalid_filter; 816 filter_dir = true; 817 } 818 else if(filter[0] == '.') 819 { 820 if(strchr(filter+1, '.')) 821 goto invalid_filter; 822 filter_no_ext = filter[1] == '\0'; 823 } 824 else 825 goto invalid_filter; 826 } 827 828 const char* fn; 829 830 // caller wants a subdirectory; return the next one. 831 if(filter_dir) 832 { 833 if(vd->subdir_it == vd->subdirs->end()) 834 return -1; 835 fn = vd->subdir_it->first.c_str(); 836 ++vd->subdir_it; 837 goto have_match; 838 } 839 840 // caller wants a file; loop until one matches or end of list. 815 841 for(;;) 816 842 { 817 H_DEREF(hd, VDir, vd); 818 if(vd->it == vd->dir->files.end()) 819 return 1; 820 821 const std::string& fn_s = vd->it->first; 822 const char* const fn = fn_s.c_str(); 823 824 if(filter) 825 { 826 char* ext = strrchr(fn, '.'); 827 if(!ext || strcmp(ext, filter) != 0) 828 continue; 829 } 830 831 // found matching entry 832 } 843 if(vd->file_it == vd->files->end()) 844 return -1; 845 fn = vd->file_it->first.c_str(); 846 ++vd->file_it; 847 848 char* const ext = strrchr(fn, '.'); 849 if(!filter || (filter_no_ext && !ext) || strcmp(ext, filter) == 0) 850 goto have_match; 851 } 852 853 have_match: 854 ent->name = fn; 855 return 0; 856 857 invalid_filter: 858 debug_warn("vfs_next_dirent: invalid filter"); 859 return -1; 833 860 } 834 861 … … 928 955 929 956 930 const Loc* loc;957 const FileLoc* loc; 931 958 CHECK_ERR(tree_lookup(path, &loc)); 932 959 -
ps/trunk/source/lib/sysdep/win/waio.cpp
r277 r334 23 23 #include "lib.h" 24 24 #include "win_internal.h" 25 #include "misc.h"26 #include "types.h"27 25 28 26 -
ps/trunk/source/lib/sysdep/win/wdetect.cpp
r293 r334 52 52 // useful for choosing a video mode. not called by detect(). 53 53 // if we fail, outputs are unchanged (assumed initialized to defaults) 54 int get_cur_ resolution(int& xres, int& yres)55 { 56 DEVMODE Adm;54 int get_cur_vmode(int* xres, int* yres, int* bpp, int* freq) 55 { 56 DEVMODEW dm; 57 57 memset(&dm, 0, sizeof(dm)); 58 58 dm.dmSize = sizeof(dm); 59 59 // dm.dmDriverExtra already set to 0 by memset 60 60 61 if(!EnumDisplaySettingsA(0, ENUM_CURRENT_SETTINGS, &dm)) 62 return -1; 63 64 xres = dm.dmPelsWidth; 65 yres = dm.dmPelsHeight; 61 if(!EnumDisplaySettingsW(0, ENUM_CURRENT_SETTINGS, &dm)) 62 return -1; 63 64 if(dm.dmFields & DM_PELSWIDTH && xres) 65 *xres = (int)dm.dmPelsWidth; 66 if(dm.dmFields & DM_PELSHEIGHT && yres) 67 *yres = (int)dm.dmPelsHeight; 68 if(dm.dmFields & DM_BITSPERPEL && bpp) 69 *bpp = (int)dm.dmBitsPerPel; 70 if(dm.dmFields & DM_DISPLAYFREQUENCY && freq) 71 *freq = (int)dm.dmDisplayFrequency; 72 66 73 return 0; 67 74 } -
ps/trunk/source/lib/sysdep/win/wposix.cpp
r322 r334 27 27 #include "hrt.h" 28 28 29 // waio included via lib -> posix -> wposix 30 31 32 static HANDLE mk_handle(intptr_t i) 33 { 34 // passing in -1 (e.g. if _get_osfhandle fails), 35 // is fine, it ends up INVALID_HANDLE_VALUE. 36 return (HANDLE)((char*)0 + i); 37 } 38 29 39 30 40 ////////////////////////////////////////////////////////////////////////////// … … 68 78 int close(int fd) 69 79 { 80 assert(3 <= fd && fd < 256); 70 81 aio_close(fd); 71 82 return _close(fd); … … 75 86 int ioctl(int fd, int op, int* data) 76 87 { 77 HANDLE h = (HANDLE)((char*)0 +_get_osfhandle(fd));88 const HANDLE h = mk_handle(_get_osfhandle(fd)); 78 89 79 90 switch(op) … … 213 224 214 225 215 static HANDLE std_h[2] = { (HANDLE)(( (char*)0) + 3), (HANDLE)(((char*)0)+ 7) };226 static HANDLE std_h[2] = { (HANDLE)((char*)0 + 3), (HANDLE)((char*)0 + 7) }; 216 227 217 228 … … 275 286 if(param) 276 287 { 277 HANDLE hThread = (HANDLE)((char*)0 +thread);288 const HANDLE hThread = mk_handle((intptr_t)thread); 278 289 param->sched_priority = GetThreadPriority(hThread); 279 290 } … … 287 298 SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); 288 299 289 HANDLE hThread = (HANDLE)((char*)0 + thread); 290 300 const HANDLE hThread = mk_handle((intptr_t)thread); 291 301 SetThreadPriority(hThread, param->sched_priority); 292 302 return 0; … … 389 399 DWORD len_hi = (DWORD)((u64)len >> 32), len_lo = (DWORD)len & 0xffffffff; 390 400 391 HANDLE hFile = (HANDLE)((char*)0 +_get_osfhandle(fd));401 HANDLE hFile = mk_handle(_get_osfhandle(fd)); 392 402 HANDLE hMap = CreateFileMapping(hFile, &sec, flProtect, len_hi, len_lo, 0); 393 403 -
ps/trunk/source/lib/sysdep/win/wposix.h
r277 r334 27 27 28 28 #include <sys/types.h> 29 #include <stddef.h> 29 30 30 31 #ifdef __cplusplus … … 33 34 34 35 35 #define IMP(ret, name, param) extern "C" __declspec(dllimport) ret __stdcall name param; 36 37 // for functions actually implemented in the CRT 38 #ifdef _DLL 39 #define _CRTIMP __declspec(dllimport) 36 // 37 // <inttypes.h> 38 // 39 40 typedef char int8_t; 41 typedef short int16_t; 42 typedef int int32_t; 43 #if defined(_MSC_VER) || defined(__INTEL_COMPILER) || defined(__LCC__) 44 typedef __int64 int64_t; 45 #elif defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__DMC__) 46 typedef long long int64_t; 40 47 #else 41 # define _CRTIMP48 #error "port int64_t" 42 49 #endif 43 50 44 45 46 // 47 // <inttypes.h> 48 // 49 50 typedef unsigned short u16_t; 51 typedef unsigned char uint8_t; 52 typedef unsigned short uint16_t; 53 typedef unsigned int uint32_t; 54 #if defined(_MSC_VER) || defined(__INTEL_COMPILER) || defined(__LCC__) 55 typedef unsigned __int64 uint64_t; 56 #elif defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__DMC__) 57 typedef unsigned long long uint64_t; 58 #else 59 #error "port uint64_t" 60 #endif 61 62 #ifdef _MSC_VER 63 # ifndef _UINTPTR_T_DEFINED 64 # define _UINTPTR_T_DEFINED 65 # define uintptr_t unsigned int 66 # endif // _UINTPTR_T_DEFINED 67 # ifndef _INTPTR_T_DEFINED 68 # define _INTPTR_T_DEFINED 69 # define intptr_t signed int 70 # endif // _INTPTR_T_DEFINED 71 #else // _MSC_VER 72 #include <stdint.h> 73 #endif // _MSC_VER 51 74 52 75 … … 226 249 extern long sysconf(int name); 227 250 228 #ifndef _WINSOCKAPI_229 230 IMP(int, gethostname, (char* name, size_t namelen))231 232 #endif233 251 234 252 // -
ps/trunk/source/lib/sysdep/win/wsdl.cpp
r329 r334 32 32 #include "lib.h" 33 33 #include "win_internal.h" 34 #include "misc.h"35 34 36 35 #include <SDL_vkeys.h> -
ps/trunk/source/lib/sysdep/win/wsock.cpp
r277 r334 47 47 48 48 49 u 16_t htons(u16_t s)49 uint16_t htons(uint16_t s) 50 50 { 51 51 return (s >> 8) | ((s & 0xff) << 8); -
ps/trunk/source/lib/sysdep/win/wsock.h
r277 r334 2 2 #define WSOCK_H__ 3 3 4 #define IMP(ret, name, param) extern "C" __declspec(dllimport) ret __stdcall name param; 5 6 IMP(int, gethostname, (char* name, size_t namelen)) 7 4 8 5 9 // … … 10 14 typedef unsigned short sa_family_t; 11 15 12 //#ifndef _WINSOCKAPI_13 14 16 // Win32 values - do not change 15 16 17 #define SOCK_STREAM 1 17 18 #define SOCK_DGRAM 2 … … 179 180 // 180 181 181 extern u 16_t htons(u16_t hostshort);182 extern uint16_t htons(uint16_t hostshort); 182 183 #define ntohs htons 183 184 IMP(unsigned long, htonl, (unsigned long hostlong)) … … 194 195 IMP(ssize_t, sendto, (int, const void*, size_t, int, const struct sockaddr*, socklen_t)) 195 196 IMP(ssize_t, recvfrom, (int, void*, size_t, int, struct sockaddr*, socklen_t*)) 196 197 //#endif /* _WINSOCKAPI_ */ 198 197 198 199 #undef IMP 199 200 200 201 #endif // #ifndef WSOCK_H__ -
ps/trunk/source/lib/sysdep/x.cpp
r221 r334 25 25 // useful for choosing a video mode. not called by detect(). 26 26 // if we fail, outputs are unchanged (assumed initialized to defaults) 27 int get_cur_ resolution(int& xres, int& yres)27 int get_cur_vmode(int* xres, int* yres, int* bpp, int* freq) 28 28 { 29 29 Display* disp = XOpenDisplay(0); … … 32 32 33 33 int screen = XDefaultScreen(disp); 34 xres = XDisplayWidth (disp, screen); 35 yres = XDisplayHeight(disp, screen); 34 if(xres) 35 *xres = XDisplayWidth (disp, screen); 36 if(yres) 37 *yres = XDisplayHeight(disp, screen); 38 if(bpp) 39 *bpp = 0; 40 if(freq) 41 *freq = 0; 36 42 XCloseDisplay(disp); 37 43 return 0; -
ps/trunk/source/lib/timer.cpp
r221 r334 18 18 #include "precompiled.h" 19 19 20 #include "lib.h" 20 21 #include "timer.h" 21 #include "types.h"22 #include "misc.h"23 #include "lib.h"24 22 25 23 #ifdef _WIN32 -
ps/trunk/source/lib/types.h
r164 r334 1 // convenience type (shorter defs than stdint uintN_t) 2 1 3 #ifndef __TYPES_H__ 2 4 #define __TYPES_H__ 3 5 6 #include "posix.h" 4 7 5 8 // defines instead of typedefs so we can #undef conflicting decls 6 7 9 8 10 #define ulong unsigned long … … 10 12 #define uint unsigned int 11 13 12 #define i8 signed char 13 #define i16 short 14 #define i32 long 14 #define i8 int8_t 15 #define i16 int16_t 16 #define i32 int32_t 17 #define i64 int64_t 15 18 16 #define u8 unsigned char 17 #define u16 unsigned short 18 #define u32 unsigned long // long to match Win32 DWORD 19 20 #if defined(_MSC_VER) || defined(__INTEL_COMPILER) || defined(__LCC__) 21 #define i64 __int64 22 #define u64 unsigned __int64 23 #elif defined(__GNUC__) || defined(__MWERKS__) || defined(__SUNPRO_C) || defined(__DMC__) 24 #define i64 long long 25 #define u64 unsigned long long 26 #else 27 #error "TODO: port u64" 28 #endif 19 #define u8 uint8_t 20 #define u16 uint16_t 21 #define u32 uint32_t 22 #define u64 uint64_t 29 23 30 24 31 #define int8 i8 32 #define int16 i16 33 #define int32 i32 34 35 #include <stddef.h> 36 #ifdef _MSC_VER 37 # ifndef _UINTPTR_T_DEFINED 38 # define _UINTPTR_T_DEFINED 39 # define uintptr_t u32 40 # endif // _UINTPTR_T_DEFINED 41 # ifndef _INTPTR_T_DEFINED 42 # define _INTPTR_T_DEFINED 43 # define intptr_t i32 44 # endif // _INTPTR_T_DEFINED 45 #else // !_MSC_VER 46 # include <stdint.h> 47 #endif // _MSC_VER 48 25 // the standard only guarantees 16 bits. 26 // we use this for memory offsets and ranges, so it better be big enough. 27 #if defined(SIZE_MAX) && SIZE_MAX < 32 28 #error "check size_t and SIZE_MAX - too small?" 29 #endif 30 49 31 50 32 #endif // #ifndef __TYPES_H__ -
ps/trunk/source/main.cpp
r322 r334 110 110 fprintf(f, "%s\n", gfx_card); 111 111 fprintf(f, "%s\n", gfx_drv_ver); 112 fprintf(f, "%dx%d:%d@%d\n", g_xres, g_yres, g_bpp, g_freq); 112 113 // .. network name / ips 113 114 char hostname[100]; // possibly nodename != hostname 114 115 gethostname(hostname, sizeof(hostname)); 115 116 fprintf(f, "%s\n", hostname); 116 hostent* h = gethostbyname(hostname);117 if(h )118 { 119 struct in_addr** ips = (struct in_addr**)h ->h_addr_list;117 hostent* host = gethostbyname(hostname); 118 if(host) 119 { 120 struct in_addr** ips = (struct in_addr**)host->h_addr_list; 120 121 for(int i = 0; ips && ips[i]; i++) 121 122 fprintf(f, "%s ", inet_ntoa(*ips[i])); … … 229 230 230 231 ////////////////////////////////////////////////////////////////////////////////////////////////// 231 // SubmitModelRecursive: recurse down given model, submitting it and all it 's descendents to the232 // SubmitModelRecursive: recurse down given model, submitting it and all its descendents to the 232 233 // renderer 233 234 void SubmitModelRecursive(CModel* model) … … 434 435 #endif 435 436 437 436 438 detect(); 437 439 … … 477 479 // preferred video mode = current desktop settings 478 480 // (command line params may override these) 479 get_cur_ resolution(g_xres, g_yres);481 get_cur_vmode(&g_xres, &g_yres, &g_bpp, &g_freq); 480 482 481 483 for(int a = 1; a < argc; a++) … … 514 516 vfs_mount("", "mods/official/", 0); 515 517 //// dir_add_watch("mods\\official", false); 516 517 518 //Handle xx = tex_load("art/textures/skins/structural/null.png");519 518 520 519 #ifndef NO_GUI … … 640 639 } 641 640 642 // TODO MT: Move this to atexit() code? Capture original gamma ramp at initialization and restore it?643 644 SDL_SetGamma( 1.0f, 1.0f, 1.0f );645 646 641 #ifndef NO_GUI 647 642 g_GUI.Destroy(); … … 666 661 delete CRenderer::GetSingletonPtr(); 667 662 663 exit(0); 668 664 return 0; 669 665 } -
ps/trunk/source/ps/Config.h
r157 r334 48 48 //-------------------------------------------------------- 49 49 50 #include "stdlib.h" 50 #include <stdlib.h> 51 51 52 #include "Prometheus.h" 52 53 #include "Singleton.h" 53 54 #include "CStr.h" 54 55 #include "LogFile.h" 55 #include "posix.h" 56 #include "misc.h" 56 #include "lib.h" 57 57 58 58 #include <vector> -
ps/trunk/source/ps/Overlay.cpp
r288 r334 50 50 } 51 51 52 CRect::CRect(const int32 &_l, const int32 &_t, const int32 &_r, const int32&_b) :52 CRect::CRect(const int32_t &_l, const int32_t &_t, const int32_t &_r, const int32_t &_b) : 53 53 left(_l), top(_t), right(_r), bottom(_b) 54 54 { … … 181 181 } 182 182 183 int32 CRect::GetWidth() const183 int32_t CRect::GetWidth() const 184 184 { 185 185 return right-left; 186 186 } 187 187 188 int32 CRect::GetHeight() const188 int32_t CRect::GetHeight() const 189 189 { 190 190 return bottom-top; … … 225 225 } 226 226 227 CPos::CPos(const int32 &_x, const int32&_y) : x(_x), y(_y)227 CPos::CPos(const int32_t &_x, const int32_t &_y) : x(_x), y(_y) 228 228 { 229 229 } … … 326 326 } 327 327 328 CSize::CSize(const int32 &_cx, const int32&_cy) : cx(_cx), cy(_cy)328 CSize::CSize(const int32_t &_cx, const int32_t &_cy) : cx(_cx), cy(_cy) 329 329 { 330 330 } -
ps/trunk/source/ps/Overlay.h
r322 r334 13 13 #define COVERLAY_H 14 14 15 #include " types.h"15 #include "lib.h" 16 16 17 17 struct CColor … … 61 61 CRect(const CPos &upperleft, const CPos &bottomright); 62 62 CRect(const CPos &pos, const CSize &size); 63 CRect(const int32 &_l, const int32 &_t, const int32 &_r, const int32&_b);63 CRect(const int32_t &_l, const int32_t &_t, const int32_t &_r, const int32_t &_b); 64 64 65 65 // Operators … … 87 87 * @return Width of Rectangle 88 88 */ 89 int32 GetWidth() const;89 int32_t GetWidth() const; 90 90 91 91 /** 92 92 * @return Height of Rectangle 93 93 */ 94 int32 GetHeight() const;94 int32_t GetHeight() const; 95 95 96 96 /** … … 129 129 * Dimensions 130 130 */ 131 int32 left, top, right, bottom;131 int32_t left, top, right, bottom; 132 132 }; 133 133 … … 143 143 public: 144 144 CPos(); 145 CPos(const int32 &_x, const int32&_y);145 CPos(const int32_t &_x, const int32_t &_y); 146 146 147 147 // Operators … … 166 166 * Position 167 167 */ 168 int32 x, y;168 int32_t x, y; 169 169 }; 170 170 … … 184 184 CSize(const CRect &rect); 185 185 CSize(const CPos &pos); 186 CSize(const int32 &_cx, const int32&_cy);186 CSize(const int32_t &_cx, const int32_t &_cy); 187 187 188 188 // Operators … … 207 207 * Size 208 208 */ 209 int32 cx, cy;209 int32_t cx, cy; 210 210 }; 211 211 -
ps/trunk/source/ps/Singleton.h
r162 r334 21 21 22 22 #include <assert.h> 23 #include " types.h" // uintptr_t - not otherwise defined by VC623 #include "lib.h" 24 24 25 25 -
ps/trunk/source/ps/ThreadUtil.h
r170 r334 67 67 //-------------------------------------------------------- 68 68 69 #include " posix.h"70 #include "misc.h" 69 #include "lib.h" 70 71 71 #ifdef DEBUG_LOCKS 72 72 -
ps/trunk/source/renderer/PatchRData.cpp
r322 r334 1 # pragma warning(disable:4786)1 #include "precompiled.h" 2 2 3 3 #include <assert.h> -
ps/trunk/source/simulation/EntityProperties.cpp
r284 r334 50 50 } 51 51 52 CGenericProperty& CGenericProperty::operator=( int32 value )52 CGenericProperty& CGenericProperty::operator=( int32_t value ) 53 53 { 54 54 if( m_type & PROP_TYPELOCKED ) -
ps/trunk/source/terrain/terrainMain.cpp
r330 r334 42 42 void terr_init() 43 43 { 44 int xres,yres; 45 get_cur_resolution(xres,yres); 46 g_Renderer.Open(xres,yres,32); 44 g_Renderer.Open(g_xres,g_yres,g_bpp); 47 45 48 46 SViewPort vp; 49 47 vp.m_X=0; 50 48 vp.m_Y=0; 51 vp.m_Width= xres;52 vp.m_Height= yres;49 vp.m_Width=g_xres; 50 vp.m_Height=g_yres; 53 51 g_Camera.SetViewPort(&vp); 54 52
Note:
See TracChangeset
for help on using the changeset viewer.
