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.20 by root, Tue Dec 12 20:53:03 2006 UTC vs.
Revision 1.31 by root, Thu Dec 21 23:37:06 2006 UTC

43static const hook_entry plug_hooks[NR_OF_HOOKS] = { 43static const hook_entry plug_hooks[NR_OF_HOOKS] = {
44 {cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"}, 44 {cfapi_system_register_global_event, 1, "cfapi_system_register_global_event"},
45 {cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event"}, 45 {cfapi_system_unregister_global_event, 3, "cfapi_system_unregister_global_event"},
46 {cfapi_system_check_path, 4, "cfapi_system_check_path"}, 46 {cfapi_system_check_path, 4, "cfapi_system_check_path"},
47 {NULL, 5, "cfapi_system_re_cmp"}, 47 {NULL, 5, "cfapi_system_re_cmp"},
48 {cfapi_system_strdup_local, 6, "cfapi_system_strdup_local"}, 48 {cfapi_system_strdup, 6, "cfapi_system_strdup"},
49 {cfapi_system_directory, 7, "cfapi_system_directory"}, 49 {cfapi_system_directory, 7, "cfapi_system_directory"},
50 {cfapi_system_find_animation, 8, "cfapi_system_find_animation"}, 50 {cfapi_system_find_animation, 8, "cfapi_system_find_animation"},
51 {cfapi_object_clean_object, 9, "cfapi_object_clean_object"}, 51 {cfapi_object_clean_object, 9, "cfapi_object_clean_object"},
52 {cfapi_object_on_same_map, 10, "cfapi_object_on_same_map"}, 52 {cfapi_object_on_same_map, 10, "cfapi_object_on_same_map"},
53 {cfapi_object_get_key, 11, "cfapi_object_get_key"}, 53 {cfapi_object_get_key, 11, "cfapi_object_get_key"},
132send_changed_object (object *op) 132send_changed_object (object *op)
133{ 133{
134 object *tmp; 134 object *tmp;
135 player *pl; 135 player *pl;
136 136
137 if (op->env != NULL) 137 if (op->env)
138 { 138 {
139 tmp = is_player_inv (op->env); 139 tmp = op->in_player ();
140
140 if (!tmp) 141 if (!tmp)
141 { 142 {
142 for (pl = first_player; pl; pl = pl->next) 143 for (pl = first_player; pl; pl = pl->next)
143 if (pl->ob->container == op->env) 144 if (pl->ob->container == op->env)
144 break; 145 break;
146
145 if (pl) 147 if (pl)
146 tmp = pl->ob; 148 tmp = pl->ob;
147 else 149 else
148 tmp = NULL; 150 tmp = NULL;
149 } 151 }
152
150 if (tmp) 153 if (tmp)
151 esrv_send_item (tmp, op); 154 esrv_send_item (tmp, op);
152 } 155 }
153 else 156 else
154 { 157 {
174 { 177 {
175 /* no action necessary: remove_ob() notifies the client */ 178 /* no action necessary: remove_ob() notifies the client */
176 return; 179 return;
177 } 180 }
178 181
179 tmp = is_player_inv (op->env); 182 tmp = op->in_player ();
180 if (!tmp) 183 if (!tmp)
181 { 184 {
182 for (pl = first_player; pl; pl = pl->next) 185 for (pl = first_player; pl; pl = pl->next)
183 if (pl->ob->container == op->env) 186 if (pl->ob->container == op->env)
184 break; 187 break;
482 *type = CFAPI_INT; 485 *type = CFAPI_INT;
483 return &rv; 486 return &rv;
484} 487}
485 488
486void * 489void *
487cfapi_system_strdup_local (int *type, ...) 490cfapi_system_strdup (int *type, ...)
488{ 491{
489 va_list args; 492 va_list args;
490 char *txt; 493 char *txt;
491 494
492 va_start (args, type); 495 va_start (args, type);
493 txt = va_arg (args, char *); 496 txt = va_arg (args, char *);
494 497
495 va_end (args); 498 va_end (args);
496 *type = CFAPI_STRING; 499 *type = CFAPI_STRING;
497 return strdup_local (txt); 500 return strdup (txt);
498} 501}
499 502
500void * 503void *
501cfapi_system_register_global_event (int *type, ...) 504cfapi_system_register_global_event (int *type, ...)
502{ 505{
1032 1035
1033 map = va_arg (args, maptile *); 1036 map = va_arg (args, maptile *);
1034 x = va_arg (args, int); 1037 x = va_arg (args, int);
1035 y = va_arg (args, int); 1038 y = va_arg (args, int);
1036 1039
1037 update_position (map, x, y); 1040 map->at (x, y).flags_ |= P_NEED_UPDATE;
1041
1038 va_end (args); 1042 va_end (args);
1039 *type = CFAPI_NONE; 1043 *type = CFAPI_NONE;
1040 return NULL; 1044 return NULL;
1041} 1045}
1042 1046
1090 x = va_arg (args, int); 1094 x = va_arg (args, int);
1091 y = va_arg (args, int); 1095 y = va_arg (args, int);
1092 1096
1093 va_end (args); 1097 va_end (args);
1094 1098
1095 rv = get_map_ob (map, x, y); 1099 rv = GET_MAP_OB (map, x, y);
1096 *type = CFAPI_POBJECT; 1100 *type = CFAPI_POBJECT;
1097 return rv; 1101 return rv;
1098} 1102}
1099 1103
1100void * 1104void *
1637 rv = &op->stats.exp; 1641 rv = &op->stats.exp;
1638 *type = CFAPI_LONG; 1642 *type = CFAPI_LONG;
1639 break; 1643 break;
1640 1644
1641 case CFAPI_OBJECT_PROP_OWNER: 1645 case CFAPI_OBJECT_PROP_OWNER:
1642 rv = get_owner (op); 1646 rv = op->owner;
1643 *type = CFAPI_POBJECT; 1647 *type = CFAPI_POBJECT;
1644 break; 1648 break;
1645 1649
1646 case CFAPI_OBJECT_PROP_PRESENT: 1650 case CFAPI_OBJECT_PROP_PRESENT:
1647 { 1651 {
1689 case CFAPI_OBJECT_PROP_MERGEABLE: 1693 case CFAPI_OBJECT_PROP_MERGEABLE:
1690 { 1694 {
1691 object *op2; 1695 object *op2;
1692 op2 = va_arg (args, object *); 1696 op2 = va_arg (args, object *);
1693 1697
1694 ri = CAN_MERGE (op, op2); 1698 ri = object::can_merge_slow (op, op2);
1695 rv = &ri; 1699 rv = &ri;
1696 } 1700 }
1697 *type = CFAPI_INT; 1701 *type = CFAPI_INT;
1698 break; 1702 break;
1699 1703
1846 rv = &ri; 1850 rv = &ri;
1847 *type = CFAPI_INT; 1851 *type = CFAPI_INT;
1848 break; 1852 break;
1849 1853
1850 case CFAPI_PLAYER_PROP_IP: 1854 case CFAPI_PLAYER_PROP_IP:
1851 rv = op->contr->socket.host; 1855 rv = op->contr->ns->host;
1852 *type = CFAPI_STRING; 1856 *type = CFAPI_STRING;
1853 break; 1857 break;
1854 1858
1855 case CFAPI_PLAYER_PROP_MARKED_ITEM: 1859 case CFAPI_PLAYER_PROP_MARKED_ITEM:
1856 rv = find_marked_object (op); 1860 rv = find_marked_object (op);
1971 player *pl; 1975 player *pl;
1972 1976
1973 op->nrof = iarg; 1977 op->nrof = iarg;
1974 if (op->env != NULL) 1978 if (op->env != NULL)
1975 { 1979 {
1976 tmp = is_player_inv (op->env); 1980 tmp = op->in_player ();
1977 if (!tmp) 1981 if (!tmp)
1978 { 1982 {
1979 for (pl = first_player; pl; pl = pl->next) 1983 for (pl = first_player; pl; pl = pl->next)
1980 if (pl->ob->container == op->env) 1984 if (pl->ob->container == op->env)
1981 break; 1985 break;
2132 player *pl; 2136 player *pl;
2133 2137
2134 op->weight = iarg; 2138 op->weight = iarg;
2135 if (op->env != NULL) 2139 if (op->env != NULL)
2136 { 2140 {
2137 tmp = is_player_inv (op->env); 2141 tmp = op->in_player ();
2138 if (!tmp) 2142 if (!tmp)
2139 { 2143 {
2140 for (pl = first_player; pl; pl = pl->next) 2144 for (pl = first_player; pl; pl = pl->next)
2141 if (pl->ob->container == op->env) 2145 if (pl->ob->container == op->env)
2142 break; 2146 break;
2271 break; 2275 break;
2272 2276
2273 case CFAPI_OBJECT_PROP_OWNER: 2277 case CFAPI_OBJECT_PROP_OWNER:
2274 oparg = va_arg (args, object *); 2278 oparg = va_arg (args, object *);
2275 2279
2276 set_owner (op, oparg); 2280 op->set_owner (oparg);
2277 break; 2281 break;
2278 2282
2279 case CFAPI_OBJECT_PROP_CHEATER: 2283 case CFAPI_OBJECT_PROP_CHEATER:
2280 set_cheat (op); 2284 set_cheat (op);
2281 break; 2285 break;
2621 2625
2622 op = va_arg (args, object *); 2626 op = va_arg (args, object *);
2623 2627
2624 va_end (args); 2628 va_end (args);
2625 2629
2626 op->destroy (0); 2630 op->destroy ();
2627 2631
2628 *type = CFAPI_NONE; 2632 *type = CFAPI_NONE;
2629 return NULL; 2633 return NULL;
2630} 2634}
2631 2635
2648 *type = CFAPI_POBJECT; 2652 *type = CFAPI_POBJECT;
2649 return object_create_clone (op); 2653 return object_create_clone (op);
2650 } 2654 }
2651 else 2655 else
2652 { 2656 {
2653 object *tmp; 2657 object *tmp = op->clone ();
2654
2655 tmp = get_object ();
2656 copy_object (op, tmp);
2657 *type = CFAPI_POBJECT; 2658 *type = CFAPI_POBJECT;
2658 return tmp; 2659 return tmp;
2659 } 2660 }
2660} 2661}
2661void * 2662void *
2697 break; 2698 break;
2698 2699
2699 case 3: 2700 case 3:
2700 op = va_arg (args, object *); 2701 op = va_arg (args, object *);
2701 2702
2702 rv = is_player_inv (op); 2703 rv = op->in_player ();
2703 break; 2704 break;
2704 2705
2705 default: 2706 default:
2706 rv = NULL; 2707 rv = NULL;
2707 *type = CFAPI_NONE; 2708 *type = CFAPI_NONE;
2725 *type = CFAPI_POBJECT; 2726 *type = CFAPI_POBJECT;
2726 switch (ival) 2727 switch (ival)
2727 { 2728 {
2728 case 0: 2729 case 0:
2729 va_end (args); 2730 va_end (args);
2730 return get_object (); 2731 return object::create ();
2731 break; 2732 break;
2732 2733
2733 case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */ 2734 case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
2734 { 2735 {
2735 char *sval; 2736 char *sval;
2738 2739
2739 op = get_archetype_by_object_name (sval); 2740 op = get_archetype_by_object_name (sval);
2740 2741
2741 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2742 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2742 { 2743 {
2743 op->destroy (0); 2744 op->destroy ();
2744 /* Try with archetype names... */ 2745 /* Try with archetype names... */
2745 op = get_archetype (sval); 2746 op = get_archetype (sval);
2746 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2747 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2747 { 2748 {
2748 op->destroy (0); 2749 op->destroy ();
2749 *type = CFAPI_NONE; 2750 *type = CFAPI_NONE;
2750 va_end (args); 2751 va_end (args);
2751 return NULL; 2752 return NULL;
2752 } 2753 }
2753 } 2754 }
2912 2913
2913 op = va_arg (args, object *); 2914 op = va_arg (args, object *);
2914 2915
2915 va_end (args); 2916 va_end (args);
2916 2917
2917 clear_object (op); 2918 op->clear ();
2918 *type = CFAPI_NONE; 2919 *type = CFAPI_NONE;
2919 return NULL; 2920 return NULL;
2920} 2921}
2921 2922
2922void * 2923void *
3222 x = map->enter_x; 3223 x = map->enter_x;
3223 y = map->enter_y; 3224 y = map->enter_y;
3224 } 3225 }
3225 3226
3226/* 3227/*
3227 originator = get_object(); 3228 originator = object::create();
3228 EXIT_PATH(originator) = add_string(map->path); 3229 EXIT_PATH(originator) = add_string(map->path);
3229 EXIT_X(originator) = x; 3230 EXIT_X(originator) = x;
3230 EXIT_Y(originator) = y; 3231 EXIT_Y(originator) = y;
3231 printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/ 3232 printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/
3232 /*enter_exit(op, originator); */ 3233 /*enter_exit(op, originator); */
3233 insert_ob_in_map_at (op, map, NULL, 0, x, y); 3234 insert_ob_in_map_at (op, map, NULL, 0, x, y);
3234 /*printf("A Transfer: X=%d, Y=%d, MAP=%s\n", x, y, op->map->name); 3235 /*printf("A Transfer: X=%d, Y=%d, MAP=%s\n", x, y, op->map->name);
3235 originator->destroy (0); 3236 originator->destroy ();
3236 */ 3237 */
3237 *type = CFAPI_INT; 3238 *type = CFAPI_INT;
3238 return &rv; 3239 return &rv;
3239 break; 3240 break;
3240 3241
3313 drop (author, op); 3314 drop (author, op);
3314 3315
3315 if (author->type == PLAYER) 3316 if (author->type == PLAYER)
3316 { 3317 {
3317 author->contr->count = 0; 3318 author->contr->count = 0;
3318 author->contr->socket.update_look = 1; 3319 author->contr->ns->floorbox_update ();
3319 } 3320 }
3320 3321
3321 *type = CFAPI_NONE; 3322 *type = CFAPI_NONE;
3322 return NULL; 3323 return NULL;
3323} 3324}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines