Crossfire Server, Branch 1.12  R12190
describe.c
Go to the documentation of this file.
00001 /*
00002     CrossFire, A Multiplayer game for X-windows
00003 
00004     Copyright (C) 2007 Mark Wedel & Crossfire Development Team
00005     Copyright (C) 1992 Frank Tore Johansen
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 
00021     The authors can be reached via e-mail at crossfire-devel@real-time.com
00022 */
00027 #include <global.h>
00028 #include <ob_methods.h>
00029 #include <ob_types.h>
00030 
00039 void common_ob_describe(const ob_methods *context, const object *op, const object *observer, char *buf, size_t size) {
00040     char name[VERY_BIG_BUF];
00041 
00042     buf[0] = '\0';
00043 
00044     if (op == NULL)
00045         return;
00046 
00047     describe_item(op, observer, name, VERY_BIG_BUF);
00048     if (name[0] != '\0') {
00049         size_t len;
00050 
00051         query_name(op, buf, size-1);
00052         buf[size-1] = 0;
00053         len = strlen(buf);
00054         if ((len+5) < size) {
00055             /* Since we know the length, we save a few cpu cycles by using
00056              * it instead of calling strcat */
00057             strcpy(buf+len, " ");
00058             len++;
00059             strncpy(buf+len, name, size-len-1);
00060             buf[size-1] = 0;
00061         }
00062     }
00063     if (buf[0] == '\0') {
00064         query_name(op, buf, size-1);
00065         buf[size-1] = 0;
00066     }
00067 }