--- deliantra/server/common/compat.C 2010/03/26 00:59:20 1.5 +++ deliantra/server/common/compat.C 2010/04/15 22:11:47 1.9 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2002 Mark Wedel & Crossfire Development Team * Copyright (©) 1992 Frank Tore Johansen * @@ -59,22 +59,16 @@ ///////////////////////////////////////////////////////////////////////////// -static const char *const fatalmsgs[80] = { - "Failed to allocate memory", - "Failed repeatedly to load maps", - "Hashtable for archetypes is too small", - "Too many errors" -}; - /* * fatal() is meant to be called whenever a fatal signal is intercepted. * It will call the emergency_save and the clean_tmp_files functions. */ +//TODO: only one caller left void -fatal (int err) +fatal (const char *msg) { - LOG (llevError, "Fatal: %s\n", fatalmsgs [err]); - cleanup (fatalmsgs[err], 1); + LOG (llevError, "FATAL: %s\n", msg); + cleanup (msg, 1); } ///////////////////////////////////////////////////////////////////////////// @@ -316,67 +310,12 @@ return (path); } -/** - * open_and_uncompress() first searches for the original filename. If it exist, - * then it opens it and returns the file-pointer. - */ -FILE * -open_and_uncompress (const char *name, int flag, int *compressed) -{ - *compressed = 0; - return fopen (name, "r"); -} - -/* - * See open_and_uncompress(). - */ - -void -close_and_delete (FILE * fp, int compressed) -{ - fclose (fp); -} - -/* - * Strip out the media tags from a String. - * Warning the input string will contain the result string - */ -void -strip_media_tag (char *message) -{ - int in_tag = 0; - char *dest; - char *src; - - src = dest = message; - while (*src != '\0') - { - if (*src == '[') - { - in_tag = 1; - } - else if (in_tag && (*src == ']')) - in_tag = 0; - else if (!in_tag) - { - *dest = *src; - dest++; - } - src++; - } - *dest = '\0'; -} - #define EOL_SIZE (sizeof("\n")-1) void strip_endline (char *buf) { - if (strlen (buf) < sizeof ("\n")) - { - return; - } - if (!strcmp (buf + strlen (buf) - EOL_SIZE, "\n")) - buf[strlen (buf) - EOL_SIZE] = '\0'; + if (*buf && buf [strlen (buf) - 1] == '\n') + buf [strlen (buf) - 1] = '\0'; } /**