00001 /* 00002 * exult_constants.h - Some constants/macros that are used all over the code. 00003 * 00004 * Copyright (C) 2000-2001 The Exult Team 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #ifndef EXULT_CONSTANTS_H 00022 #define EXULT_CONSTANTS_H 00023 00024 #include <string> 00025 00026 /* 00027 * Sizes: 00028 */ 00029 const int c_tilesize = 8; // A tile (shape) is 8x8 pixels. 00030 const int c_tiles_per_chunk = 16; // A chunk is 16x16 tiles. 00031 const int c_chunksize = 16 * 8; // A chunk has 16 8x8 shapes. 00032 const int c_num_schunks = 12; 00033 const int c_num_chunks = 12*16; // Total # of chunks in each dir. 00034 const int c_chunks_per_schunk = 16; // # chunks in each superchunk. 00035 const int c_tiles_per_schunk = 16*16; // # tiles in each superchunk. 00036 // Total # tiles in each dir.: 00037 const int c_num_tiles = c_tiles_per_chunk*c_num_chunks; 00038 00039 const int c_fade_in_time = 30; // Time for fade in 00040 const int c_fade_out_time = 30; // Time for fade out 00041 const int c_std_delay = 200; // Standard animation delay. May want to 00042 // make this settable! 00043 00044 const int c_any_shapenum = -359; 00045 const int c_any_qual = -359; 00046 const int c_any_framenum = -359; 00047 00048 /* 00049 * Empty string 00050 */ 00051 extern const std::string c_empty_string; 00052 00053 00054 #define MOVE_NODROP (1<<3) 00055 #define MOVE_FLY (1<<4) 00056 #define MOVE_LEVITATE (MOVE_FLY|MOVE_NODROP) 00057 #define MOVE_WALK (1<<5) 00058 #define MOVE_SWIM (1<<6) 00059 #define MOVE_ALL_TERRAIN ((1<<5)|(1<<6)) 00060 #define MOVE_ETHEREAL (1<<7) 00061 #define MOVE_ALL (MOVE_FLY|MOVE_WALK|MOVE_SWIM|MOVE_ETHEREAL) 00062 #define MOVE_MAPEDIT (1<<8) 00063 00064 // Wrapping: 00065 #define INCR_CHUNK(x) (((x) + 1)%c_num_chunks) 00066 #define DECR_CHUNK(x) (((x) - 1 + c_num_chunks)%c_num_chunks) 00067 #define INCR_TILE(x) (((x) + 1)%c_num_tiles) 00068 inline int DECR_TILE(int x, int amt = 1) 00069 { return (x - amt + c_num_tiles)%c_num_tiles; } 00070 // Return x - y with wrapping. 00071 inline int SUB_TILE(int x, int y) 00072 { 00073 int delta = x - y; 00074 return delta < -c_num_tiles/2 ? delta + c_num_tiles : 00075 delta >= c_num_tiles/2 ? delta - c_num_tiles : delta; 00076 } 00077 00078 // Debug 00079 #ifdef DEBUG 00080 # define COUT(x) do { std::cout << x << std::endl; std::cout.flush(); } while (0) 00081 # define CERR(x) do { std::cerr << x << std::endl; std::cerr.flush(); } while (0) 00082 #else 00083 # define COUT(x) do { } while(0) 00084 # define CERR(x) do { } while(0) 00085 #endif 00086 00087 // Two very useful macros that one should use instead of pure delete; they will additionally 00088 // set the old object pointer to 0, thus helping prevent double deletes (not that "delete 0" 00089 // is a no-op. 00090 #define FORGET_OBJECT(x) do { delete x; x = 0; } while(0) 00091 #define FORGET_ARRAY(x) do { delete [] x; x = 0; } while(0) 00092 00093 00094 #endif