Crossfire Server, Branches 1.12  R18729
describe.c
Go to the documentation of this file.
1 /*
2  CrossFire, A Multiplayer game for X-windows
3 
4  Copyright (C) 2007 Mark Wedel & Crossfire Development Team
5  Copyright (C) 1992 Frank Tore Johansen
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21  The authors can be reached via e-mail at crossfire-devel@real-time.com
22 */
27 #include <global.h>
28 #include <ob_methods.h>
29 #include <ob_types.h>
30 
39 void common_ob_describe(const ob_methods *context, const object *op, const object *observer, char *buf, size_t size) {
40  char name[VERY_BIG_BUF];
41 
42  buf[0] = '\0';
43 
44  if (op == NULL)
45  return;
46 
47  describe_item(op, observer, name, VERY_BIG_BUF);
48  if (name[0] != '\0') {
49  size_t len;
50 
51  query_name(op, buf, size-1);
52  buf[size-1] = 0;
53  len = strlen(buf);
54  if ((len+5) < size) {
55  /* Since we know the length, we save a few cpu cycles by using
56  * it instead of calling strcat */
57  strcpy(buf+len, " ");
58  len++;
59  strncpy(buf+len, name, size-len-1);
60  buf[size-1] = 0;
61  }
62  }
63  if (buf[0] == '\0') {
64  query_name(op, buf, size-1);
65  buf[size-1] = 0;
66  }
67 }
void common_ob_describe(const ob_methods *context, const object *op, const object *observer, char *buf, size_t size)
Definition: describe.c:39
#define VERY_BIG_BUF
Definition: define.h:82
void describe_item(const object *op, const object *owner, char *retbuf, size_t size)
Definition: item.c:1018
void query_name(const object *op, char *buf, size_t size)
Definition: item.c:628