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.42 by root, Mon Feb 5 01:47:23 2007 UTC vs.
Revision 1.51 by root, Thu Jul 26 00:27:09 2007 UTC

1/*****************************************************************************/ 1/*
2/* CrossFire, A Multiplayer game for X-windows */ 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3/* */ 3 *
4/* Copyright (C) 2000 Mark Wedel */ 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5/* Copyright (C) 1992 Frank Tore Johansen */ 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6/* */ 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 *
7/* This program is free software; you can redistribute it and/or modify */ 8 * Crossfire TRT 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 * 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 * the Free Software Foundation, either version 3 of the License, or
10/* (at your option) any later version. */ 11 * (at your option) any later version.
11/* */ 12 *
12/* This program is distributed in the hope that it will be useful, */ 13 * This program is distributed in the hope that it will be useful,
13/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15/* GNU General Public License for more details. */ 16 * GNU General Public License for more details.
16/* */ 17 *
17/* You should have received a copy of the GNU General Public License */ 18 * 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 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 20 *
20/* */ 21 * The authors can be reached via e-mail to <crossfire@schmorp.de>
22 */
23
21/*****************************************************************************/ 24/*****************************************************************************/
22/* This is the server-side plugin management part. */ 25/* This is the server-side plugin management part. */
23/*****************************************************************************/ 26/*****************************************************************************/
24/* Original code by Yann Chachkoff (yann.chachkoff@mailandnews.com). */ 27/* Original code by Yann Chachkoff (yann.chachkoff@mailandnews.com). */
25/* Special thanks to: */ 28/* Special thanks to: */
26/* David Delbecq (david.delbecq@mailandnews.com); */ 29/* David Delbecq (david.delbecq@mailandnews.com); */
27/* Joris Bontje (jbontje@suespammers.org); */ 30/* Joris Bontje (jbontje@suespammers.org); */
28/* Philip Currlin (?); */ 31/* Philip Currlin (?); */
29/*****************************************************************************/ 32/*****************************************************************************/
33
30/*****************************************************************************/ 34/*****************************************************************************/
31/* First, the headers. We only include plugin.h, because all other includes */ 35/* First, the headers. We only include plugin.h, because all other includes */
32/* are done into it, and plugproto.h (which is used only by this file). */ 36/* are done into it, and plugproto.h (which is used only by this file). */
33/*****************************************************************************/ 37/*****************************************************************************/
34 38
41#define NR_OF_HOOKS 74 45#define NR_OF_HOOKS 74
42 46
43static const hook_entry plug_hooks[NR_OF_HOOKS] = { 47static const hook_entry plug_hooks[NR_OF_HOOKS] = {
44 {cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"}, 48 {cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"},
45 {cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event"}, 49 {cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event"},
46 {cfapi_system_check_path, 4, "cfapi_system_check_path"}, 50 {NULL, 4, "cfapi_system_check_path"},
47 {NULL, 5, "cfapi_system_re_cmp"}, 51 {NULL, 5, "cfapi_system_re_cmp"},
48 {cfapi_system_strdup, 6, "cfapi_system_strdup"}, 52 {cfapi_system_strdup, 6, "cfapi_system_strdup"},
49 {cfapi_system_directory, 7, "cfapi_system_directory"}, 53 {cfapi_system_directory, 7, "cfapi_system_directory"},
50 {cfapi_system_find_animation, 8, "cfapi_system_find_animation"}, 54 {cfapi_system_find_animation, 8, "cfapi_system_find_animation"},
51 {cfapi_object_clean_object, 9, "cfapi_object_clean_object"}, 55 {cfapi_object_clean_object, 9, "cfapi_object_clean_object"},
122/* NEW PLUGIN STUFF STARTS HERE */ 126/* NEW PLUGIN STUFF STARTS HERE */
123 127
124/*****************************************************************************/ 128/*****************************************************************************/
125 129
126/** 130/**
127 * Notify clients about a changed object.
128 *
129 * @param op the object that has changed
130 */
131static void
132send_changed_object (object *op)
133{
134 object *tmp;
135
136 if (op->env)
137 {
138 tmp = op->in_player ();
139
140 if (!tmp)
141 {
142 for_all_players (pl)
143 if (pl->ob->container == op->env)
144 {
145 tmp = pl->ob;
146 break;
147 }
148 }
149
150 if (tmp)
151 esrv_send_item (tmp, op);
152 }
153 else
154 {
155 for (tmp = op->above; tmp != NULL; tmp = tmp->above)
156 if (tmp->type == PLAYER)
157 esrv_send_item (tmp, op);
158 }
159}
160
161/**
162 * Notify clients about a removed object. 131 * Notify clients about a removed object.
163 * 132 *
164 * @param op the object about to be removed from its environment; it must still 133 * @param op the object about to be removed from its environment; it must still
165 * be present in its environment 134 * be present in its environment
166 */ 135 */
537} 506}
538 507
539void * 508void *
540cfapi_system_check_path (int *type, ...) 509cfapi_system_check_path (int *type, ...)
541{ 510{
542 va_list args; 511 abort ();
543 static int rv;
544 char *name;
545 int prepend_dir;
546
547 va_start (args, type);
548
549 name = va_arg (args, char *);
550 prepend_dir = va_arg (args, int);
551
552 rv = check_path (name, prepend_dir);
553
554 va_end (args);
555 *type = CFAPI_INT;
556 return &rv;
557} 512}
558 513
559void * 514void *
560cfapi_system_directory (int *type, ...) 515cfapi_system_directory (int *type, ...)
561{ 516{
571 *type = CFAPI_STRING; 526 *type = CFAPI_STRING;
572 527
573 switch (dirtype) 528 switch (dirtype)
574 { 529 {
575 case 0: 530 case 0:
576 return settings.mapdir; 531 return (char *)settings.mapdir;
577 break; 532 break;
578 533
579 case 1: 534 case 1:
580 return settings.uniquedir; 535 return (char *)settings.uniquedir;
581 break; 536 break;
582 537
583 case 2: 538 case 2:
584 return settings.tmpdir; 539 return (char *)settings.tmpdir;
585 break; 540 break;
586 541
587 case 3: 542 case 3:
588 return settings.confdir; 543 return (char *)settings.confdir;
589 break; 544 break;
590 545
591 case 4: 546 case 4:
592 return settings.localdir; 547 return (char *)settings.localdir;
593 break; 548 break;
594 549
595 case 5: 550 case 5:
596 return settings.playerdir; 551 return (char *)settings.playerdir;
597 break; 552 break;
598 553
599 case 6: 554 case 6:
600 return settings.datadir; 555 return (char *)settings.datadir;
601 break; 556 break;
602 } 557 }
603 558
604 *type = CFAPI_NONE; 559 *type = CFAPI_NONE;
605 return NULL; 560 return NULL;
919 owner = va_arg (args, object *); 874 owner = va_arg (args, object *);
920 875
921 va_end (args); 876 va_end (args);
922 877
923 *type = CFAPI_STRING; 878 *type = CFAPI_STRING;
924 return describe_item (op, owner); 879 return (char *)describe_item (op, owner);
925} 880}
926 881
927void * 882void *
928cfapi_object_drain (int *type, ...) 883cfapi_object_drain (int *type, ...)
929{ 884{
1105} 1060}
1106 1061
1107void * 1062void *
1108cfapi_object_create (int *type, ...) 1063cfapi_object_create (int *type, ...)
1109{ 1064{
1110 va_list args; 1065 abort ();
1111 int ival;
1112
1113 va_start (args, type);
1114 ival = va_arg (args, int);
1115
1116 *type = CFAPI_POBJECT;
1117 switch (ival)
1118 {
1119 case 0:
1120 va_end (args);
1121 return object::create ();
1122 break;
1123
1124 case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
1125 {
1126 char *sval;
1127 object *op;
1128 sval = va_arg (args, char *);
1129
1130 op = get_archetype_by_object_name (sval);
1131
1132 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
1133 {
1134 op->destroy ();
1135 /* Try with archetype names... */
1136 op = get_archetype (sval);
1137 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
1138 {
1139 op->destroy ();
1140 *type = CFAPI_NONE;
1141 va_end (args);
1142 return NULL;
1143 }
1144 }
1145 va_end (args);
1146 return op;
1147 }
1148 break;
1149
1150 default:
1151 *type = CFAPI_NONE;
1152 va_end (args);
1153 return NULL;
1154 break;
1155 }
1156} 1066}
1067
1157void * 1068void *
1158cfapi_object_insert (int *type, ...) 1069cfapi_object_insert (int *type, ...)
1159{ 1070{
1160 va_list args; 1071 va_list args;
1161 object *op; 1072 object *op;
1790 1701
1791 send_removed_object (who); 1702 send_removed_object (who);
1792 who->remove (); 1703 who->remove ();
1793 1704
1794 for (tmp = who; tmp != NULL; tmp = tmp->more) 1705 for (tmp = who; tmp != NULL; tmp = tmp->more)
1795 tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), 1706 tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->x),
1796 tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); 1707 tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->y);
1797 1708
1798 insert_ob_in_map (who, map, NULL, 0); 1709 insert_ob_in_map (who, map, NULL, 0);
1799 result = 0; 1710 result = 0;
1800 } 1711 }
1801 1712
1822 1733
1823/* Archetype-related functions */ 1734/* Archetype-related functions */
1824void * 1735void *
1825cfapi_archetype_get_first (int *type, ...) 1736cfapi_archetype_get_first (int *type, ...)
1826{ 1737{
1827 va_list args; 1738 abort ();
1828
1829 va_start (args, type);
1830 va_end (args);
1831 *type = CFAPI_PARCH;
1832 return first_archetype;
1833} 1739}
1834 1740
1835void * 1741void *
1836cfapi_archetype_get_property (int *type, ...) 1742cfapi_archetype_get_property (int *type, ...)
1837{ 1743{
1838 archetype *arch; 1744 abort ();
1839 int prop;
1840 va_list args;
1841 void *rv;
1842
1843 va_start (args, type);
1844 arch = va_arg (args, archetype *);
1845 prop = va_arg (args, int);
1846
1847 switch (prop)
1848 {
1849 case CFAPI_ARCH_PROP_NAME:
1850 *type = CFAPI_STRING;
1851 rv = (void *) &arch->name;
1852 break;
1853
1854 case CFAPI_ARCH_PROP_NEXT:
1855 *type = CFAPI_PARCH;
1856 rv = arch->next;
1857 break;
1858
1859 case CFAPI_ARCH_PROP_HEAD:
1860 *type = CFAPI_PARCH;
1861 rv = arch->head;
1862 break;
1863
1864 case CFAPI_ARCH_PROP_MORE:
1865 *type = CFAPI_PARCH;
1866 rv = arch->more;
1867 break;
1868
1869 case CFAPI_ARCH_PROP_CLONE:
1870 *type = CFAPI_POBJECT;
1871 rv = &arch->clone;
1872 break;
1873
1874 default:
1875 *type = CFAPI_NONE;
1876 rv = NULL;
1877 break;
1878 }
1879 va_end (args);
1880 return rv;
1881} 1745}
1882 1746
1883/* Party-related functions */ 1747/* Party-related functions */
1884void * 1748void *
1885cfapi_party_get_property (int *type, ...) 1749cfapi_party_get_property (int *type, ...)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines