|
Crossfire Client, Trunk
R18666
|
00001 /* 00002 * static char *rcsid_common_client_h = 00003 * "$Id: client.h 14099 2010-11-15 07:21:33Z mwedel $"; 00004 */ 00005 /* 00006 Crossfire client, a client program for the crossfire program. 00007 00008 Copyright (C) 2001,2007,2010 Mark Wedel & Crossfire Development Team 00009 00010 This program is free software; you can redistribute it and/or modify 00011 it under the terms of the GNU General Public License as published by 00012 the Free Software Foundation; either version 2 of the License, or 00013 (at your option) any later version. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00023 00024 The author can be reached via e-mail to crossfire-devel@real-time.com 00025 */ 00026 00033 #include <config.h> 00034 #include <version.h> 00035 #include <client-types.h> 00036 #include <shared/newclient.h> 00037 #include <item.h> 00038 00039 #ifdef HAVE_DMALLOC_H 00040 # include <dmalloc.h> 00041 #endif 00042 00043 #define MULTKEYS 00044 00045 #define VERSION_CS 1023 00046 #define VERSION_SC 1029 00047 00048 extern char VERSION_INFO[256]; 00049 00054 #define COMMAND_WINDOW 10 00055 00056 #define STRINGCOMMAND 0 00057 00062 #define MAX_SKILL CS_NUM_SKILLS 00063 00064 #define MAXANIM 2000 00065 00071 #define SC_NORMAL 0 00072 #define SC_FIRERUN 1 00073 #define SC_ALWAYS 2 00074 00076 typedef struct Animations { 00077 uint16 flags; 00078 uint8 num_animations; 00082 uint8 speed; 00083 uint8 speed_left; 00084 uint8 phase; 00085 uint16 *faces; 00086 00087 } Animations; 00088 00089 extern Animations animations[MAXANIM]; 00090 00091 #define CAN_SMOOTH(__SQUARE,__LEVEL) ( ( \ 00092 (__SQUARE.heads[__LEVEL].face==0) \ 00093 && (__LEVEL >0) \ 00094 ) \ 00095 || (__SQUARE.smooth[layer]) \ 00096 ) 00097 00104 typedef struct ClientSocket { 00105 int fd; 00106 SockList inbuf; 00107 int cs_version, sc_version; 00109 int command_sent, command_received; 00114 int command_time; 00117 char* servername; 00118 } ClientSocket; 00119 00120 extern ClientSocket csocket; 00121 00122 extern char *server, *client_libdir,*image_file, *sound_server; 00123 00124 typedef enum Input_State { 00125 Playing, Reply_One, Reply_Many, Configure_Keys, Command_Mode, 00126 Metaserver_Select 00127 } Input_State; 00128 00129 typedef enum rangetype { 00130 range_bottom = -1, range_none = 0, range_bow = 1, range_magic = 2, 00131 range_wand = 3, range_rod = 4, range_scroll = 5, range_horn = 6, 00132 range_steal = 7, 00133 range_size = 8 00134 } rangetype; 00135 00170 #define CONFIG_DOWNLOAD 1 00171 #define CONFIG_ECHO 2 00172 #define CONFIG_FASTTCP 3 00173 #define CONFIG_CWINDOW 4 00174 #define CONFIG_CACHE 5 00175 #define CONFIG_FOGWAR 6 00176 #define CONFIG_ICONSCALE 7 00177 #define CONFIG_MAPSCALE 8 00178 #define CONFIG_POPUPS 9 00179 #define CONFIG_DISPLAYMODE 10 00180 #define CONFIG_SHOWICON 11 00181 #define CONFIG_TOOLTIPS 12 00182 #define CONFIG_SOUND 13 00183 #define CONFIG_SPLITINFO 14 00184 #define CONFIG_SPLITWIN 15 00185 #define CONFIG_SHOWGRID 16 00186 #define CONFIG_LIGHTING 17 00187 #define CONFIG_TRIMINFO 18 00188 #define CONFIG_MAPWIDTH 19 00189 #define CONFIG_MAPHEIGHT 20 00190 #define CONFIG_FOODBEEP 21 00191 #define CONFIG_DARKNESS 22 00192 #define CONFIG_PORT 23 00193 #define CONFIG_GRAD_COLOR 24 00194 #define CONFIG_RESISTS 25 00195 #define CONFIG_SMOOTH 26 00196 #define CONFIG_SPLASH 27 00197 #define CONFIG_APPLY_CONTAINER 28 00198 #define CONFIG_MAPSCROLL 29 00200 #define CONFIG_SIGNPOPUP 30 00201 #define CONFIG_TIMESTAMP 31 00202 #define CONFIG_NUMS 32 00205 00206 00211 #define CFG_LT_NONE 0 00212 #define CFG_LT_TILE 1 00213 #define CFG_LT_PIXEL 2 00214 #define CFG_LT_PIXEL_BEST 3 00215 00222 #define CFG_DM_PIXMAP 0 00223 #define CFG_DM_SDL 1 00224 #define CFG_DM_OPENGL 2 00225 00227 extern sint16 want_config[CONFIG_NUMS], use_config[CONFIG_NUMS]; 00228 00229 extern const char *const config_names[CONFIG_NUMS]; 00234 typedef struct Stat_struct { 00235 sint8 Str; 00236 sint8 Dex; 00237 sint8 Con; 00238 sint8 Wis; 00239 sint8 Cha; 00240 sint8 Int; 00241 sint8 Pow; 00242 sint8 wc; 00243 sint8 ac; 00244 sint8 level; 00245 sint16 hp; 00246 sint16 maxhp; 00247 sint16 sp; 00248 sint16 maxsp; 00249 sint16 grace; 00250 sint16 maxgrace; 00251 sint64 exp; 00252 sint16 food; 00255 sint16 dam; 00258 sint32 speed; 00259 sint32 weapon_sp; 00262 uint32 attuned; 00265 uint32 repelled; 00268 uint32 denied; 00269 uint16 flags; 00270 sint16 resists[30]; 00271 uint32 resist_change:1; 00272 sint16 skill_level[MAX_SKILL]; 00273 sint64 skill_exp[MAX_SKILL]; 00274 uint32 weight_limit; 00275 } Stats; 00276 00277 typedef struct Spell_struct { 00278 struct Spell_struct *next; 00279 char name[256]; 00280 char message[10000]; 00282 uint32 tag; 00284 uint16 level; 00285 uint16 time; 00286 uint16 sp; 00287 uint16 grace; 00288 uint16 dam; 00292 uint8 skill_number; 00296 char *skill; 00298 uint32 path; 00302 sint32 face; 00305 uint8 usage; 00310 char requirements[256]; 00316 } Spell; 00317 00318 typedef struct Player_Struct { 00319 item *ob; 00320 item *below; 00322 item *container; 00323 uint16 count_left; 00324 Input_State input_state; 00325 char last_command[MAX_BUF]; 00326 char input_text[MAX_BUF]; 00327 item *ranges[range_size]; 00329 uint8 ready_spell; 00330 char spells[255][40]; 00332 Stats stats; 00333 Spell *spelldata; 00334 char title[MAX_BUF]; 00335 char range[MAX_BUF]; 00336 uint32 spells_updated; 00337 uint32 fire_on:1; 00338 uint32 run_on:1; 00339 uint32 meta_on:1; 00340 uint32 alt_on:1; 00341 uint32 no_echo:1; 00342 uint32 count; 00343 uint16 mmapx, mmapy; 00344 uint16 pmapx, pmapy; 00346 uint8 *magicmap; 00347 uint8 showmagic; 00349 uint16 mapxres,mapyres; 00352 #ifdef MULTKEYS 00353 char name[ 40 ]; 00355 #endif 00356 } Client_Player; 00357 00363 #define MAX_FACE_SETS 20 00364 #define MAX_IMAGE_SIZE 320 00372 00373 typedef struct FaceSets_struct { 00374 uint8 setnum; 00375 uint8 fallback; 00376 char *prefix; 00377 char *fullname; 00378 char *size; 00379 char *extension; 00380 char *comment; 00381 } FaceSets; 00382 00387 typedef struct Face_Information_struct { 00388 uint8 faceset; 00389 char *want_faceset; 00390 sint16 num_images; 00391 uint32 bmaps_checksum, old_bmaps_checksum; 00398 sint16 cache_hits, cache_misses; 00399 uint8 have_faceset_info; 00402 FaceSets facesets[MAX_FACE_SETS]; 00403 } Face_Information; 00404 00405 extern Face_Information face_info; 00406 00407 extern Client_Player cpl; 00408 extern char *skill_names[MAX_SKILL]; 00409 00410 extern int last_used_skills[MAX_SKILL+1]; 00414 typedef enum LogLevel { 00415 LOG_DEBUG = 0, LOG_INFO = 1, LOG_WARNING = 2, LOG_ERROR = 3, LOG_CRITICAL = 4 00416 } LogLevel; 00417 00418 typedef struct LogEntry { 00419 char* message; 00420 char* origin; 00421 LogLevel level; 00422 struct LogEntry* next; 00423 } LogEntry; 00424 extern LogEntry* LogFirst; 00425 extern LogEntry* LogLast; 00426 extern int logcount; 00427 typedef void (*LogListener)(LogEntry*); 00428 #define MAX_LOGS 200 00429 #define LOG_APPEND(_Entry) if (LogLast) {\ 00430 LogLast->next=_Entry;\ 00431 } else {\ 00432 LogFirst=_Entry;\ 00433 };\ 00434 LogLast=_Entry;_Entry->next=NULL;\ 00435 if (++logcount > MAX_LOGS)\ 00436 {\ 00437 LogEntry* old = LogFirst;\ 00438 LogFirst = LogFirst -> next;\ 00439 if (old->message) free (old->message);\ 00440 if (old->origin) free (old->origin);\ 00441 } 00442 #define LOG_NEW_ENTRY (LogEntry*)calloc(1,sizeof(LogEntry)) 00443 #define LOG_SETMESSAGE(_Entry,_msg) free(_Entry->message);_Entry->message=strdup(_msg) 00444 #define LOG_SETORIGIN(_Entry,_orig) free(_Entry->origin);_Entry->origin=strdup(_orig) 00445 00446 typedef struct PipeLog { 00447 char* name; 00448 LogLevel level; 00449 int log; 00450 }PipeLog; 00451 00452 #define CHILD_STDIN 1 00453 #define CHILD_STDOUT 2 00454 #define CHILD_STDERR 4 00455 #define CHILD_SILENTFAIL 8 00456 #define CHILD_TUBE (CHILD_STDIN|CHILD_STDOUT|CHILD_STDERR) 00457 typedef struct ChildProcess{ 00458 char* name; 00459 int flag; 00460 int pid; 00461 int tube[3]; 00462 PipeLog logger[3]; 00463 struct ChildProcess* next; 00464 }ChildProcess; 00465 00466 #define CHILD_PIPEIN(__child) (__child->tube[0]) 00467 #define CHILD_PIPEOUT(__child) (__child->tube[1]) 00468 #define CHILD_PIPEERR(__child) (__child->tube[2]) 00469 00473 #define NUM_RESISTS 18 00474 00475 extern const char *const resists_name[NUM_RESISTS]; 00476 extern char *meta_server; 00477 extern int meta_port; 00478 extern int metaserver_on, metaserver2_on, serverloginmethod, wantloginmethod; 00479 extern uint32 tick; 00480 00484 typedef struct { 00485 const char *name; 00486 int value; 00487 } NameMapping; 00488 00489 extern NameMapping skill_mapping[MAX_SKILL], resist_mapping[NUM_RESISTS]; 00490 00491 extern uint64 *exp_table; 00492 extern uint16 exp_table_max; 00493 00498 #define MAP_MAX_SIZE 31 00499 00507 #define MIN_ALLOCATED_MAP_SIZE MAP_MAX_SIZE * 2 00508 00514 #define MAX_MAP_OFFSET 8 00515 00516 /* Start of map handling code. 00517 * 00518 * For the most part, this actually is not window system specific, but 00519 * certainly how the client wants to store this may vary. 00520 */ 00521 00522 #define MAXPIXMAPNUM 10000 00523 00531 typedef struct Cache_Entry { 00532 char *filename; 00533 uint32 checksum; 00534 uint32 ispublic:1; 00535 void *image_data; 00536 struct Cache_Entry *next; 00537 } Cache_Entry; 00538 00550 #define RI_IMAGE_INFO 0x1 00551 #define RI_IMAGE_SUMS 0x2 00552 00554 extern int replyinfo_status, requestinfo_sent, replyinfo_last_face; 00555 00556 typedef struct PlayerPosition { 00557 int x; 00558 int y; 00559 } PlayerPosition; 00560 00561 extern PlayerPosition pl_pos; 00562 00563 typedef struct Msg_Type_Names { 00564 int type; 00565 int subtype; 00566 const char *style_name; 00569 } Msg_Type_Names; 00570 00571 extern TextManager* firstTextManager; 00572 00573 /* declared/handled in commands.c . These variables are documented 00574 * in that file - the data they present is created by the command 00575 * code, but consumed by the GUI code. 00576 */ 00577 extern char *motd, *news, *rules; 00578 extern char *motd, *news, *rules; /* Declared/handled in commands.c */ 00579 extern int num_races, used_races, num_classes, used_classes; 00580 extern int stat_points, stat_min, stat_maximum; 00581 00582 00583 00584 /* 00585 * This structure is used to hold race/class adjustment info, as 00586 * received by the requestinfo command. We get the same info 00587 * for both races and class, so it simplifies code to share a structure. 00588 */ 00589 /* This is how many stats (str, dex, con, etc) that are present 00590 * in the create character window. 00591 */ 00592 #define NUM_NEW_CHAR_STATS 7 00593 00600 struct Stat_Mapping { 00601 const char *widget_suffix; /* within the glade file, suffix used on widget */ 00602 uint8 cs_value; /* within the protocol, the CS_STAT value */ 00603 uint8 rc_offset; /* Offset into the stat_adj array */ 00604 }; 00605 00606 extern struct Stat_Mapping stat_mapping[NUM_NEW_CHAR_STATS]; 00607 00617 struct RC_Choice { 00618 char *choice_name; /* name to respond, eg, race_choice_1 */ 00619 char *choice_desc; /* Longer description of choice */ 00620 int num_values; /* How many values we have */ 00621 char **value_arch; /* Array arch names */ 00622 char **value_desc; /* Array of description */ 00623 }; 00624 00625 typedef struct Race_Class_Info { 00626 char *arch_name; /* Name of the archetype this correponds to */ 00627 char *public_name; /* Public (human readadable) name */ 00628 char *description; /* Description of the race/class */ 00629 sint8 stat_adj[NUM_NEW_CHAR_STATS]; /* Adjustment values */ 00630 int num_rc_choice; /* Size of following array */ 00631 struct RC_Choice *rc_choice; /* array of choices */ 00632 } Race_Class_Info; 00633 00634 typedef struct Starting_Map_Info { 00635 char *arch_name; /* Name of archetype for this map */ 00636 char *public_name; /* Name of the human readable name */ 00637 char *description; /* Description of this map */ 00638 } Starting_Map_Info; 00639 00640 extern Race_Class_Info *races, *classes; 00641 extern Starting_Map_Info *starting_map_info; 00642 extern int starting_map_number; 00643 00644 /* End of commands.c data, start of other declarations */ 00645 #ifndef MIN 00646 #define MIN(X__,Y__) ( (X__)<(Y__)?(X__):(Y__) ) 00647 #endif 00648 00655 #define INFO_NEWS 1 00656 #define INFO_MOTD 2 00657 #define INFO_RULES 3 00658 00671 #ifndef WIN32 00672 #define CONVERT_FILESPEC_TO_OS_FORMAT(path) 00673 #else 00674 extern void replace_chars_with_string( 00675 char* buffer, const uint16 buffer_size, 00676 const char find, const char* replace); 00677 #define CONVERT_FILESPEC_TO_OS_FORMAT(path) \ 00678 replace_chars_with_string((path), sizeof(path), '/', "\\") 00679 #endif 00680 00682 #ifndef CPROTO 00683 /* We need to declare most of the structs before we can include this */ 00684 #include <proto.h> 00685 #endif 00686
1.7.6.1