Crossfire Server, Trunk
light_object.c
Go to the documentation of this file.
1
/*
2
* Crossfire -- cooperative multi-player graphical RPG and adventure game
3
*
4
* Copyright (c) 1999-2021 The Crossfire Development Team
5
* Copyright (c) 1992 Frank Tore Johansen
6
*
7
* Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8
* welcome to redistribute it under certain conditions. For details, please
9
* see COPYING and LICENSE.
10
*
11
* The authors can be reached via e-mail at <crossfire@metalforge.org>.
12
*/
13
20
#include "
global.h
"
21
#include "
sproto.h
"
22
36
void
do_light
(
object
*
item
,
const
char
*lighter_name,
object
*applier) {
37
int
is_player_env = 0;
38
tag_t
count
;
39
char
item_name[
MAX_BUF
];
40
uint32_t nrof;
41
/* Perhaps we should split what we are trying to light on fire?
42
* I can't see many times when you would want to light multiple
43
* objects at once. */
44
nrof =
item
->nrof;
45
count
=
item
->count;
46
/* If the item is destroyed, we don't have a valid pointer to the
47
* name object, so make a copy so the message we print out makes
48
* some sense. */
49
safe_strncpy
(item_name,
item
->name,
sizeof
(item_name));
50
if
(applier ==
object_get_player_container
(
item
))
51
is_player_env = 1;
52
53
save_throw_object
(
item
,
AT_FIRE
, applier);
54
55
/* Change to check count and not freed, since the object pointer
56
* may have gotten recycled */
57
if
((nrof !=
item
->nrof) || (
count
!=
item
->count)) {
58
draw_ext_info_format
(
NDI_UNIQUE
, 0, applier,
MSG_TYPE_APPLY
,
MSG_TYPE_APPLY_SUCCESS
,
59
"You light the %s with the %s."
,
60
item_name, lighter_name);
61
62
/* Need to update the player so that the players glow radius
63
* gets changed. */
64
if
(is_player_env)
65
fix_object
(applier);
66
}
else
{
67
draw_ext_info_format
(
NDI_UNIQUE
, 0, applier,
MSG_TYPE_APPLY
,
MSG_TYPE_APPLY_FAILURE
,
68
"You attempt to light the %s with the %s and fail."
,
69
item
->name, lighter_name);
70
}
71
}
global.h
safe_strncpy
#define safe_strncpy
Definition:
compat.h:27
MSG_TYPE_APPLY_SUCCESS
#define MSG_TYPE_APPLY_SUCCESS
Definition:
newclient.h:603
fix_object
void fix_object(object *op)
Definition:
living.c:1126
disinfect.count
int count
Definition:
disinfect.py:7
tag_t
uint32_t tag_t
Definition:
object.h:12
sproto.h
MAX_BUF
#define MAX_BUF
Definition:
define.h:35
NDI_UNIQUE
#define NDI_UNIQUE
Definition:
newclient.h:262
item
Definition:
item.py:1
do_light
void do_light(object *item, const char *lighter_name, object *applier)
Definition:
light_object.c:36
MSG_TYPE_APPLY_FAILURE
#define MSG_TYPE_APPLY_FAILURE
Definition:
newclient.h:604
object_get_player_container
object * object_get_player_container(object *op)
Definition:
object.c:611
save_throw_object
void save_throw_object(object *op, uint32_t type, object *originator)
Definition:
attack.c:196
MSG_TYPE_APPLY
#define MSG_TYPE_APPLY
Definition:
newclient.h:408
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Definition:
main.c:319
AT_FIRE
#define AT_FIRE
Definition:
attack.h:78
crossfire-crossfire-server
types
common
light_object.c
Generated by
1.8.17