54 #include <sys/types.h> 55 #include <netinet/in.h> 56 #include <netinet/tcp.h> 71 #define VALIDCHAR_MSG "The first character must be alphanumeric and the last cannot be a space. None of these characters are allowed: :;/\\[" 92 assert(flags >= 0 && flags <= 15);
96 static int clamp(
int x,
int min,
int max) {
97 return MAX(min,
MIN(x, max));
148 if (len <= 0 || !buf) {
168 for (; buf[s] && buf[s] !=
' '; s++)
174 while (buf[s] ==
' ')
180 for (; buf[s] && buf[s] !=
' '; s++)
184 while (s < len && buf[s] ==
' ')
189 if (!strcmp(cmd,
"sound2")) {
192 }
else if (!strcmp(cmd,
"spellmon")) {
195 monitor_spells = atoi(param);
196 if (monitor_spells < 0 || monitor_spells > 2) {
202 }
else if (!strcmp(cmd,
"darkness")) {
205 darkness = atoi(param);
206 if (darkness != 0 && darkness != 1) {
212 }
else if (!strcmp(cmd,
"map2cmd")) {
215 map2cmd = atoi(param);
221 }
else if (!strcmp(cmd,
"facecache")) {
224 facecache = atoi(param);
225 if (facecache != 0 && facecache != 1) {
231 }
else if (!strcmp(cmd,
"faceset")) {
237 }
else if (!strcmp(cmd,
"mapsize")) {
240 if (sscanf(param,
"%dx%d%n", &x, &y, &n) != 2 || n != (
int)strlen(param)) {
249 if ((x <= 0) && (y <= 0)) {
282 }
else if (!strcmp(cmd,
"tick")) {
286 if (tick != 0 && tick != 1) {
292 }
else if (!strcmp(cmd,
"bot")) {
295 is_bot = atoi(param);
296 if (is_bot != 0 && is_bot != 1) {
302 }
else if (!strcmp(cmd,
"want_pickup")) {
305 want_pickup = atoi(param);
306 if (want_pickup != 0 && want_pickup != 1) {
312 }
else if (!strcmp(cmd,
"num_look_objects")) {
330 }
else if (!strcmp(cmd,
"extended_stats")) {
333 extended_stats = atoi(param);
334 if (extended_stats != 0 && extended_stats != 1) {
340 }
else if (!strcmp(cmd,
"beat")) {
341 int use_beat = atoi(param);
343 if (use_beat != 0 && use_beat != 1) {
351 }
else if (!strcmp(cmd,
"loginmethod")) {
354 loginmethod = atoi(param);
357 if (loginmethod > 2) loginmethod=2;
362 }
else if (!strcmp(cmd,
"notifications")) {
365 notifications = atoi(param);
370 }
else if (!strcmp(cmd,
"newmapcmd")) {
378 }
else if (!strcmp(cmd,
"extendedTextInfos")) {
384 }
else if (!strcmp(cmd,
"itemcmd")) {
390 }
else if (!strcmp(cmd,
"exp64")) {
443 "Warning: Your client is too old to receive map data. Please update to a new client at: " 444 "https://sourceforge.net/projects/crossfire/");
460 const Face *smoothface;
479 "Could not smooth face %s. " 480 "Check that this face has a smoothing pixmap, or remove its smoothlevel.\n",
506 if (len <= 0 || !buf) {
507 LOG(
llevDebug,
"IP '%s' sent bogus ask_smooth_cmd information\n", ns->
host);
534 LOG(
llevDebug,
"Corrupt ncom command - not long enough - discarding\n");
547 strncpy(command, (
char *)buf+6, len-4);
548 command[len-4] =
'\0';
557 "You can not issue commands - state is not ST_PLAYING (%s)",
564 LOG(
llevError,
"Player %s (%s) has negative time - shouldn't do command.\n",
591 if (len <= 0 || !buf) {
600 LOG(
llevError,
"Got reply message with ST_PLAYING input state\n");
653 char *cs_str = strtok_r(buf,
" ", &rest);
654 char *sc_str = strtok_r(NULL,
" ", &rest);
657 if (cs_str == NULL || sc_str == NULL) {
676 LOG(
llevInfo,
"Connection from %s (%s), CS %d, SC %d\n",
711 if (len <= 0 || !buf) {
721 for (i = 0; i < 2; i++) {
723 if (!(buf = strchr(buf,
' '))) {
754 #define AddIfInt64(Old, New, sl, Type) \ 757 SockList_AddChar(sl, Type); \ 758 SockList_AddInt64(sl, New); \ 761 #define AddIfInt(Old, New, sl, Type) \ 764 SockList_AddChar(sl, Type); \ 765 SockList_AddInt(sl, New); \ 768 #define AddIfShort(Old, New, sl, Type) \ 771 SockList_AddChar(sl, Type); \ 772 SockList_AddShort(sl, New); \ 775 #define AddIfFloat(Old, New, sl, Type) \ 778 SockList_AddChar(sl, Type); \ 779 SockList_AddInt(sl, (long)(New*FLOAT_MULTI));\ 782 #define AddIfString(Old, New, sl, Type) \ 783 if (Old == NULL || strcmp(Old, New)) { \ 785 Old = strdup_local(New); \ 786 SockList_AddChar(sl, Type); \ 787 SockList_AddLen8Data(sl, New, strlen(New)); \ 797 for (int16_t i = 1; i < until; i++) {
812 const char *god =
"none";
826 if (QUERY_FLAG(pl->ob, F)) { \ 839 if (strcmp(item->arch->name,
"poisoning") == 0) {
842 if (strcmp(item->arch->name,
"blindness") == 0) {
845 if (item->type ==
FORCE && strcmp(item->name,
"confusion") == 0) {
848 if (item->type ==
SKILL && item->subtype ==
SK_PRAYING && item->title) {
875 if (pl->
ob != NULL) {
891 int16_t golem_hp, golem_maxhp;
899 if (pl->
ob != NULL) {
938 LOG(
llevDebug,
"pruning removed object from last_skill_ob\n");
1074 memset(cell->
faces, face,
sizeof(cell->
faces));
1077 #define MAX_HEAD_POS MAX(MAX_CLIENT_X, MAX_CLIENT_Y) 1114 uint8_t nlayer, smoothlevel = 0;
1144 if (bx < ax || by < ay) {
1145 LOG(
llevError,
"map2_add_ob: bx (%d) or by (%d) is less than ax (%d) or ay (%d)\n", bx, by, ax, ay);
1152 for (l = layer-1; l <= layer+1; l++) {
1155 if (heads[by][bx][l] == head)
1162 if (!heads[by][bx][layer])
1163 heads[by][bx][layer] = head;
1164 else if (layer+1 <
MAP_LAYERS && !heads[by][bx][layer+1])
1165 heads[by][bx][layer+1] = head;
1170 uint16_t face_num = face ? face->
number : 0;
1186 uint8_t len, anim_speed = 0, i;
1215 anim_speed = (int)(1.0/
FABS(ob->
speed));
1263 nlayer = 0x10+layer+(2<<5);
1284 int got_one = 0, poisoned = 0, diseased = 0;
1286 int value, granularity;
1287 const object *
probe;
1304 if (probe == NULL || probe->
level < 15) {
1309 granularity = (probe->
level - 14) / 3;
1310 if (granularity <= 0)
1312 else if (granularity > 30)
1321 else if (value > granularity)
1322 value = granularity;
1326 value = (value * 30) / granularity;
1336 snprintf(name,
sizeof(name),
"hpbar%s%s%s_%d",
1337 poisoned ?
"_poisoned" :
"",
1338 diseased ?
"_diseased" :
"",
1339 (!poisoned && !diseased) ?
"_standard" :
"",
1342 if (dummy != NULL) {
1365 (subtype == 0 || cell->
label_text == label)) {
1378 len = strlen(label);
1379 if (len > 256 - 2 - 1) {
1380 LOG(
llevError,
"The label '%s' is too long to send to the client.", label);
1397 int got_one =
check_probe(ax, ay, ob, sl, ns, has_obj, alive_layer);
1402 if (dummy != NULL) {
1421 }
else if (plyr->
party) {
1452 int layer, got_one = 0, del_one = 0, oldlen, has_obj = 0;
1459 for (layer = 0; layer <
MAP_LAYERS; layer++) {
1462 head = heads[ay][ax][layer];
1467 got_one +=
map2_add_ob(ax, ay, layer, head, sl, ns, &has_obj, 1);
1480 if (!del_one && !got_one) {
1482 }
else if (del_one && !has_obj) {
1499 int x, y, ax, ay,
darkness, min_x, max_x, min_y, max_y, oldlen, layer;
1515 memset(heads, 0,
sizeof(heads));
1529 for (y = min_y; y < max_y; y++, ay++) {
1531 for (x = min_x; x < max_x; x++, ax++) {
1581 int have_darkness = 0, has_obj = 0, got_one = 0, del_one = 0, g1, alive_layer = -1, old_got;
1618 for (layer = 0; layer <
MAP_LAYERS; layer++) {
1635 if (got_one != old_got || ob->
head == NULL) {
1636 got_one +=
annotate_ob(ax, ay, ob, &sl, plyr, &has_obj, &alive_layer);
1637 got_label +=
add_labels(ax, ay, ob, &sl, plyr, &got_one);
1645 if (g1 == has_obj) {
1649 if (layer != alive_layer)
1653 if (got_label == 0) {
1659 if (!del_one && !got_one && !have_darkness) {
1661 }
else if (del_one && !has_obj) {
1683 if (sl.
len > startlen) {
1697 int min_x, min_y, max_x, max_y;
1700 LOG(
llevError,
"draw_client_map called with non player/non eric-server\n");
1724 for (j = min_y; j < max_y; j++) {
1725 for (i = min_x; i < max_x; i++) {
1769 for (x = 0; x < mx; x++) {
1770 for (y = 0; y < my; y++) {
1771 if (x >= ns->
mapx || y >= ns->
mapy) {
1773 memset(&newmap.
cells[x][y], 0,
sizeof(newmap.
cells[x][y]));
1774 }
else if (x+dx < 0 || x+dx >= ns->
mapx || y+dy < 0 || y+dy >= ns->
mapy) {
1776 memset(&newmap.
cells[x][y], 0,
sizeof(newmap.
cells[x][y]));
1823 if (spell->type ==
SPELL) {
1860 if (!pl || !spell || spell->
env != pl->
ob) {
1926 int len, i, skill = 0;
1952 if (!strcmp(spell->
skill, skill_names[i])) {
1966 len = strlen(spell->
msg);
2000 LOG(
llevError,
"esrv_add_spells, tried to add a spell to a NULL player\n");
2023 size = 26+strlen(spell->
name)+(spell->
msg ? strlen(spell->
msg) : 0);
2027 size += 2 + (value ? strlen(value) : 0);
2037 LOG(
llevError,
"Asked to send a non-spell object as a spell\n");
2124 uint16_t faceno = 0;
2135 if (acn->face[0] != 0 ) {
2202 nlen = (
unsigned char)buf[0];
2203 if (nlen >=
MAX_BUF || nlen > *len-2) {
2206 memcpy(name, buf+1, nlen);
2209 plen = (
unsigned char)buf[nlen+1];
2210 if (plen >=
MAX_BUF || plen > *len-2-nlen) {
2213 memcpy(password, buf+2+nlen, plen);
2235 if (len <= 0 || !buf) {
2236 LOG(
llevDebug,
"IP '%s' sent bogus add_player_cmd information\n", ns->
host);
2258 SockList_AddString(&sl,
"failure accountlogin No such account name exists on this server");
2278 LOG(
llevInfo,
"Failed account login for '%s' from %s\n", name, ns->
host);
2334 if (len <= 0 || !buf) {
2335 LOG(
llevDebug,
"IP '%s' sent bogus add_player_cmd information\n", ns->
host);
2373 if (strlen(password)<2) {
2381 SockList_AddString(&sl,
"failure accountnew That account already exists on this server");
2390 "failure accountnew Choose a different account name. " VALIDCHAR_MSG);
2398 "failure accountnew That account name is too long");
2407 "failure accountnew Choose a different password. " VALIDCHAR_MSG);
2415 "failure accountnew That password is too long");
2445 int status, force, nlen;
2449 if (len <= 0 || !buf) {
2450 LOG(
llevDebug,
"IP '%s' sent bogus add_player_cmd information\n", ns->
host);
2502 SockList_AddString(&sl,
"failure accountaddplayer 0 That character is already connected to this account.");
2508 SockList_AddString(&sl,
"failure accountaddplayer 1 That character is already connected to a different account.");
2520 SockList_AddString(&sl,
"failure accountaddplayer 0 That character is already connected to a different account which is currently logged in.");
2542 }
else if (status == 2) {
2543 SockList_AddString(&sl,
"failure accountaddplayer 0 You have reached the maximum number of characters allowed per account.");
2579 if (len <= 0 || !buf) {
2580 LOG(
llevDebug,
"IP '%s' sent bogus account_play_cmd information\n", ns->
host);
2610 for (i=0; chars[i]; i++) {
2611 if (strcmp(chars[i], buf) == 0)
2616 "failure accountplay Character %s is not associated with account %s",
2626 "failure accountplay Character %s is already playing",
2670 #define MAX_CHOICES 100 2680 int status, nlen, choice_num=0, i;
2683 archetype *map=NULL, *race_a=NULL, *class_a=NULL;
2686 if (len <= 0 || !buf) {
2687 LOG(
llevDebug,
"IP '%s' sent bogus create_player_cmd information\n", ns->
host);
2718 SockList_AddString(&sl,
"failure createplayer Player name contains invalid characters");
2725 if (strlen(password)<2) {
2748 if (strlen(password)>17)
2783 if (!strcmp(pl->
ob->
name, name)) {
2819 int i, j, stat_total=0;
2820 char *key, *value, *race=NULL, *class_name=NULL;
2825 memset(&new_stats, 0,
sizeof(
living));
2827 while (nlen < len) {
2836 if ((i == 0) || (nlen + i > len))
break;
2844 key = buf + nlen + 1;
2845 value = strchr(key,
' ');
2851 else if (!
strcasecmp(key,
"class")) class_name = value;
2856 "failure createplayer Invalid starting map");
2870 "Number of choices receive exceed max value: %d>%d\n",
2873 choices[choice_num] = value;
2881 int val = atoi(value);
2887 if (j >= NUM_STATS) {
2891 LOG(
llevError,
"Got unknown key/value from client: %s %s\n", key, value);
2909 "failure createplayer Stat value is out of range - %d must be between %d and %d",
2918 "failure createplayer Total allocated statistics is higher than allowed (%d>%d)",
2934 if (!race_a || race_a->clone.type !=
PLAYER || !class_a || class_a->clone.type !=
CLASS) {
2936 "failure createplayer Invalid or unknown race or class");
2947 "failure createplayer Unable to apply race or class - statistic is out of bounds");
3009 if (pl->
ob->
map == NULL) {
3029 for (i=0; i < choice_num; i++) {
3031 const char *value, *cp;
3035 choiceval = strchr(choices[i],
' ');
3037 LOG(
llevError,
"Choice does not specify value: %s\n", choices[i]);
3047 LOG(
llevError,
"Choice not found in archetype: %s\n", choices[i]);
3050 cp = strstr(value, choiceval);
3052 LOG(
llevError,
"Choice value not found in archetype: %s %s\n",
3053 choices[i], choiceval);
3063 if ((cp[strlen(choiceval)] !=
' ') && (cp[strlen(choiceval)] != 0) &&
3064 (cp != value) && (*(cp-1) !=
' ')) {
3066 LOG(
llevError,
"Choice value matches substring but not entire word: %s substring %s\n",
3072 LOG(
llevError,
"Choice value can not find archetype %s\n", choiceval);
3084 "%s has entered the game.", pl->
ob->
name);
3102 if (len <= 0 || !buf) {
3103 LOG(
llevDebug,
"IP '%s' sent bogus account_password_cmd information\n", ns->
host);
3133 if (strlen(change)<2) {
3143 "failure accountpw Choose a different password. " VALIDCHAR_MSG);
3151 "failure accountpw That password is too long");
3162 error =
"failure accountpw Illegal characters present";
3163 }
else if (status == 2) {
3164 error =
"failure accountpw Invalid account";
3166 error =
"failure accountpw Incorrect current password";
static int map2_add_ob(int ax, int ay, int layer, const object *ob, SockList *sl, socket_struct *ns, int *has_obj, int is_head)
object 'ob' at 'ax,ay' on 'layer' is visible to the client.
static int account_block_create(const socket_struct *ns)
Checks if account creation is blocked for this connection.
void account_char_remove(Account_Chars *chars, const char *pl_name)
This removes a character on this account.
void esrv_add_spells(player *pl, object *spell)
This tells the client to add the spell *spell, if spell is NULL, then add all spells in the player's ...
uint8_t login_method
Login method this client is using.
void map_newmap_cmd(socket_struct *ns)
Sound related function.
void SockList_AddPrintf(SockList *sl, const char *format,...)
Adds a printf like formatted string.
#define CS_STAT_RES_GHOSTHIT
object * ranges[range_size]
Object for each range.
#define CS_STAT_APPLIED_CON
CON changes from gear or skills.
living orig_stats
Permanent real stats of player.
#define AddIfInt64(Old, New, sl, Type)
uint8_t faceset
Set the client is using, default 0.
int16_t last_sp
Last spell cost.
void esrv_send_animation(socket_struct *ns, const Animations *anim)
Need to send an animation sequence to the client.
void update_position(mapstruct *m, int x, int y)
This function updates various attributes about a specific space on the map (what it looks like...
static uint16_t MAP2_COORD_ENCODE(int x, int y, int flags)
Encodes a (x, y) pair suitable for map2 parameters.
#define ST_GET_PARTY_PASSWORD
Player tried to join a password-protected party.
const char * skill_names[MAX_SKILLS]
Will contain a number-name mapping for skills, initialized by init_skills().
uint32_t tick
Client wishes to get tick commands.
void add_me_cmd(char *buf, int len, socket_struct *ns)
The client has requested to be added to the game.
void SockList_Reset(SockList *sl)
Resets the length of the stored data for writing.
void enter_exit(object *op, object *exit_ob)
Tries to move 'op' to exit_ob.
const char *const short_stat_name[NUM_STATS]
Short name of stats.
This represents one animation.
struct archetype * arch
Pointer to archetype.
static int clamp(int x, int min, int max)
#define NS_FACESENT_FACE
Bitmask for the faces_sent[] array - what portion of the face have we sent?
float last_weapon_sp
if diff than weapon_sp, update client.
int account_login(const char *account_name, const char *account_password)
Check if the given account exists, and whether the password is correct.
uint32_t want_pickup
Client wants pickup information when logging in.
#define P_NEED_UPDATE
This space is out of date.
int16_t last_dam
Last damage.
int account_remove_player(const char *account_name, const char *player_name)
Removes a player name from an account.
char * account_name
Name of the account logged in on this socket.
#define CS_STAT_RES_POISON
#define MAX_LIGHT_RADII
Max radii for 'light' object, really large values allow objects that can slow down the game...
void SockList_Init(SockList *sl)
Initializes the SockList instance.
uint8_t starting_stat_min
Minimum value of a starting stat.
#define CF_PARALYZED
Player is paralyzed.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
#define CS_STAT_RES_DRAIN
#define NDI_ALL
Inform all players of this message.
uint32_t last_path_attuned
Last spell attunment sent to client.
#define FABS(x)
Decstations have trouble with fabs()...
void SockList_ResetRead(SockList *sl)
Resets the length of the stored data for reading.
int GetInt_String(const unsigned char *data)
Basically does the reverse of SockList_AddInt, but on strings instead.
Defines various flags that both the new client and new server use.
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
#define AddIfInt(Old, New, sl, Type)
player * add_player(socket_struct *ns, int flags)
Tries to add player on the connection passwd in ns.
#define AddIfString(Old, New, sl, Type)
#define FLAG_FRIENDLY
Will help players.
uint32_t peaceful
If set, won't attack friendly creatures.
#define UPD_SP_GRACE
updspell command flag value.
void esrv_send_pickup(player *pl)
Sends the "pickup" state to pl if client wants it requested.
int account_change_password(const char *account_name, const char *current_password, const char *new_password)
Change an account password.
enum map2_label label_subtype
#define SND_EFFECTS
Those flags are for the 'socket.sound' field.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
#define CF_CONFUSED
Confused by a spell or an item.
const char * account_get_account_for_char(const char *charname)
This looks at all the accounts and sees if charname is associated with any of them.
int account_new(const char *account_name, const char *account_password)
Adds an account.
player * first_player
First player.
int16_t maxgrace
Maximum grace.
#define CS_STAT_GOD_NAME
Name of the god the character worships.
static bool map2_coord_valid(int x)
New face structure - this enforces the notion that data is face by face only - you can not change the...
int save_player(object *op, int flag)
Saves a player to disk.
void send_plugin_custom_message(object *pl, char *buf)
GROS: The following one is used to allow a plugin to send a generic cmd to a player.
static int check_probe(int ax, int ay, const object *ob, SockList *sl, socket_struct *ns, int *has_obj, int *alive_layer)
Check if a hp bar should be added to the map square.
#define MAP_TYPE_DEFAULT
If no map is specified, where character starts.
uint32_t count
Any numbers typed before a command.
void print_ext_msg(socket_struct *ns, int color, uint8_t type, uint8_t subtype, const char *message)
Draws an extended message on the client.
void key_roll_stat(object *op, char key)
Player is currently swapping stats.
partylist * party
Party this player is part of.
void receive_player_password(object *op, const char *password)
A player just entered her password, including for changing it.
sstring add_string(const char *str)
Share a string.
static void check_space_for_heads(int ax, int ay, SockList *sl, socket_struct *ns)
#define SND_MUTE
Don't sent anything for now.
void SockList_AddShort(SockList *sl, uint16_t data)
Adds a 16 bit value.
#define ST_CHANGE_PASSWORD_CONFIRM
Player is confirming new password.
Socket structure, represents a client-server connection.
#define NS_FACESENT_SMOOTH
#define ST_CONFIRM_PASSWORD
New character, confirm password.
int16_t SP_level_spellpoint_cost(object *caster, object *spell, int flags)
Scales the spellpoint cost of a spell by it's increased effectiveness.
#define CF_HOSTILE
'hostile' flag is set.
living last_orig_stats
Last permanent stats sent to client.
int8_t blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]
Array showing what spaces the player can see.
Object for applying character class modifications to someone.
#define FLAG_CONFUSED
Will also be unable to cast spells.
#define FLAG_STEALTH
Will wake monsters with less range.
bool heartbeat
Client will send hearbeats.
int16_t y
Position in the map for this object.
static int decode_name_password(const char *buf, int *len, char *name, char *password)
This is a basic routine which extracts the name/password from the buffer.
#define AddIfShort(Old, New, sl, Type)
int SP_level_dam_adjust(const object *caster, const object *spob)
Returns adjusted damage based on the caster.
uint32_t mode
Mode of player for pickup.
const char * account_exists(const char *account_name)
Checks the existing accounts, and see if this account exists.
uint32_t get_weight_limit(int stat)
sstring add_refcount(sstring str)
Like add_string(), but the string is already a shared string.
uint8_t starting_stat_max
Maximum value of a starting stat.
void SockList_AddInt(SockList *sl, uint32_t data)
Adds a 32 bit value.
#define ST_CHANGE_PASSWORD_NEW
Player is entering new password.
#define CS_STAT_RES_DEATH
This stores, for a spell a player knows, the last sp/gr/dam information sent to client.
void version_cmd(char *buf, int len, socket_struct *ns)
Client tells its version.
int verify_player(const char *name, char *password)
This verify that a character of name exits, and that it matches password.
living applied_stats
Stat changes due to gear or skills.
void account_new_cmd(char *buf, int len, socket_struct *ns)
Handles the account creation This function shares a fair amount of the same logic as account_login_cm...
uint32_t path_repelled
Paths the object is repelled from.
int apply_race_and_class(object *op, archetype *race, archetype *opclass, living *stats)
This is somewhat like key_change_class() above, except we know the race to change to...
#define SP_CREATE_MISSILE
Global type definitions and header inclusions.
#define CF_STEALTHY
Player is stealthy.
struct player * contr
Pointer to the player which control this object.
client_spell * spell_state
Spell information sent to client.
#define ST_ROLL_STAT
New character, rolling stats.
object * object_find_by_arch_name(const object *who, const char *name)
Find object in inventory by archetype name.
One map cell, as sent to the client.
int8_t levgrace[11]
What grace bonus the player gained on that level.
#define ST_PLAYING
Usual state.
#define NDI_DK_ORANGE
DarkOrange2.
uint8_t anim_speed
Ticks between animation-frames.
char * host
Which host it is connected from (ip address).
static void send_smooth(socket_struct *ns, const Face *face)
A lot like the old AskSmooth (in fact, now called by AskSmooth).
void set_attr_value(living *stats, int attr, int8_t value)
Sets Str/Dex/con/Wis/Cha/Int/Pow in stats to value, depending on what attr is (STR to POW)...
archetype * try_find_archetype(const char *name)
#define FLAG_REMOVED
Object is not in any map or invenory.
#define CS_STAT_WEIGHT_LIM
float weapon_speed
The overall speed of this object.
object * transport
Transport the player is in.
Account_Chars * account_chars
Detailed information on characters on this account.
#define MAP_LAYER_LIVING2
#define MAP_TYPE_CHOICE
Choice of maps presented to player.
uint16_t notifications
Notifications this client wants to get.
void create_player_cmd(char *buf, int len, socket_struct *ns)
We have received a createplayer command.
int32_t last_weight_limit
Last weight limit transmitted to client.
int probe(object *op, object *caster, object *spell_ob, int dir, int level)
Try to get information about a living thing.
void account_password(char *buf, int len, socket_struct *ns)
Handles the account password change.
void move_cmd(char *buf, int len, player *pl)
Moves an object (typically, container to inventory).
const Face * try_find_face(const char *name, const Face *error)
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
#define MAP_CLIENT_Y_MINIMUM
#define MAP_IN_MEMORY
Map is fully loaded.
uint32_t update_look
If true, we need to send the look window.
uint32_t facecache
If true, client is caching images.
int16_t level
Level of creature or object.
#define MAX_NUM_LOOK_OBJECTS
The upper bound for the number of objects to send for the 'look' window (container or ground view)...
static const int MAP2_COORD_MAX
player * next
Pointer to next player, NULL if this is last.
void new_player_cmd(uint8_t *buf, int len, player *pl)
This handles the commands issued by the player (ie, north, fire, cast, etc.).
void esrv_update_stats(player *pl)
Sends a statistics update.
#define MSG_TYPE_COMMAND
Responses to commands, eg, who.
int16_t casting_time
Time left before spell goes off.
int get_skill_client_code(const char *skill_name)
Return the code of the skill for a client, the index in the skill_names array.
int ssop_t
Parameter type for setsockopt, different between WIN32 and Linux.
#define FLAG_CLIENT_ANIM_SYNC
Let client animate this, synchronized.
uint32_t sound
Client sound mode.
#define FLAG_ALIVE
Object can fight (or be fought)
int8_t tail_y
Where the lower right most portion of the object is in comparison to the head.
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
#define ADD_PLAYER_NO_STATS_ROLL
Stats provided from client.
uint32_t do_los
If true, need to call update_los() in draw(), and clear.
uint16_t last_item_power
Last value for item_power.
float character_load
Value between 0 and 1 indicating how much the character is overloaded.
void SockList_AddData(SockList *sl, const void *data, size_t len)
Adds a data block.
int account_is_logged_in(const char *name)
This checkes if an account is logged in.
void accounts_save(void)
Save all the account information.
void receive_party_password(object *op, const char *password)
Player entered a party password.
int16_t last_resist[NROFATTACKS]
last resist values sent to client.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
uint8_t num_animations
How many different faces to animate, size of the faces array.
uint8_t num_look_objects
The maximum number of objects to show on the ground view; this number includes the prev/next group fa...
map2_label
Map label subtypes.
#define CS_STAT_RES_HOLYWORD
sstring name
More definite name, like "generate_kobold".
void set_player_socket(player *p, socket_struct *ns)
This copies the data from the socket into the player structure.
void key_change_class(object *op, char key)
This function takes the key that is passed, and does the appropriate action with it (change race...
#define MSG_TYPE_COMMAND_ERROR
Bad syntax/can't use command.
#define FLAG_CLIENT_SENT
We use it to detect cases were the server is trying to send an upditem when we have not actually sent...
float speed
Frequency of object 'moves' relative to server tick rate.
void esrv_remove_spell(player *pl, object *spell)
uint8_t min_name
Minimum characters for an account or player name.
const char * NPC_DIALOG_ARCH
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
static int map2_delete_layer(int ax, int ay, int layer, SockList *sl, socket_struct *ns)
char path[HUGE_BUF]
Filename of the map.
#define ADD_PLAYER_NEW
Name/password provided, so skip to roll stats.
object * env
Pointer to the object which is the environment.
#define FLAG_UNAGGRESSIVE
Monster doesn't attack players.
#define QUERY_FLAG(xyz, p)
#define ST_CONFIRM_QUIT
Player used the 'quit' command, make sure that's ok.
void key_confirm_quit(object *op, char key)
We receive the reply to the 'quit confirmation' message.
#define UPD_SP_DAMAGE
updspell command flag value.
#define BEAT_INTERVAL
Interval between heartbeat requests.
#define MSG_TYPE_ADMIN_PLAYER
Player coming/going/death.
short GetShort_String(const unsigned char *data)
int16_t last_golem_hp
Last golem hp value sent to the client.
uint8_t always_show_hp
'probe' spell HP bars for all living things (0, 1, or 2)
static uint8_t is_perfect(const player *pl)
Check whether the player is perfect relatively to improvement potions.
void SockList_Term(SockList *sl)
Frees all resources allocated by a SockList instance.
void player_set_state(player *pl, uint8_t state)
Set the player's state to the specified one.
void account_char_save(Account_Chars *chars)
Saves the character information for the given account.
#define CS_STAT_APPLIED_INT
INT changes from gear or skills.
#define MAX_HEAD_OFFSET
This basically defines the largest size an archetype may be - it is used for allocation of some struc...
int strcasecmp(const char *s1, const char *s2)
static void append_spell(player *pl, SockList *sl, object *spell)
appends the spell *spell to the Socklist we will send the data to.
struct linked_char * next
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
uint32_t last_character_flags
Last character flags (CS_STAT_CHARACTER_FLAGS) sent to client.
socket_struct * socket
Socket information for this player.
sstring msg
If this is a book/sign/magic mouth/etc.
uint32_t golem_count
To track the golem.
uint8_t smoothlevel
how to smooth this square around
object * head
Points to the main object of a large body.
char password[16]
2 (seed) + 11 (crypted) + 1 (EOS) + 2 (safety) = 16
#define MAP_LAYERS
This correspondes to the map layers in the map2 protocol.
client_spell * get_client_spell_state(player *pl, object *spell)
Gets the (client-side) spell state for specified spell.
#define FLAG_PROBE
Object displays HP information to player.
const Animations * animation
Animation of this item, NULL if not animated.
uint32_t sc_version
Versions of the client.
static void draw_client_map2(object *pl)
void account_login_cmd(char *buf, int len, socket_struct *ns)
Handles the account login.
#define MAX_TIME
If you feel the game is too fast or too slow, change MAX_TIME.
#define CF_POISONED
Poisoned.
#define CS_STAT_TURN_UNDEAD
#define ST_PLAY_AGAIN
Player left through a bed of reality, and can login again.
static const short atnr_cs_stat[NROFATTACKS]
This table translates the attack numbers as used within the program to the value we use when sending ...
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
void SockList_AddString(SockList *sl, const char *data)
Adds a string without length.
uint8_t state
Input state of the player (name, password, etc).
#define FLAG_PARALYZED
Monster or player is paralyzed.
object * ob
The object representing the player.
int16_t last_grace
Last grace cost.
uint32_t fire_on
Player should fire object, not move.
const Face * face
Face with colors.
int find_smooth(const Face *face, const Face **smoothed)
Find the smooth face for a given face.
Defines various structures and values that are used for the new client server communication method...
#define P_OUT_OF_MAP
This space is outside the map.
player * get_player(player *p)
Create a player's object, initialize a player's structure.
Defines and structures related to commands the player can send.
struct Settings settings
Global settings.
void send_query(socket_struct *ns, uint8_t flags, const char *text)
Asks the client to query the user.
static void map_clearcell(struct map_cell_struct *cell, int face, int darkness)
Clears a map cell.
float last_speed
Last speed as sent to client.
int32_t last_weight
Last weight as sent to client; -1 means do not send weight.
void send_tick(player *pl)
#define FLAG_XRAYS
X-ray vision.
int8_t last_level
Last level we sent to client.
object * object_present_in_ob(uint8_t type, const object *op)
Searches for any objects with a matching type variable in the inventory of the given object...
size_t SockList_Avail(const SockList *sl)
Returns the available bytes in a SockList instance.
float last_character_load
Last value sent to the client.
#define UPD_SP_MANA
updspell command flag value.
int16_t bed_y
x,y - coordinates of respawn (savebed).
static void add_char_field(SockList *sl, int type, const char *data)
Basic helper function which adds a piece of data for the accountplayers protocol command.
uint16_t number
This is the image unique identifier.
#define VERSION_CS
Version >= 1023 understand setup cmd.
int16_t dam
How much damage this object does when hitting.
#define CS_STAT_APPLIED_POW
POW changes from gear or skills.
uint32_t pticks
Number of ticks since time reset.
uint32_t last_path_denied
Last spell denied sent to client.
static const object * heads[MAX_HEAD_POS][MAX_HEAD_POS][MAP_LAYERS]
Using a global really isn't a good approach, but saves the over head of allocating and deallocating s...
#define CS_STAT_SPELL_REPEL
char savebed_map[MAX_BUF]
Map where player will respawn after death.
#define MSG_TYPE_ADMIN_VERSION
version info
#define HEAD(op)
Returns the head part of an object.
struct map_cell_struct cells[MAX_CLIENT_X][MAX_CLIENT_Y]
uint32_t path_denied
Paths the object is denied access to.
void ask_smooth_cmd(char *buf, int len, socket_struct *ns)
Tells client the picture it has to use to smooth a picture number given as argument.
uint32_t is_bot
Client shouldn't be reported to metaserver.
#define CS_STAT_APPLIED_DEX
DEX changes from gear or skills.
#define FLAG_WIZ
Object has special privilegies.
void update_los(object *op)
Recalculates the array which specifies what is visible for the given player-object.
living stats
Str, Con, Dex, etc.
#define CS_STAT_CHARACTER_FLAGS
Character flags, like 'confused' and such.
living last_stats
Last stats as sent to client.
#define MAX_BUF
Used for all kinds of things.
#define MIN_NUM_LOOK_OBJECTS
The lower bound for the number of objects to send for the 'look' window (container or ground view)...
int16_t invisible
How much longer the object will be invis.
int64_t last_skill_exp[MAX_SKILLS]
Last exp sent to client.
int16_t last_golem_maxhp
Last golem max hp value sent to the client.
uint32_t extended_stats
Client wants base and maximum statistics information.
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
This is basically the same as out_of_map above(), but instead we return NULL if no map is valid (coor...
float speed_left
How much speed is left to spend this round.
Structure handling character information for an account.
struct mapstruct * map
Pointer to the map in which this object is present.
uint32_t last_path_repelled
Last spell repelled sent to client.
#define MAP_CLIENT_X
This determines the maximum map size the client can request (and thus what the server will send to th...
int8_t levsp[11]
What sp bonus the player gained on that level.
archetype * get_archetype_by_type_subtype(int type, int subtype)
Retrieves an archetype by type and subtype.
void reply_cmd(char *buf, int len, player *pl)
This is a reply to a previous query.
uint32_t in_memory
Combination of IN_MEMORY_xxx flags.
Various statistics of objects.
uint8_t account_block_create
static const flag_definition flags[]
Flag mapping.
void SockList_AddChar(SockList *sl, unsigned char c)
Adds an 8 bit value.
#define CS_STAT_APPLIED_CHA
CHA changes from gear or skills.
object * object_find_by_type_and_name(const object *who, int type, const char *name)
Find object in inventory by type and name.
void command_execute(object *pl, char *command)
Handle a player-issued command.
struct archetype * other_arch
Pointer used for various things - mostly used for what this objects turns into or what this object cr...
uint32_t darkness
True if client wants darkness information.
int is_valid_faceset(int fsn)
Checks specified faceset is valid.
#define GET_MAP_FACE_OBJ(M, X, Y, L)
Gets the layer face of specified square.
struct treasurelist * randomitems
Items to be generated.
void esrv_draw_look(object *pl)
Send the look window.
int account_check_string(const char *str)
Checks a string to make sure it does not have any invalid characters.
int account_link(const char *account_name, const char *player_name)
Adds a player name to an account.
void account_add_player_cmd(char *buf, int len, socket_struct *ns)
Handle accountaddplayer from server (add a character to this account).
uint16_t num
Where we are in the array.
sstring name_pl
The plural name of the object.
#define FLAG_AUTO_APPLY
Will be applied when created.
#define MAP2_TYPE_DARKNESS
Account_Chars * account_char_load(const char *account_name)
For a given account name, load the character information and return it.
static bool add_labels(int ax, int ay, const object *ob, SockList *sl, player *plyr, int *got_one)
Return true if there is a label present on this square.
#define P_NEW_MAP
Coordinates passed result in a new tiled map.
#define MAP_LAYER_LIVING1
Living creatures.
static int annotate_ob(int ax, int ay, const object *ob, SockList *sl, player *plyr, int *has_obj, int *alive_layer)
static event_registration m
static void send_extra_stats(SockList *sl, player *pl)
Send extra stats for the player, if 'notification' is 3.
void esrv_send_face(socket_struct *ns, const Face *face, int nocache)
Sends a face to a client if they are in pixmap mode, nothing gets sent in bitmap mode.
#define FREE_AND_COPY(sv, nv)
Release the shared string if not NULL, and make it a reference to nv.
#define CS_STAT_APPLIED_STR
STR changes from gear or skills.
#define NUM_ANIMATIONS(ob)
void map_reset_swap(mapstruct *m)
Call this when an in-memory map is used or referenced.
uint32_t name_changed
If true, the player has set a name.
Also see SKILL_TOOL (74) below.
player * find_player_socket(const socket_struct *ns)
Return a player for a socket structure.
#define CS_STAT_GOLEM_HP
Golem's current hp, 0 if no golem.
object * last_skill_ob[MAX_SKILLS]
Exp objects sent to client.
uint8_t starting_stat_points
How many stat points character starts with.
int darkness
Cell's darkness.
sstring name
The name of the object, obviously...
int8_t get_attr_value(const living *stats, int attr)
Gets the value of a stat.
void check_login(object *op, const char *password)
Actually login a player, load from disk and such.
static int spell_client_use(const object *spell)
Give the client-side use information for a spell, to know how to use a spell.
Only for debugging purposes.
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_...
uint8_t anims_sent[MAXANIMNUM]
What animations we sent.
void receive_player_name(object *op, const char *name)
A player just entered her name.
#define CS_STAT_RES_DEPLETE
#define MAP_CLIENT_X_MINIMUM
uint16_t last_flags
Fire/run on flags for last tick.
void account_play_cmd(char *buf, int len, socket_struct *ns)
We have received an accountplay command.
void send_account_players(socket_struct *ns)
Upon successful login/account creation, we send a list of characters associated with the account to t...
uint32_t monitor_spells
Client wishes to be informed when their spell list changes.
#define MAP2_COORD_OFFSET
How much the x,y coordinates in the map2 are off from actual upper left corner.
uint32_t run_on
Player should keep moving in dir until run is off.
void set_up_cmd(char *buf, int len, socket_struct *ns)
This is the Setup cmd - easy first implementation.
void SockList_AddLen8Data(SockList *sl, const void *data, size_t len)
Adds a data block prepended with an 8 bit length field.
uint8_t type
PLAYER, BULLET, etc.
void account_char_free(Account_Chars *chars)
This frees all data associated with the character information.
#define ADD_PLAYER_NO_MAP
Do not set the first map.
void esrv_map_scroll(socket_struct *ns, int dx, int dy)
int8_t ac
Armor Class, lower AC increases probability of not getting hit.
#define CS_STAT_APPLIED_WIS
WIS changes from gear or skills.
#define AddIfFloat(Old, New, sl, Type)
#define ST_CHANGE_PASSWORD_OLD
Player is entering old password to change password.
void esrv_new_player(player *pl, uint32_t weight)
Tells the client that here is a player it should start using.
void esrv_update_spells(player *pl)
This looks for any spells the player may have that have changed their stats.
const Face ** faces
The actual faces for the animation.
#define ST_CHANGE_CLASS
New character, choosing class.
living last_applied_stats
Last applied stats sent to the client.
#define SP_SUMMON_MONSTER
int8_t levhp[11]
What hp bonus the player gained on that level.
#define CF_DISEASED
Has at least one disease.
void receive_play_again(object *op, char key)
Player replied to play again / disconnect.
#define FLAG_STARTEQUIP
Object was given to player at start.
method_ret ob_apply(object *op, object *applier, int aflags)
Apply an object by running an event hook or an object method.
static const int MAP2_COORD_MIN
int playername_ok(const char *cp)
Is the player name valid.
#define CS_STAT_SPELL_DENY
sstring skill
Name of the skill this object uses/grants.
int16_t maxsp
Max spell points.
#define NDI_UNIQUE
Print immediately, don't buffer.
#define CS_STAT_RES_BLIND
#define CS_STAT_ITEM_POWER
Equipped item power.
#define FLAG_CLIENT_ANIM_RANDOM
Client animate this, randomized.
#define CS_STAT_GOLEM_MAXHP
Golem's max hp, 0 if no golem.
void set_title(const object *pl, char *buf, size_t len)
Sets player title.
void free_charlinks(linked_char *lc)
Frees a link structure and its next items.
#define SND_MUSIC
Client wants background music info.
int32_t food
How much food in stomach.
char ** account_get_players_for_account(const char *account_name)
Returns an array of strings for the characters on this account - the array is null terminated...
Structure containing object statistics.
int16_t maxhp
Max hit points.
uint8_t subtype
Subtype of object.
#define CF_NOT_PERFECT
Can drink some improvement potions.
#define MAX_SKILLS
This is the maximum number of skills the game may handle.
void rangetostring(const object *pl, char *obuf, size_t len)
Get player's current range attack in obuf.
#define MAP_LAYER_FLY2
Arrows, etc.
Contains the base information we use to make up a packet we want to send.
int16_t item_power
Total item power of objects equipped.
void SockList_AddInt64(SockList *sl, uint64_t data)
Adds a 64 bit value.
object * object_insert_in_ob(object *op, object *where)
This function inserts the object op in the linked list inside the object environment.
int8_t wc
Weapon Class, lower WC increases probability of hitting.
#define ST_GET_NAME
Player just connected.
#define CS_STAT_SPELL_ATTUNE
tag_t count
Unique object number for this object.
static void handle_scroll(socket_struct *socket, SockList *sl)
As part of sending the map2 command, send one or more scroll commands to update the client map to mat...
#define CF_XRAY
Has X-ray.
static bool map2_add_label(int ax, int ay, socket_struct *ns, SockList *sl, enum map2_label subtype, sstring label)
Return true if an update was sent to the client.
void draw_client_map(object *pl)
Draws client map.
uint8_t mapy
How large a map the client wants.
char const * newhash(char const *password)
linked_char * account_get_additional_chars(const char *account_name, const Account_Chars *chars, int *count)
Get a list of character names linked to the specified account which are not listed in chars...
living last_race_stats
Last race stats sent to the client.
#define CS_STAT_OVERLOAD
How much (0 to 1) the character is overloaded.
#define CS_STAT_SKILLINFO
CS_STAT_SKILLINFO is used as the starting index point.
sstring name
Face name, as used by archetypes and such.
uint8_t * faces_sent
This is a bitmap on sent face status.
int check_race_and_class(living *stats, archetype *race, archetype *opclass)
This checks to see if the race and class are legal.
#define CF_WIZARD
Player is DM.
object clone
An object from which to do object_copy()
bool object_value_set(const object *op, const char *const key)
Determine if an extra value is set.
uint16_t faces[MAP_LAYERS]
Face numbers.
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
SockList inbuf
If we get an incomplete packet, this is used to hold the data.
uint32_t path_attuned
Paths the object is attuned to.
const Face * get_face_by_id(uint16_t id)
Get a face from its unique identifier.
#define ST_GET_PASSWORD
Name entered, now for password.
static bool CAN_PROBE(const object *ob)
Determine whether the given object can have an HP bar.
#define FLAG_FREED
Object is in the list of free objects.
void Send_With_Handling(socket_struct *ns, SockList *sl)
Calls Write_To_Socket to send data to the client.
void esrv_move_object(object *pl, tag_t to, tag_t tag, long nrof)
Move an object to a new location.
std::vector< Account_Char * > chars
Characters of the account.
char * account_trusted_host
Block account creation for untrusted hosts.