char *rcsid_common_init_c = "$Id: init.c,v 1.22 2005/07/10 10:19:02 ryo_saeba Exp $"; /* Crossfire client, a client program for the crossfire program. Copyright (C) 2001 Mark Wedel & Crossfire Development Team 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. The author can be reached via e-mail to crossfire-devel@real-time.com */ /* This handles the initialization of the client. This includes making * the I_IMAGE and I_ARCH commands. */ #include #include "p_cmd.h" /* init_commands() */ /* XXX Does the x11 client *use* these? */ /* Makes the load/save code trivial - basically, the * entries here match the same numbers as the CONFIG_ values defined * in common/client.h - this means the load and save just does * something like a fprintf(outifle, "%s: %d", config_names[i], * want_config[i]); */ char *config_names[CONFIG_NUMS] = { NULL, "colorinv", "colortext", "download_all_images", "echo_bindings", "fasttcpsend", "command_window", "cacheimages", "fog_of_war", "iconscale", "mapscale", "popups", "sdl", "showicon", "tooltips", "sound", "splitinfo", "split", "show_grid", "lighting", "trim_info_window", "map_width", "map_height", "foodbeep", "darkness", "port", "grad_color_bars", "resists", "smoothing", "nosplash", "auto_apply_container" }; sint16 want_config[CONFIG_NUMS], use_config[CONFIG_NUMS]; #define TEST_FREE_AND_CLEAR(xyz) {if (xyz) { free(xyz); xyz=NULL; } } void VersionCmd(char *data, int len) { char *cp; csocket.cs_version = atoi(data); /* set sc_version in case it is an old server supplying only one version */ csocket.sc_version = csocket.cs_version; if (csocket.cs_version != VERSION_CS) { LOG(LOG_WARNING,"common::VersionCmd","Differing C->S version numbers (%d,%d)", VERSION_CS,csocket.cs_version); /* exit(1);*/ } cp = strchr(data,' '); if (!cp) return; csocket.sc_version = atoi(cp); if (csocket.sc_version != VERSION_SC) { LOG(LOG_WARNING,"common::VersionCmd","Differing S->C version numbers (%d,%d)", VERSION_SC,csocket.sc_version); } cp = strchr(cp+1, ' '); if (cp) LOG(LOG_INFO,"common::VersionCmd","Playing on server type %s", cp); } void SendVersion(ClientSocket csock) { cs_print_string(csock.fd, "version %d %d %s", VERSION_CS, VERSION_SC, VERSION_INFO); } void SendAddMe(ClientSocket csock) { cs_print_string(csock.fd, "addme"); } void SendSetFaceMode(ClientSocket csock,int mode) { cs_print_string(csock.fd, "setfacemode %d", mode); } void init_client_vars() { int i; /* I think environemental variables should be more important than * compiled in defaults, so these probably should be reversed. */ client_libdir=getenv("CFCLIENT_LIBDIR"); #ifdef CLIENT_LIBDIR if (client_libdir==NULL) client_libdir=CLIENT_LIBDIR; #endif cpl.count_left = 0; cpl.container = NULL; memset(&cpl.stats,0, sizeof(Stats)); cpl.stats.maxsp=1; /* avoid div by 0 errors */ cpl.stats.maxhp=1; /* ditto */ cpl.stats.maxgrace=1; /* ditto */ /* ditto - displayed weapon speed is weapon speed/speed */ cpl.stats.speed=1; cpl.input_text[0]='\0'; cpl.title[0] = '\0'; cpl.range[0] = '\0'; cpl.last_command[0] = '\0'; for (i=0; i number mapping so that we don't * need to rebuild all the images. */ face_info.old_bmaps_checksum = face_info.bmaps_checksum; face_info.bmaps_checksum = 0; face_info.cache_hits=0; face_info.cache_misses=0; face_info.have_faceset_info=0; for (i=0; i