36 #define MAXITEMLEN 300 50 unsigned int flags = 0;
123 int flags, len, anim_speed;
150 len = strlen(item_n);
155 len = strlen(item_n);
158 strncpy(item_n+len+1, item_p, 127);
160 item_n[len+1+127] = 0;
161 len += strlen(item_n+1+len)+1;
175 anim_speed = (int)(1.0/
FABS(head->
speed));
177 if (anim_speed > 255)
195 int got_one = 0, start_look = 0, end_look = 0, objects_sent = 0;
200 LOG(
llevDebug,
"esrv_draw_look called when update_look was not set\n");
237 snprintf(buf,
sizeof(buf),
"Click here to see previous group of items");
283 snprintf(buf,
sizeof(buf),
"Click here to see next group of items");
317 int got_one = 0, start_look = 0, end_look = 0, objects_sent = 0;
336 snprintf(buf,
sizeof(buf),
"Click here to see previous group of items");
364 snprintf(buf,
sizeof(buf),
"Click here to see next group of items");
454 int32_t weight =
WEIGHT(op);
481 strlcpy(item_n, custom_name,
sizeof(item_n)-1);
482 strlcpy(item_p, custom_name,
sizeof(item_p));
485 len = strlen(item_n)+1;
486 snprintf(item_n+len,
sizeof(item_n)-len,
"%s", item_p);
487 len += strlen(item_n+len);
507 if (anim_speed > 255)
611 if (pl->
count == count)
615 if (op->count == count)
619 if (tmp->count == count)
626 if (
HEAD(op)->count == count)
630 if (tmp->count == count)
638 if (tmp->count == count)
650 if (len <= 0 || !buf) {
658 LOG(
llevDebug,
"Player '%s' tried to examine the unknown object (%ld)\n", pl->
ob->
name, tag);
672 if (!buf || len <= 0) {
688 if (tag&0x80000000) {
701 LOG(
llevDebug,
"Player '%s' tried to apply the unknown object (%d)\n", pl->
ob->
name, tag);
724 "Could not find object to lock/unlock");
730 "Can't lock/unlock an item on the ground");
733 if (op->
env != pl->
ob) {
735 "Can't lock/unlock an item not directly in your inventory");
743 "Unlocked %s.", name);
781 "Could not find object to mark");
855 "You see nothing there.");
873 if (len <= 0 || !buf) {
879 if (!(cp = strchr(buf,
' '))) {
886 "You can't see there from where you're standing.");
892 "You can't see there from where you're standing.");
904 LOG(
llevDebug,
"Player '%s' tried to move an unknown object (%lu)\n", pl->
name, (
unsigned long)tag);
914 if (op->
map && !op->
env) {
930 }
else if (to == pl->
count) {
948 LOG(
llevDebug,
"Player '%s' tried to move object to the unknown location (%d)\n", pl->
name, to);
965 object *scroll, *spell, *marked, *inscription, *currentspell;
966 tag_t tscroll, tspell, tmarked;
992 LOG(
llevDebug,
"Player %s sent an invalid scroll for inscribe command.\n", pl->
ob->
name);
998 LOG(
llevDebug,
"Player %s sent an invalid spell for inscribe command.\n", pl->
ob->
name);
#define FLAG_KNOWN_BLESSED
Item is known to be blessed.
void do_dump(object *who, object *what)
void SockList_AddPrintf(SockList *sl, const char *format,...)
Adds a printf like formatted string.
void esrv_send_inventory(object *pl, object *op)
Sends inventory of a container.
object * ranges[range_size]
Object for each range.
#define FLAG_DAMNED
The object is very cursed.
#define FLAG_UNPAID
Object hasn't been paid for yet.
static bool player_can_see(player *pl, int dx, int dy)
void SockList_Reset(SockList *sl)
Resets the length of the stored data for writing.
#define NS_FACESENT_FACE
Bitmask for the faces_sent[] array - what portion of the face have we sent?
#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.
void look_at(object *op, int dx, int dy)
Prints items on the specified square.
void apply_cmd(char *buf, int len, player *pl)
Client wants to apply some object.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
#define FABS(x)
Decstations have trouble with fabs()...
int GetInt_String(const unsigned char *data)
Basically does the reverse of SockList_AddInt, but on strings instead.
#define MSG_TYPE_COMMAND_FAILURE
Failed result from command.
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
uint16_t look_position
Start of drawing of look window.
#define FLAG_IS_FLOOR
Can't see what's underneath this object.
#define LOOK_OBJ(ob)
This returns TRUE if the object is something that should be displayed in the look window...
object * below
Pointer to the object stacked below this one.
uint32_t count
Any numbers typed before a command.
#define HUGE_BUF
Used for messages - some can be quite long.
#define MSG_TYPE_COMMAND_EXAMINE
Player examining something.
void SockList_AddShort(SockList *sl, uint16_t data)
Adds a 16 bit value.
Socket structure, represents a client-server connection.
static object * esrv_get_ob_from_count(object *pl, tag_t count)
Takes a player and object count (tag) and returns the actual object pointer, or null if it can't be f...
object * above
Pointer to the object stacked above this one.
int8_t blocked_los[MAP_CLIENT_X][MAP_CLIENT_Y]
Array showing what spaces the player can see.
bool player_can_find(object *op, object *ob)
Return true if player 'op' can see object 'op' for purpose of locating items for partial item matchin...
int sack_can_hold(const object *pl, const object *sack, const object *op, uint32_t nrof)
Check if an item op can be put into a sack.
int16_t y
Position in the map for this object.
#define FLAG_BLESSED
Item has a blessing, opposite of cursed/damned.
uint16_t container_position
Start of container contents to send to client.
void SockList_AddInt(SockList *sl, uint32_t data)
Adds a 32 bit value.
animal 'body parts' -b.t.
Global type definitions and header inclusions.
struct player * contr
Pointer to the player which control this object.
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
uint8_t anim_speed
Ticks between animation-frames.
#define FOR_OB_AND_BELOW_FINISH()
Finishes FOR_OB_AND_BELOW_PREPARE().
#define FLAG_REMOVED
Object is not in any map or invenory.
object * transport
Transport the player is in.
#define FLAG_KNOWN_MAGICAL
The object is known to be magical.
static std::shared_ptr< inja::Environment > env
Rendering environment.
void look_at_cmd(char *buf, int len, player *pl)
Client wants to look at some object.
#define MAP_IN_MEMORY
Map is fully loaded.
uint32_t update_look
If true, we need to send the look window.
#define MSG_TYPE_COMMAND
Responses to commands, eg, who.
int apply_by_living(object *pl, object *op, int aflag, int quiet)
Living thing is applying an object.
uint8_t num_look_objects
The maximum number of objects to show on the ground view; this number includes the prev/next group fa...
#define MSG_TYPE_COMMAND_SUCCESS
Successful result from command.
#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.
char path[HUGE_BUF]
Filename of the map.
object * env
Pointer to the object which is the environment.
#define QUERY_FLAG(xyz, p)
void SockList_Term(SockList *sl)
Frees all resources allocated by a SockList instance.
void query_name(const object *op, char *buf, size_t size)
Describes an item.
#define FLAG_IDENTIFIED
Item is identifiable (e.g.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
socket_struct * socket
Socket information for this player.
const Animations * animation
Animation of this item, NULL if not animated.
#define WEIGHT(op)
Returns the weight of the given object.
int out_of_map(mapstruct *m, int x, int y)
Return 1 if coordinates X and Y are out of the map M, taking into account tiling. ...
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.
void esrv_draw_look(object *pl)
Send the look window.
object * ob
The object representing the player.
const Face * face
Face with colors.
void examine_cmd(char *buf, int len, player *pl)
Client wants to examine some object.
Defines various structures and values that are used for the new client server communication method...
int is_identified(const object *op)
Return true if the item is identified, either because it is of a type that doesn't ever need identifi...
uint32_t mark_count
Count of marked object.
void examine(object *op, object *tmp)
Player examines some object.
int32_t last_weight
Last weight as sent to client; -1 means do not send weight.
#define MSG_TYPE_SKILL_FAILURE
Failure in using skill.
size_t SockList_Avail(const SockList *sl)
Returns the available bytes in a SockList instance.
uint32_t update_inventory
If true, we need to send the inventory list.
#define MAXITEMLEN
This is the maximum number of bytes we expect any one item to take up.
uint16_t number
This is the image unique identifier.
void esrv_move_object(object *pl, tag_t to, tag_t tag, long nrof)
Move an object to a new location.
uint32_t tag_t
Object tag, unique during the whole game.
void mark_item_cmd(uint8_t *data, int len, player *pl)
Client wants to mark some object.
#define HEAD(op)
Returns the head part of an object.
#define FLAG_WIZ
Object has special privilegies.
#define MAX_BUF
Used for all kinds of things.
void put_object_in_sack(object *op, object *sack, object *tmp, uint32_t nrof)
Something tries to put an object into another.
int16_t invisible
How much longer the object will be invis.
size_t strlcpy(char *dst, const char *src, size_t size)
Portable implementation of strlcpy(3).
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...
struct mapstruct * map
Pointer to the map in which this object is present.
#define MAP_CLIENT_X
This determines the maximum map size the client can request (and thus what the server will send to th...
object * mark
Marked object.
int object_can_pick(const object *who, const object *item)
Finds out if an object can be picked up.
uint32_t in_memory
Combination of IN_MEMORY_xxx flags.
static const flag_definition flags[]
Flag mapping.
void inventory(object *op, object *inv)
Prints object's inventory.
void SockList_AddChar(SockList *sl, unsigned char c)
Adds an 8 bit value.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
#define FLAG_KNOWN_CURSED
The object is known to be cursed.
object * object_merge(object *op, object *top)
This function goes through all objects below and including top, and merges op to the first matching o...
#define FLAG_CURSED
The object is cursed.
#define FLAG_ANIMATE
The object looks at archetype for faces.
uint16_t num
Where we are in the array.
Object structure, the core of Crossfire.
void query_base_name(const object *op, int plural, char *buf, size_t size)
Query a short name for the item.
static event_registration m
object * container
Current container being used.
void esrv_send_animation(socket_struct *ns, const Animations *anim)
Need to send an animation sequence to the client.
void lock_item_cmd(uint8_t *data, int len, player *pl)
Client wants to apply some object.
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.
Also see SKILL_TOOL (74) below.
sstring name
The name of the object, obviously...
Only for debugging purposes.
uint32_t nrof
Number of objects.
uint8_t anims_sent[MAXANIMNUM]
What animations we sent.
void esrv_update_item(int flags, object *pl, object *op)
Updates object *op for player *pl.
void SockList_AddLen8Data(SockList *sl, const void *data, size_t len)
Adds a data block prepended with an 8 bit length field.
#define CLEAR_FLAG(xyz, p)
uint8_t type
PLAYER, BULLET, etc.
int transport_can_hold(const object *transport, const object *op, int nrof)
Can transport hold object op? This is a pretty trivial function, but in the future, possible transport may have more restrictions or weight reduction like containers.
#define FLAG_APPLIED
Object is ready for use by living.
void esrv_send_item(object *pl, object *op)
Sends item's info to player.
uint16_t client_type
Public type information.
object * inv
Pointer to the first object in the inventory.
#define FOR_OB_AND_BELOW_PREPARE(op_)
Constructs a loop iterating over an object and all objects below it in the same pile.
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
#define MSG_TYPE_SKILL
Messages related to skill use.
#define NDI_UNIQUE
Print immediately, don't buffer.
static void add_object_to_socklist(socket_struct *ns, SockList *sl, object *head)
Used in the send_look to put object head into SockList sl for socket ns.
bool pick_up(object *op, object *alt)
Try to pick up an item.
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
void inscribe_scroll_cmd(char *buf, int len, player *pl)
Contains the base information we use to make up a packet we want to send.
tag_t count
Unique object number for this object.
#define FLAG_NO_PICK
Object can't be picked up.
int write_on_item(object *pl, const char *params, object *skill)
Implement the 'inscription' skill, which checks for the required skills and marked items before runni...
#define FLAG_NO_SKILL_IDENT
If set, item cannot be identified w/ a skill.
uint8_t mapy
How large a map the client wants.
void query_short_name(const object *op, char *buf, size_t size)
query_short_name(object) is similar to query_name(), but doesn't contain any information about object...
#define FLAG_INV_LOCKED
Item will not be dropped from inventory.
object * drop_object(object *op, object *tmp, uint32_t nrof)
Try to drop an object on the floor.
void esrv_del_item(player *pl, object *ob)
Tells the client to delete an item.
object * find_skill_by_name(object *who, const char *name)
This returns the skill pointer of the given name (the one that accumulates exp, has the level...
uint8_t * faces_sent
This is a bitmap on sent face status.
#define CUSTOM_NAME_FIELD
Key in an object for the player-assigned custom name.
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
static unsigned int query_flags(const object *op)
This is a similar to query_name, but returns flags to be sended to client.
void Send_With_Handling(socket_struct *ns, SockList *sl)
Calls Write_To_Socket to send data to the client.
static object * ob_if_can_find(object *op, object *ob)
Return object 'ob' if player 'op' can find it, otherwise return NULL.