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.18 by pippijn, Sat Dec 9 17:28:37 2006 UTC vs.
Revision 1.21 by root, Tue Dec 12 21:39:57 2006 UTC

121 121
122/* NEW PLUGIN STUFF STARTS HERE */ 122/* NEW PLUGIN STUFF STARTS HERE */
123 123
124/*****************************************************************************/ 124/*****************************************************************************/
125 125
126#ifdef WIN32
127static const char *
128plugins_dlerror (void)
129{
130 static char buf[256];
131 DWORD err;
132 char *p;
133
134 err = GetLastError ();
135 if (FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, buf, sizeof (buf), NULL) == 0)
136 snprintf (buf, sizeof (buf), "error %lu", err);
137 p = strchr (buf, '\0');
138 while (p > buf && (p[-1] == '\r' || p[-1] == '\n'))
139 p--;
140 *p = '\0';
141 return buf;
142}
143#endif /* WIN32 */
144
145/** 126/**
146 * Notify clients about a changed object. 127 * Notify clients about a changed object.
147 * 128 *
148 * @param op the object that has changed 129 * @param op the object that has changed
149 */ 130 */
2623 op = va_arg (args, object *); 2604 op = va_arg (args, object *);
2624 2605
2625 va_end (args); 2606 va_end (args);
2626 2607
2627 send_removed_object (op); 2608 send_removed_object (op);
2628 remove_ob (op); 2609 op->remove ();
2629 *type = CFAPI_NONE; 2610 *type = CFAPI_NONE;
2630 return NULL; 2611 return NULL;
2631} 2612}
2632 2613
2633void * 2614void *
2640 2621
2641 op = va_arg (args, object *); 2622 op = va_arg (args, object *);
2642 2623
2643 va_end (args); 2624 va_end (args);
2644 2625
2645 free_object (op); 2626 op->destroy ();
2646 2627
2647 *type = CFAPI_NONE; 2628 *type = CFAPI_NONE;
2648 return NULL; 2629 return NULL;
2649} 2630}
2650 2631
2669 } 2650 }
2670 else 2651 else
2671 { 2652 {
2672 object *tmp; 2653 object *tmp;
2673 2654
2674 tmp = get_object (); 2655 tmp = object::create ();
2675 copy_object (op, tmp); 2656 op->copy_to (tmp);
2676 *type = CFAPI_POBJECT; 2657 *type = CFAPI_POBJECT;
2677 return tmp; 2658 return tmp;
2678 } 2659 }
2679} 2660}
2680void * 2661void *
2744 *type = CFAPI_POBJECT; 2725 *type = CFAPI_POBJECT;
2745 switch (ival) 2726 switch (ival)
2746 { 2727 {
2747 case 0: 2728 case 0:
2748 va_end (args); 2729 va_end (args);
2749 return get_object (); 2730 return object::create ();
2750 break; 2731 break;
2751 2732
2752 case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */ 2733 case 1: /* Named object. Nearly the old plugin behavior, but we don't add artifact suffixes */
2753 { 2734 {
2754 char *sval; 2735 char *sval;
2757 2738
2758 op = get_archetype_by_object_name (sval); 2739 op = get_archetype_by_object_name (sval);
2759 2740
2760 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2741 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2761 { 2742 {
2762 free_object (op); 2743 op->destroy ();
2763 /* Try with archetype names... */ 2744 /* Try with archetype names... */
2764 op = get_archetype (sval); 2745 op = get_archetype (sval);
2765 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2746 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2766 { 2747 {
2767 free_object (op); 2748 op->destroy ();
2768 *type = CFAPI_NONE; 2749 *type = CFAPI_NONE;
2769 va_end (args); 2750 va_end (args);
2770 return NULL; 2751 return NULL;
2771 } 2752 }
2772 } 2753 }
3241 x = map->enter_x; 3222 x = map->enter_x;
3242 y = map->enter_y; 3223 y = map->enter_y;
3243 } 3224 }
3244 3225
3245/* 3226/*
3246 originator = get_object(); 3227 originator = object::create();
3247 EXIT_PATH(originator) = add_string(map->path); 3228 EXIT_PATH(originator) = add_string(map->path);
3248 EXIT_X(originator) = x; 3229 EXIT_X(originator) = x;
3249 EXIT_Y(originator) = y; 3230 EXIT_Y(originator) = y;
3250 printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/ 3231 printf("B Transfer: X=%d, Y=%d, OP=%s\n", x, y, op->name);*/
3251 /*enter_exit(op, originator); */ 3232 /*enter_exit(op, originator); */
3252 insert_ob_in_map_at (op, map, NULL, 0, x, y); 3233 insert_ob_in_map_at (op, map, NULL, 0, x, y);
3253 /*printf("A Transfer: X=%d, Y=%d, MAP=%s\n", x, y, op->map->name); 3234 /*printf("A Transfer: X=%d, Y=%d, MAP=%s\n", x, y, op->map->name);
3254 free_object(originator); 3235 originator->destroy ();
3255 */ 3236 */
3256 *type = CFAPI_INT; 3237 *type = CFAPI_INT;
3257 return &rv; 3238 return &rv;
3258 break; 3239 break;
3259 3240
3448 result = 1; 3429 result = 1;
3449 return &result; 3430 return &result;
3450 } 3431 }
3451 3432
3452 send_removed_object (who); 3433 send_removed_object (who);
3453 remove_ob (who); 3434 who->remove ();
3454 3435
3455 for (tmp = who; tmp != NULL; tmp = tmp->more) 3436 for (tmp = who; tmp != NULL; tmp = tmp->more)
3456 tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), 3437 tmp->x = x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x),
3457 tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); 3438 tmp->y = y + freearr_y[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y);
3458 3439

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines