From 0ec7dd3b79c2f0e16d93b1ff7910c073f3d0ddde Mon Sep 17 00:00:00 2001 From: Polonkai Gergely Date: Tue, 6 Mar 2012 08:41:05 +0100 Subject: [PATCH] Started adding races support Started adding Races support, based on http://www.circlemud.org/pub/CircleMUD/contrib/code/players/races.txt Signed-off-by: Polonkai Gergely --- src/races.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/structs.h | 10 ++++++++ src/utils.h | 2 ++ 3 files changed, 82 insertions(+) create mode 100644 src/races.c diff --git a/src/races.c b/src/races.c new file mode 100644 index 0000000..c975041 --- /dev/null +++ b/src/races.c @@ -0,0 +1,70 @@ +#include "sysdep.h" +#include "conf.h" +#include "structs.h" +#include "interpreter.h" +#include "utils.h" + +const char *race_abbrevs[] = { + "Hao", + "Utn", + "Dua", + "\n" +}; + +const char *pc_race_types[] = { + "Haoon", + "Utnir", + "Duaron", + "\n" +}; + +const char *race_menu = "\r\n" +"Select race:\r\n" +"(1) Haoon\r\n" +"(2) Utnir\r\n" +"(3) Duaron\r\n"; + +int +parse_race(char arg) +{ + arg = LOWER(arg); + + switch (arg) + { + case '1': + return RACE_HAOON; + break; + case '2': + return RACE_UTNIR; + break; + case '3': + return RACE_DUARON; + break; + default: + return RACE_UNDEFINED; + break; + } +} + +long +find_race_bitvector(char arg) +{ + arg = LOWER(arg); + + switch (arg) + { + case '1': + return (1 << 0); + break; + case '2': + return (1 << 1); + break; + case '3': + return (1 << 2); + break; + default: + return 0; + break; + } +} + diff --git a/src/structs.h b/src/structs.h index 57bb131..fc6ecdb 100644 --- a/src/structs.h +++ b/src/structs.h @@ -130,6 +130,13 @@ #define CLASS_DRAGON 4 #define CLASS_GIANT 5 +/* Race */ +#define RACE_UNDEFINED (-1) +#define RACE_HAOON 0 +#define RACE_UTNIR 1 +#define RACE_DUARON 2 + +#define NUM_RACES 3 /* This must be the number of races! */ /* Sex */ #define SEX_NEUTRAL 0 @@ -263,6 +270,7 @@ #define CON_DELCNF1 15 /* Delete confirmation 1 */ #define CON_DELCNF2 16 /* Delete confirmation 2 */ #define CON_DISCONNECT 17 /* In-game link loss (leave character) */ +#define CON_QRACE 18 /* Race? */ /* Character equipment positions: used as index for char_data.equipment[] */ /* NOTE: Don't confuse these constants with the ITEM_ bitvectors @@ -734,6 +742,7 @@ struct char_player_data { char *title; /* PC / NPC's title */ byte sex; /* PC / NPC's sex */ byte chclass; /* PC / NPC's class */ + byte race; /* PC / NPC's race */ byte level; /* PC / NPC's level */ sh_int hometown; /* PC s Hometown (zone) */ struct time_data time; /* PC's AGE in days */ @@ -943,6 +952,7 @@ struct char_file_u { char title[MAX_TITLE_LENGTH+1]; byte sex; byte chclass; + byte race; byte level; sh_int hometown; time_t birth; /* Time of birth of character */ diff --git a/src/utils.h b/src/utils.h index 75c3df5..b135311 100644 --- a/src/utils.h +++ b/src/utils.h @@ -275,6 +275,7 @@ void update_pos(struct char_data *victim); GET_LEVEL(ch)) #define GET_CLASS(ch) ((ch)->player.chclass) +#define GET_RACE(ch) ((ch)->player.race) #define GET_HOME(ch) ((ch)->player.hometown) #define GET_HEIGHT(ch) ((ch)->player.height) #define GET_WEIGHT(ch) ((ch)->player.weight) @@ -483,6 +484,7 @@ void update_pos(struct char_data *victim); #define CLASS_ABBR(ch) (IS_NPC(ch) ? "--" : class_abbrevs[(int)GET_CLASS(ch)]) +#define RACE_ABBR(ch) (IS_NPC(ch) ? "--" : race_abbrevs[(int)GET_RACE(ch)]) #define IS_MAGIC_USER(ch) (!IS_NPC(ch) && \ (GET_CLASS(ch) == CLASS_MAGIC_USER))