summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-14 07:01:29 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-14 07:01:29 +0000
commit4b7d62bb60b9559290a67645368e2dd72865e173 (patch)
tree54195fa092df6890c39cfcb542af8655cc14f040
parent7f78db9414b3c2dd97da70ce74198f0360cdedc6 (diff)
downloadcrawl-ref-4b7d62bb60b9559290a67645368e2dd72865e173.tar.gz
crawl-ref-4b7d62bb60b9559290a67645368e2dd72865e173.zip
Removed SHORT_FILE_NAMES for Windows builds.
Fixed poisoned needles not stacking correctly. Allow character names to end with digits on multiuser systems. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@628 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/AppHdr.h3
-rw-r--r--crawl-ref/source/dungeon.cc4
-rw-r--r--crawl-ref/source/files.cc14
-rw-r--r--crawl-ref/source/newgame.cc85
4 files changed, 38 insertions, 68 deletions
diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h
index 5ce561d512..c43f4789d3 100644
--- a/crawl-ref/source/AppHdr.h
+++ b/crawl-ref/source/AppHdr.h
@@ -173,7 +173,6 @@
#elif defined(WIN32CONSOLE) && (defined(__IBMCPP__) || defined(__MINGW32__))
#include "libw32c.h"
#define PLAIN_TERM
- #define SHORT_FILE_NAMES
#define EOL "\n"
#define CHARACTER_SET A_ALTCHARSET
#define getstr(X,Y) getConsoleString(X,Y)
@@ -188,7 +187,7 @@
// linked in.
// #define REGEX_PCRE
#else
- #error unsupported compiler
+ #error Missing platform #define or unsupported compiler.
#endif
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 59fed1ab5f..fe4457cd91 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -3274,8 +3274,8 @@ void give_item(int mid, int level_number) //mv: cleanup+minor changes
if (xitt == MI_NEEDLE)
set_item_ego_type(mitm[thing_created], OBJ_MISSILES,
got_curare_roll(give_level)?
- SPMSL_CURARE
- : SPMSL_POISONED);
+ SPMSL_CURARE
+ : SPMSL_POISONED_II);
mitm[thing_created].x = 0;
mitm[thing_created].y = 0;
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index 5653948834..757783a045 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -208,7 +208,7 @@ static std::string uid_as_string()
{
#ifdef MULTIUSER
char struid[20];
- snprintf( struid, sizeof struid, "%d", (int)getuid() );
+ snprintf( struid, sizeof struid, "-%d", (int)getuid() );
return std::string(struid);
#else
return std::string();
@@ -229,13 +229,7 @@ static bool is_uid_file(const std::string &name, const std::string &ext)
std::string::size_type suffix_pos = name.find(save_suffix);
return (suffix_pos != std::string::npos
&& suffix_pos == name.length() - save_suffix.length()
- && suffix_pos != 0
-#ifdef MULTIUSER
- // See verifyPlayerName() in newgame.cc
- && !isdigit(name[suffix_pos - 1])
-#endif
- );
-
+ && suffix_pos != 0);
}
bool is_save_file_name(const std::string &name)
@@ -347,6 +341,10 @@ static bool create_dirs(const std::string &dir)
path += segments[i];
path += FILE_SEPARATOR;
+ // Handle absolute paths correctly.
+ if (i == 0 && dir.size() && dir[0] == FILE_SEPARATOR)
+ path = FILE_SEPARATOR + path;
+
if (!dir_exists(path) && create_directory(path.c_str()))
return (false);
}
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index a0d4581159..21cabb3540 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -93,9 +93,9 @@ extern std::string init_file_location;
#define MIN_START_STAT 1
static bool class_allowed(unsigned char speci, int char_class);
-static bool validate_player_name(void);
+static bool validate_player_name(bool verbose);
static void choose_weapon(void);
-static void enterPlayerName(bool blankOK);
+static void enter_player_name(bool blankOK);
static void give_basic_knowledge(int which_job);
static void give_basic_spells(int which_job);
static void give_basic_mutations(unsigned char speci);
@@ -281,7 +281,7 @@ static bool check_saved_game(void)
{
FILE *handle;
- std::string basename = get_savedir_filename( you.your_name, "", "");
+ std::string basename = get_savedir_filename( you.your_name, "", "" );
std::string savename = basename + ".sav";
#ifdef LOAD_UNPACKAGE_CMD
@@ -289,7 +289,7 @@ static bool check_saved_game(void)
handle = fopen(zipname.c_str(), "rb+");
if (handle != NULL)
{
- fclose(handle);
+ fclose(handle);
cprintf(EOL "Loading game..." EOL);
// Create command
@@ -298,7 +298,7 @@ static bool check_saved_game(void)
const std::string directory = get_savedir();
snprintf( cmd_buff, sizeof(cmd_buff), LOAD_UNPACKAGE_CMD,
- basename.c_str(), directory.c_str() );
+ basename.c_str(), directory.c_str() );
if (system( cmd_buff ) != 0)
{
@@ -373,7 +373,7 @@ bool new_game(void)
}
openingScreen();
- enterPlayerName(true);
+ enter_player_name(true);
if (you.your_name[0] != 0)
{
@@ -417,7 +417,7 @@ bool new_game(void)
cprintf( info );
- enterPlayerName(false);
+ enter_player_name(false);
if (check_saved_game())
{
@@ -2017,7 +2017,7 @@ static void preprocess_character_name(char *name, bool blankOK)
*name = 0;
}
-static bool is_good_name(char *name, bool blankOK)
+static bool is_good_name(char *name, bool blankOK, bool verbose)
{
preprocess_character_name(name, blankOK);
@@ -2027,7 +2027,8 @@ static bool is_good_name(char *name, bool blankOK)
if (blankOK)
return (true);
- cprintf(EOL "That's a silly name!" EOL);
+ if (verbose)
+ cprintf(EOL "That's a silly name!" EOL);
return (false);
}
@@ -2041,11 +2042,12 @@ static bool is_good_name(char *name, bool blankOK)
// as level files for a character named "bones". -- bwr
if (stricmp(you.your_name, "bones") == 0)
{
- cprintf(EOL "That's a silly name!" EOL);
+ if (verbose)
+ cprintf(EOL "That's a silly name!" EOL);
return (false);
}
#endif
- return (validate_player_name());
+ return (validate_player_name(verbose));
}
static int newname_keyfilter(int &ch)
@@ -2101,7 +2103,7 @@ static bool read_player_name(
}
}
-static void enterPlayerName(bool blankOK)
+static void enter_player_name(bool blankOK)
{
int prompt_start = wherey();
bool ask_name = true;
@@ -2112,7 +2114,7 @@ static void enterPlayerName(bool blankOK)
if (you.your_name[0] != 0)
ask_name = false;
- if (blankOK)
+ if (blankOK && (ask_name || !is_good_name(you.your_name, false, false)))
{
existing_chars = find_saved_characters();
@@ -2150,39 +2152,20 @@ static void enterPlayerName(bool blankOK)
name[kNameLen - 1] = 0;
}
}
- while (ask_name = !is_good_name(you.your_name, blankOK));
-} // end enterPlayerName()
+ while (ask_name = !is_good_name(you.your_name, blankOK, true));
+} // end enter_player_name()
-static bool validate_player_name(void)
+static bool validate_player_name(bool verbose)
{
#if defined(DOS) || defined(WIN32CONSOLE)
- static int william_tanksley_asked_for_this = 2;
-
// quick check for CON -- blows up real good under DOS/Windows
if (stricmp(you.your_name, "con") == 0
- || stricmp(you.your_name, "nul") == 0)
+ || stricmp(you.your_name, "nul") == 0
+ || stricmp(you.your_name, "prn") == 0
+ || strnicmp(you.your_name, "LPT", 3) == 0)
{
- cprintf(EOL "Sorry, that name gives your OS a headache." EOL);
- return (false);
- }
-
- // quick check for LPTx -- thank you, Mr. Tanksley! ;-)
- if (strnicmp(you.your_name, "LPT", 3) == 0)
- {
- switch (william_tanksley_asked_for_this)
- {
- case 2:
- cprintf(EOL "Hello, William! How is work on Omega going?" EOL);
- break;
- case 1:
- cprintf(EOL "Look, it's just not a legal name." EOL);
- break;
- case 0:
- strcpy(you.your_name, "William");
- return (true);
- } // end switch
-
- william_tanksley_asked_for_this--;
+ if (verbose)
+ cprintf(EOL "Sorry, that name gives your OS a headache." EOL);
return (false);
}
#endif
@@ -2197,27 +2180,17 @@ static bool validate_player_name(void)
// play it very conservative here. -- bwr
if (!isalnum(c) && c != '-' && c != '.' && c != '_' && c != ' ')
{
- cprintf( EOL
- "Alpha-numerics, spaces, dashes, periods and underscores "
- "only, please."
- EOL );
+ if (verbose)
+ cprintf( EOL
+ "Alpha-numerics, spaces, dashes, periods "
+ "and underscores only, please."
+ EOL );
return (false);
}
}
-#ifdef MULTIUSER
- // Until we have a better way to handle the fact that this could lead
- // to some confusion with where the name ends and the uid begins. -- bwr
- const size_t len = strlen( you.your_name );
- if (isdigit( you.your_name[ len - 1 ] ))
- {
- cprintf( EOL "Sorry, your name cannot end with a digit." EOL );
- return (false);
- }
-#endif
-
return (true);
-} // end verifyPlayerName()
+} // end validate_player_name()
#if 0
// currently unused