📄 constants.h
字号:
/*************************************************************************** constants.h - description ------------------- begin : Sun Oct 12 2003 copyright : (C) 2003 by Gabor Torok email : cctorok@yahoo.com ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#ifndef CONSTANTS_H#define CONSTANTS_H// from tuxracer#if defined ( __MWERKS__ ) || defined( _MSC_VER ) || defined( WIN32 )# define NATIVE_WIN32_COMPILER 1#else/* Assume UNIX compatible by default */# define COMPILER_IS_UNIX_COMPATIBLE 1#endif// include sdl, opengl and glut#include <SDL.h>#include <SDL_opengl.h>#include <SDL_endian.h>#if defined(__APPLE__) || defined(__MACH_O__)// *** #include <GLUT/glut.h>#else// *** #include <GL/glut.h>#ifndef WIN32// Could not get these to include on my Mandrake9 box...#ifndef APIENTRY#define APIENTRY#endiftypedef void (APIENTRY * PFNGLACTIVETEXTUREARBPROC) (GLenum texture);typedef void (APIENTRY * PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);typedef void (APIENTRY * PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);#endif#endif#include <stdlib.h>#include <math.h>#include <vector>#include <iostream>#if defined( COMPILER_IS_UNIX_COMPATIBLE )# include <unistd.h># include <pwd.h># include <dirent.h># include <sys/time.h># include <sys/types.h># include <dirent.h># include <sys/stat.h>#endifusing namespace std;#ifdef WIN32#define SEPARATOR '\\'#else#define SEPARATOR '/'#endif/* Data and config dirs. Shamelessly borrowed from tuxracer. */#if defined( WIN32 )# define CONFIG_DIR "."# define CONFIG_FILE "options.txt"#else# define CONFIG_DIR ".scourge"# define CONFIG_FILE "options"#endif /* defined( WIN32 ) */#ifndef DATA_DIR# if defined( WIN32 )# define DATA_DIR "./data"# else# define DATA_DIR "/usr/local/share/scourge"# endif /* defined( WIN32 ) */#endifextern char rootDir[300];extern char configDir[300];extern int get_config_dir_name( char *buff, int len );extern int get_config_file_name( char *buff, int len );#define SCOURGE_VERSION 0.6// opengl extension function ptrs for SDL (set in sdlhandler.cpp)extern PFNGLACTIVETEXTUREARBPROC glSDLActiveTextureARB;extern PFNGLMULTITEXCOORD2FARBPROC glSDLMultiTexCoord2fARB;extern PFNGLMULTITEXCOORD2IARBPROC glSDLMultiTexCoord2iARB;// some windows versions of opengl don't have this#define GL_BGR 0x80E0#define GL_BGRA 0x80E1// show fps info#define SHOW_DEBUG_INFO/* Float swapping code by: Ramin Firoozye' -- rp&A Inc. 1995/06/30 found on Google groups *//* * Helpful macros in swapping bytes etc... * This union lets us map just about any common datatype onto the * specified value, so we can use direct array access to do byte, word, * or long swapping. */union NetValue{ short s; /* Straight 2-byte short */ unsigned short sU; /* unsigned short */ unsigned char sC[2]; /* short as bytes */ long l; /* Straight 4-byte long */ unsigned long lU; /* unsigned long */ unsigned char lC[4]; /* long as bytes */ unsigned short lS[2]; /* long as short */ float f; /* Straight (presumed) 4-byte single */ unsigned char fC[4]; /* single as bytes */ unsigned short fS[2]; /* single as short */ double g; /* Straight (presumed) 8-byte double */ unsigned char gC[8]; /* double as bytes */ unsigned short gS[4]; /* double as short */ unsigned long gL[2]; /* double as long */};typedef union NetValue NetValue;/* * We define macros as mSWAPn where m is one of B=Byte, W=word and L=long * and n is one of B=byte, W=word, L=long, F=single float, * and G=double float. We are swapping n in chunks of m. So WSWAPL is * a word-swap of a longword (i.e. we swap the first and second words). * and BSWAPG is a byte-swap of a double (i.e. total reversal of byte order * across all 8 bytes). For float and double values, we don't do bit * swapping of any sort (just B, W, and L). So if the network format of * the floating value is too damn obscure, something more complicated * has to be done... */#define BSWAPW(src, dst) { NetValue _t; _t.s = src; \ ((char *)&dst)[0] = _t.sC[1]; ((char *)&dst)[1] = _t.sC[0]; \}#define BSWAPL(src, dst) { NetValue _t; _t.lU = src; \ ((char *)&dst)[0] = _t.lC[3]; ((char *)&dst)[1] = _t.lC[2]; \ ((char *)&dst)[2] = _t.lC[1]; ((char *)&dst)[3] = _t.lC[0]; \}#define WSWAPL(src, dst) { NetValue _t; _t.lU = src; \ ((short *)&dst)[0] = _t.lS[1]; ((short *)&dst)[1] = _t.lS[0]; \}#define BSWAPF(src, dst) { NetValue _t; _t.f = src; \ ((char *)&dst)[0] = _t.fC[3]; ((char *)&dst)[1] = _t.fC[2]; \ ((char *)&dst)[2] = _t.fC[1]; ((char *)&dst)[3] = _t.fC[0]; \}#define WSWAPF(src, dst) { NetValue _t; _t.f = src; \ ((short *)&dst)[0] = _t.fS[1]; ((short *)&dst)[1] = _t.fS[0]; \}#define BSWAPG(src, dst) { NetValue _t; _t.g = src; \ ((char *)&dst)[0] = _t.gC[7]; ((char *)&dst)[1] = _t.gC[6]; \ ((char *)&dst)[2] = _t.gC[5]; ((char *)&dst)[3] = _t.gC[4]; \ ((char *)&dst)[4] = _t.gC[3]; ((char *)&dst)[5] = _t.gC[2]; \ ((char *)&dst)[6] = _t.gC[1]; ((char *)&dst)[7] = _t.gC[0]; \}#define WSWAPG(src, dst) { NetValue _t; _t.g = src; \ ((short *)&dst)[0] = _t.gS[3]; ((short *)&dst)[1] = _t.gS[2]; \ ((short *)&dst)[2] = _t.gS[1]; ((short *)&dst)[3] = _t.gS[0]; \}#define LSWAPG(src, dst) { NetValue _t; _t.g = src; \ ((long *)&dst)[0] = _t.gL[1]; ((long *)&dst)[1] = _t.gL[0]; \}// GL color in floattypedef struct _Color { float r, g, b, a;} Color;/** *@author Gabor Torok */typedef struct _ParticleStruct { GLfloat x, y, z; GLint height; int life; GLfloat moveDelta; int maxLife; int trail; float rotate; float zoom;} ParticleStruct;#define SINGLE_TARGET 0#define GROUP_TARGET 1class Constants {public: // creature movement enum motion { MOTION_MOVE_TOWARDS=0, MOTION_MOVE_AWAY, // flee MOTION_LOITER };// This stores the speed of the animation between each key frame for md2 models// A higher value means a *faster* animation and NOT a *smoother* animation.// The smoothing of the animation is only determined by fps. // So this value should not be modified. Maybe later there will be an// animation_speed for each creature, to give the feeling some are faster than others ?#define ANIMATION_SPEED 5.0f // The map's dimensions#define MAP_WIDTH 600#define MAP_DEPTH 600// How big is the on-screen view. Should be calculated.#define MAP_VIEW_WIDTH 100#define MAP_VIEW_DEPTH 110#define MAP_VIEW_HEIGHT 16 // How big is 1 map chunk#define MAP_UNIT 16#define MAP_UNIT_OFFSET 2#define MAP_WALL_HEIGHT 12 // How far from the edge to start drawing in map#define MAP_OFFSET 55 // define some active region labels enum { INV_PLAYER_0 = 0, INV_PLAYER_1, INV_PLAYER_2, INV_PLAYER_3, INV_MODE_INVENTORY, INV_MODE_PROPERTIES, INV_MODE_SPELLS, INV_MODE_LOG, MENU_0, MENU_1, MENU_2, MENU_3, MENU_4, ESCAPE, SHOW_INVENTORY, SHOW_OPTIONS, SKILL_LIST, ITEM_LIST, DIAMOND_FORMATION, STAGGERED_FORMATION, SQUARE_FORMATION, ROW_FORMATION, SCOUT_FORMATION, CROSS_FORMATION, PLAYER_1, PLAYER_2, PLAYER_3, PLAYER_4, PLAYER_ONLY, MOVE_ITEM_TO_PLAYER_0, MOVE_ITEM_TO_PLAYER_1, MOVE_ITEM_TO_PLAYER_2, MOVE_ITEM_TO_PLAYER_3, DROP_ITEM, EQUIP_ITEM, FIX_ITEM, ENCHANT_ITEM, REMOVE_CURSE_ITEM, COMBINE_ITEM, IDENTIFY_ITEM }; // Directions (a bitfield so they can be combined) static const Uint16 MOVE_UP = 1; static const Uint16 MOVE_DOWN = 2; static const Uint16 MOVE_LEFT = 4; static const Uint16 MOVE_RIGHT = 8; enum { NORTH=0, EAST, SOUTH, WEST }; // messages enum { WELCOME=0, ITEM_OUT_OF_REACH, DOOR_BLOCKED, SINGLE_MODE,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -