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 it |
8 | /* it under the terms of the GNU General Public License as published by */ |
9 | * under the terms of the GNU General Public License as published by the Free |
9 | /* the Free Software Foundation; either version 2 of the License, or */ |
10 | * Software Foundation; either version 2 of the License, or (at your option) |
10 | /* (at your option) any later version. */ |
11 | * 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, but |
13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ |
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ |
15 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
15 | /* GNU General Public License for more details. */ |
16 | * 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 along |
18 | /* along with this program; if not, write to the Free Software */ |
19 | * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 |
19 | /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ |
20 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | /* */ |
21 | * |
|
|
22 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
|
|
23 | */ |
|
|
24 | |
21 | /*****************************************************************************/ |
25 | /*****************************************************************************/ |
22 | /* This is the server-side plugin management part. */ |
26 | /* This is the server-side plugin management part. */ |
23 | /*****************************************************************************/ |
27 | /*****************************************************************************/ |
24 | /* Original code by Yann Chachkoff (yann.chachkoff@mailandnews.com). */ |
28 | /* Original code by Yann Chachkoff (yann.chachkoff@mailandnews.com). */ |
25 | /* Special thanks to: */ |
29 | /* Special thanks to: */ |
26 | /* David Delbecq (david.delbecq@mailandnews.com); */ |
30 | /* David Delbecq (david.delbecq@mailandnews.com); */ |
27 | /* Joris Bontje (jbontje@suespammers.org); */ |
31 | /* Joris Bontje (jbontje@suespammers.org); */ |
28 | /* Philip Currlin (?); */ |
32 | /* Philip Currlin (?); */ |
29 | /*****************************************************************************/ |
33 | /*****************************************************************************/ |
|
|
34 | |
30 | /*****************************************************************************/ |
35 | /*****************************************************************************/ |
31 | /* First, the headers. We only include plugin.h, because all other includes */ |
36 | /* 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). */ |
37 | /* are done into it, and plugproto.h (which is used only by this file). */ |
33 | /*****************************************************************************/ |
38 | /*****************************************************************************/ |
34 | |
39 | |
… | |
… | |
122 | /* NEW PLUGIN STUFF STARTS HERE */ |
127 | /* NEW PLUGIN STUFF STARTS HERE */ |
123 | |
128 | |
124 | /*****************************************************************************/ |
129 | /*****************************************************************************/ |
125 | |
130 | |
126 | /** |
131 | /** |
127 | * Notify clients about a changed object. |
|
|
128 | * |
|
|
129 | * @param op the object that has changed |
|
|
130 | */ |
|
|
131 | static void |
|
|
132 | send_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. |
132 | * Notify clients about a removed object. |
163 | * |
133 | * |
164 | * @param op the object about to be removed from its environment; it must still |
134 | * @param op the object about to be removed from its environment; it must still |
165 | * be present in its environment |
135 | * be present in its environment |
166 | */ |
136 | */ |
… | |
… | |
571 | *type = CFAPI_STRING; |
541 | *type = CFAPI_STRING; |
572 | |
542 | |
573 | switch (dirtype) |
543 | switch (dirtype) |
574 | { |
544 | { |
575 | case 0: |
545 | case 0: |
576 | return settings.mapdir; |
546 | return (char *)settings.mapdir; |
577 | break; |
547 | break; |
578 | |
548 | |
579 | case 1: |
549 | case 1: |
580 | return settings.uniquedir; |
550 | return (char *)settings.uniquedir; |
581 | break; |
551 | break; |
582 | |
552 | |
583 | case 2: |
553 | case 2: |
584 | return settings.tmpdir; |
554 | return (char *)settings.tmpdir; |
585 | break; |
555 | break; |
586 | |
556 | |
587 | case 3: |
557 | case 3: |
588 | return settings.confdir; |
558 | return (char *)settings.confdir; |
589 | break; |
559 | break; |
590 | |
560 | |
591 | case 4: |
561 | case 4: |
592 | return settings.localdir; |
562 | return (char *)settings.localdir; |
593 | break; |
563 | break; |
594 | |
564 | |
595 | case 5: |
565 | case 5: |
596 | return settings.playerdir; |
566 | return (char *)settings.playerdir; |
597 | break; |
567 | break; |
598 | |
568 | |
599 | case 6: |
569 | case 6: |
600 | return settings.datadir; |
570 | return (char *)settings.datadir; |
601 | break; |
571 | break; |
602 | } |
572 | } |
603 | |
573 | |
604 | *type = CFAPI_NONE; |
574 | *type = CFAPI_NONE; |
605 | return NULL; |
575 | return NULL; |
… | |
… | |
919 | owner = va_arg (args, object *); |
889 | owner = va_arg (args, object *); |
920 | |
890 | |
921 | va_end (args); |
891 | va_end (args); |
922 | |
892 | |
923 | *type = CFAPI_STRING; |
893 | *type = CFAPI_STRING; |
924 | return describe_item (op, owner); |
894 | return (char *)describe_item (op, owner); |
925 | } |
895 | } |
926 | |
896 | |
927 | void * |
897 | void * |
928 | cfapi_object_drain (int *type, ...) |
898 | cfapi_object_drain (int *type, ...) |
929 | { |
899 | { |
… | |
… | |
1127 | object *op; |
1097 | object *op; |
1128 | sval = va_arg (args, char *); |
1098 | sval = va_arg (args, char *); |
1129 | |
1099 | |
1130 | op = get_archetype_by_object_name (sval); |
1100 | op = get_archetype_by_object_name (sval); |
1131 | |
1101 | |
1132 | if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) |
1102 | if (strcmp (query_name (op), ARCH_SINGULARITY) == 0) |
1133 | { |
1103 | { |
1134 | op->destroy (); |
1104 | op->destroy (); |
1135 | /* Try with archetype names... */ |
1105 | /* Try with archetype names... */ |
1136 | op = get_archetype (sval); |
1106 | op = get_archetype (sval); |
1137 | if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) |
1107 | if (strcmp (query_name (op), ARCH_SINGULARITY) == 0) |
1138 | { |
1108 | { |
1139 | op->destroy (); |
1109 | op->destroy (); |
1140 | *type = CFAPI_NONE; |
1110 | *type = CFAPI_NONE; |
1141 | va_end (args); |
1111 | va_end (args); |
1142 | return NULL; |
1112 | return NULL; |
… | |
… | |
1833 | } |
1803 | } |
1834 | |
1804 | |
1835 | void * |
1805 | void * |
1836 | cfapi_archetype_get_property (int *type, ...) |
1806 | cfapi_archetype_get_property (int *type, ...) |
1837 | { |
1807 | { |
1838 | archetype *arch; |
1808 | 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 | } |
1809 | } |
1882 | |
1810 | |
1883 | /* Party-related functions */ |
1811 | /* Party-related functions */ |
1884 | void * |
1812 | void * |
1885 | cfapi_party_get_property (int *type, ...) |
1813 | cfapi_party_get_property (int *type, ...) |