Crossfire Server, Trunk
describe.cpp
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
buf
StringBuffer * buf
Definition:
readable.cpp:1565
common_ob_describe
void common_ob_describe(const object *op, const object *observer, int use_media_tags, char *buf, size_t size)
Definition:
describe.cpp:36
stringbuffer_finish
char * stringbuffer_finish(StringBuffer *sb)
Definition:
stringbuffer.cpp:76
query_name
void query_name(const object *op, char *buf, size_t size)
Definition:
item.cpp:588
describe_item
StringBuffer * describe_item(const object *op, const object *owner, int use_media_tags, StringBuffer *buf)
Definition:
item.cpp:951
ob_types.h
give.op
op
Definition:
give.py:33
ob_methods.h
crossfire-crossfire-server
types
common
describe.cpp
Generated by
1.8.17