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.50 by root, Sun Jul 1 05:00:20 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
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 */
571 *type = CFAPI_STRING; 540 *type = CFAPI_STRING;
572 541
573 switch (dirtype) 542 switch (dirtype)
574 { 543 {
575 case 0: 544 case 0:
576 return settings.mapdir; 545 return (char *)settings.mapdir;
577 break; 546 break;
578 547
579 case 1: 548 case 1:
580 return settings.uniquedir; 549 return (char *)settings.uniquedir;
581 break; 550 break;
582 551
583 case 2: 552 case 2:
584 return settings.tmpdir; 553 return (char *)settings.tmpdir;
585 break; 554 break;
586 555
587 case 3: 556 case 3:
588 return settings.confdir; 557 return (char *)settings.confdir;
589 break; 558 break;
590 559
591 case 4: 560 case 4:
592 return settings.localdir; 561 return (char *)settings.localdir;
593 break; 562 break;
594 563
595 case 5: 564 case 5:
596 return settings.playerdir; 565 return (char *)settings.playerdir;
597 break; 566 break;
598 567
599 case 6: 568 case 6:
600 return settings.datadir; 569 return (char *)settings.datadir;
601 break; 570 break;
602 } 571 }
603 572
604 *type = CFAPI_NONE; 573 *type = CFAPI_NONE;
605 return NULL; 574 return NULL;
919 owner = va_arg (args, object *); 888 owner = va_arg (args, object *);
920 889
921 va_end (args); 890 va_end (args);
922 891
923 *type = CFAPI_STRING; 892 *type = CFAPI_STRING;
924 return describe_item (op, owner); 893 return (char *)describe_item (op, owner);
925} 894}
926 895
927void * 896void *
928cfapi_object_drain (int *type, ...) 897cfapi_object_drain (int *type, ...)
929{ 898{
1105} 1074}
1106 1075
1107void * 1076void *
1108cfapi_object_create (int *type, ...) 1077cfapi_object_create (int *type, ...)
1109{ 1078{
1110 va_list args; 1079 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} 1080}
1081
1157void * 1082void *
1158cfapi_object_insert (int *type, ...) 1083cfapi_object_insert (int *type, ...)
1159{ 1084{
1160 va_list args; 1085 va_list args;
1161 object *op; 1086 object *op;
1790 1715
1791 send_removed_object (who); 1716 send_removed_object (who);
1792 who->remove (); 1717 who->remove ();
1793 1718
1794 for (tmp = who; tmp != NULL; tmp = tmp->more) 1719 for (tmp = who; tmp != NULL; tmp = tmp->more)
1795 tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), 1720 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); 1721 tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->y);
1797 1722
1798 insert_ob_in_map (who, map, NULL, 0); 1723 insert_ob_in_map (who, map, NULL, 0);
1799 result = 0; 1724 result = 0;
1800 } 1725 }
1801 1726
1822 1747
1823/* Archetype-related functions */ 1748/* Archetype-related functions */
1824void * 1749void *
1825cfapi_archetype_get_first (int *type, ...) 1750cfapi_archetype_get_first (int *type, ...)
1826{ 1751{
1827 va_list args; 1752 abort ();
1828
1829 va_start (args, type);
1830 va_end (args);
1831 *type = CFAPI_PARCH;
1832 return first_archetype;
1833} 1753}
1834 1754
1835void * 1755void *
1836cfapi_archetype_get_property (int *type, ...) 1756cfapi_archetype_get_property (int *type, ...)
1837{ 1757{
1838 archetype *arch; 1758 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} 1759}
1882 1760
1883/* Party-related functions */ 1761/* Party-related functions */
1884void * 1762void *
1885cfapi_party_get_property (int *type, ...) 1763cfapi_party_get_property (int *type, ...)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines