Crossfire Server, Trunk
describe.c
Go to the documentation of this file.
1
/*
2
* Crossfire -- cooperative multi-player graphical RPG and adventure game
3
*
4
* Copyright (c) 1999-2014 Mark Wedel and 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
22
#include <stdlib.h>
23
#include <string.h>
24
25
#include "
ob_methods.h
"
26
#include "
ob_types.h
"
27
36
void
common_ob_describe
(
const
object
*
op
,
const
object
*observer,
int
use_media_tags,
char
*
buf
,
size_t
size) {
37
char
*desc;
38
39
buf
[0] =
'\0'
;
40
41
if
(
op
== NULL)
42
return
;
43
44
desc =
stringbuffer_finish
(
describe_item
(
op
, observer, use_media_tags, NULL));
45
if
(desc[0] !=
'\0'
) {
46
size_t
len;
47
48
query_name
(
op
,
buf
, size-1);
49
buf
[size-1] = 0;
50
len = strlen(
buf
);
51
if
((len+5) < size) {
52
/* Since we know the length, we save a few cpu cycles by using
53
* it instead of calling strcat */
54
strcpy(
buf
+len,
" "
);
55
len++;
56
strncpy(
buf
+len, desc, size-len-1);
57
buf
[size-1] = 0;
58
}
59
}
60
free(desc);
61
if
(
buf
[0] ==
'\0'
) {
62
query_name
(
op
,
buf
, size-1);
63
buf
[size-1] = 0;
64
}
65
}
global.h
describe_item
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Definition:
item.c:941
query_name
void query_name(const object *op, char *buf, size_t size)
Definition:
item.c:585
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Definition:
stringbuffer.c:76
ob_types.h
give.op
op
Definition:
give.py:33
buf
StringBuffer * buf
Definition:
readable.c:1610
ob_methods.h
common_ob_describe
void common_ob_describe(const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
Definition:
describe.c:36
crossfire-crossfire-server
types
common
describe.c
Generated by
1.8.17