ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/plugins.C
(Generate patch)

Comparing deliantra/server/server/plugins.C (file contents):
Revision 1.8 by root, Tue Aug 29 05:03:55 2006 UTC vs.
Revision 1.9 by root, Sun Sep 3 00:18:42 2006 UTC

1/* 1/*
2 * static char *rcsid_plugins_c = 2 * static char *rcsid_plugins_c =
3 * "$Id: plugins.C,v 1.8 2006/08/29 05:03:55 root Exp $"; 3 * "$Id: plugins.C,v 1.9 2006/09/03 00:18:42 root Exp $";
4 */ 4 */
5 5
6/*****************************************************************************/ 6/*****************************************************************************/
7/* CrossFire, A Multiplayer game for X-windows */ 7/* CrossFire, A Multiplayer game for X-windows */
8/* */ 8/* */
45 45
46#define NR_OF_HOOKS 74 46#define NR_OF_HOOKS 74
47 47
48static const hook_entry plug_hooks[NR_OF_HOOKS] = 48static const hook_entry plug_hooks[NR_OF_HOOKS] =
49{ 49{
50 {cfapi_system_add_string, 0, "cfapi_system_add_string"},
51 {cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"}, 50 {cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"},
52 {cfapi_system_remove_string, 2, "cfapi_system_remove_string"},
53 {cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event"}, 51 {cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event"},
54 {cfapi_system_check_path, 4, "cfapi_system_check_path"}, 52 {cfapi_system_check_path, 4, "cfapi_system_check_path"},
55 {cfapi_system_re_cmp, 5, "cfapi_system_re_cmp"}, 53 {cfapi_system_re_cmp, 5, "cfapi_system_re_cmp"},
56 {cfapi_system_strdup_local, 6, "cfapi_system_strdup_local"}, 54 {cfapi_system_strdup_local, 6, "cfapi_system_strdup_local"},
57 {cfapi_system_directory, 7, "cfapi_system_directory"}, 55 {cfapi_system_directory, 7, "cfapi_system_directory"},
501 499
502 va_end(args); 500 va_end(args);
503 return NULL; 501 return NULL;
504} 502}
505 503
506void* cfapi_system_add_string(int *type, ...)
507{
508 va_list args;
509 const char* str;
510 char* rv;
511
512 va_start(args, type);
513 str = va_arg(args, char*);
514 va_end(args);
515
516 rv = (char*)add_string(str);
517 *type = CFAPI_STRING;
518 return rv;
519}
520
521void* cfapi_system_remove_string(int *type, ...)
522{
523 va_list args;
524 char* str;
525
526 va_start(args, type);
527 str = va_arg(args, char*);
528 va_end(args);
529
530 free_string(str);
531 *type = CFAPI_NONE;
532 return NULL;
533}
534void* cfapi_system_check_path(int* type, ...) 504void* cfapi_system_check_path(int* type, ...)
535{ 505{
536 va_list args; 506 va_list args;
537 static int rv; 507 static int rv;
538 char* name; 508 char* name;
1242 rv = query_name(op); 1212 rv = query_name(op);
1243 *type = CFAPI_STRING; 1213 *type = CFAPI_STRING;
1244 break; 1214 break;
1245 1215
1246 case CFAPI_OBJECT_PROP_NAME_PLURAL: 1216 case CFAPI_OBJECT_PROP_NAME_PLURAL:
1247 rv = (char*)op->name_pl; 1217 rv = (char*)&op->name_pl;
1248 *type = CFAPI_STRING; 1218 *type = CFAPI_STRING;
1249 break; 1219 break;
1250 1220
1251 case CFAPI_OBJECT_PROP_TITLE: 1221 case CFAPI_OBJECT_PROP_TITLE:
1252 rv = (char*)op->title; 1222 rv = (char*)&op->title;
1253 *type = CFAPI_STRING; 1223 *type = CFAPI_STRING;
1254 break; 1224 break;
1255 1225
1256 case CFAPI_OBJECT_PROP_RACE: 1226 case CFAPI_OBJECT_PROP_RACE:
1257 rv = (char*)op->race; 1227 rv = (char*)&op->race;
1258 *type = CFAPI_STRING; 1228 *type = CFAPI_STRING;
1259 break; 1229 break;
1260 1230
1261 case CFAPI_OBJECT_PROP_SLAYING: 1231 case CFAPI_OBJECT_PROP_SLAYING:
1262 rv = (char*)op->slaying; 1232 rv = (char*)&op->slaying;
1263 *type = CFAPI_STRING; 1233 *type = CFAPI_STRING;
1264 break; 1234 break;
1265 1235
1266 case CFAPI_OBJECT_PROP_SKILL: 1236 case CFAPI_OBJECT_PROP_SKILL:
1267 rv = (char*)op->skill; 1237 rv = (char*)&op->skill;
1268 *type = CFAPI_STRING; 1238 *type = CFAPI_STRING;
1269 break; 1239 break;
1270 1240
1271 case CFAPI_OBJECT_PROP_MESSAGE: 1241 case CFAPI_OBJECT_PROP_MESSAGE:
1272 rv = (char*)op->msg; 1242 rv = (char*)&op->msg;
1273 if (rv == NULL) 1243 if (rv == NULL)
1274 rv = (void*)""; 1244 rv = (void*)"";
1275 *type = CFAPI_STRING; 1245 *type = CFAPI_STRING;
1276 break; 1246 break;
1277 1247
1278 case CFAPI_OBJECT_PROP_LORE: 1248 case CFAPI_OBJECT_PROP_LORE:
1279 rv = (char*)op->lore; 1249 rv = (char*)&op->lore;
1280 *type = CFAPI_STRING; 1250 *type = CFAPI_STRING;
1281 break; 1251 break;
1282 1252
1283 case CFAPI_OBJECT_PROP_X: 1253 case CFAPI_OBJECT_PROP_X:
1284 ri = op->x; 1254 ri = op->x;
1365 ri = op->material; rv = &ri; 1335 ri = op->material; rv = &ri;
1366 *type = CFAPI_INT; 1336 *type = CFAPI_INT;
1367 break; 1337 break;
1368 1338
1369 case CFAPI_OBJECT_PROP_MATERIAL_NAME: 1339 case CFAPI_OBJECT_PROP_MATERIAL_NAME:
1370 rv = (char*)op->materialname; 1340 rv = (char*)&op->materialname;
1371 *type = CFAPI_STRING; 1341 *type = CFAPI_STRING;
1372 break; 1342 break;
1373 1343
1374 case CFAPI_OBJECT_PROP_MAGIC: 1344 case CFAPI_OBJECT_PROP_MAGIC:
1375 ri = op->magic; rv = &ri; 1345 ri = op->magic; rv = &ri;
1510 rv = op->other_arch; 1480 rv = op->other_arch;
1511 *type = CFAPI_PARCH; 1481 *type = CFAPI_PARCH;
1512 break; 1482 break;
1513 1483
1514 case CFAPI_OBJECT_PROP_CUSTOM_NAME: 1484 case CFAPI_OBJECT_PROP_CUSTOM_NAME:
1515 rv = (char*)op->custom_name; 1485 rv = (char*)&op->custom_name;
1516 *type = CFAPI_STRING; 1486 *type = CFAPI_STRING;
1517 break; 1487 break;
1518 1488
1519 case CFAPI_OBJECT_PROP_ANIM_SPEED: 1489 case CFAPI_OBJECT_PROP_ANIM_SPEED:
1520 ri = op->anim_speed; rv = &ri; 1490 ri = op->anim_speed; rv = &ri;
1737 rv = (char*)determine_god(op); 1707 rv = (char*)determine_god(op);
1738 *type = CFAPI_STRING; 1708 *type = CFAPI_STRING;
1739 break; 1709 break;
1740 1710
1741 case CFAPI_OBJECT_PROP_ARCH_NAME: 1711 case CFAPI_OBJECT_PROP_ARCH_NAME:
1742 rv = (char*)op->arch->name; 1712 rv = (char*)&op->arch->name;
1743 *type = CFAPI_STRING; 1713 *type = CFAPI_STRING;
1744 break; 1714 break;
1745 1715
1746 case CFAPI_OBJECT_PROP_INVISIBLE: 1716 case CFAPI_OBJECT_PROP_INVISIBLE:
1747 ri = op->invisible; 1717 ri = op->invisible;
1799 if (op != NULL && (!op->arch || (op != &op->arch->clone))) { 1769 if (op != NULL && (!op->arch || (op != &op->arch->clone))) {
1800 switch (property) 1770 switch (property)
1801 { 1771 {
1802 case CFAPI_OBJECT_PROP_NAME: 1772 case CFAPI_OBJECT_PROP_NAME:
1803 sarg = va_arg(args, char*); 1773 sarg = va_arg(args, char*);
1774#define FREE_AND_COPY(a,b) (a) = (b) // TODO: remove, but plugins.C is considered zombie code
1804 FREE_AND_COPY(op->name, sarg); 1775 FREE_AND_COPY(op->name, sarg);
1805 send_changed_object(op); 1776 send_changed_object(op);
1806 break; 1777 break;
1807 1778
1808 case CFAPI_OBJECT_PROP_NAME_PLURAL: 1779 case CFAPI_OBJECT_PROP_NAME_PLURAL:
3178 arch = va_arg(args, archetype*); 3149 arch = va_arg(args, archetype*);
3179 prop = va_arg(args, int); 3150 prop = va_arg(args, int);
3180 switch (prop) { 3151 switch (prop) {
3181 case CFAPI_ARCH_PROP_NAME: 3152 case CFAPI_ARCH_PROP_NAME:
3182 *type = CFAPI_STRING; 3153 *type = CFAPI_STRING;
3183 rv = (void*)arch->name; 3154 rv = (void*)&arch->name;
3184 break; 3155 break;
3185 3156
3186 case CFAPI_ARCH_PROP_NEXT: 3157 case CFAPI_ARCH_PROP_NEXT:
3187 *type = CFAPI_PARCH; 3158 *type = CFAPI_PARCH;
3188 rv = arch->next; 3159 rv = arch->next;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines