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.16 by root, Sat Sep 16 22:24:13 2006 UTC vs.
Revision 1.21 by root, Tue Dec 12 21:39:57 2006 UTC

42 42
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 {cfapi_system_re_cmp, 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_local, 6, "cfapi_system_strdup_local"},
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"},
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 */
575 *type = CFAPI_INT; 556 *type = CFAPI_INT;
576 return &rv; 557 return &rv;
577} 558}
578 559
579void * 560void *
580cfapi_system_re_cmp (int *type, ...)
581{
582 va_list args;
583 char *rv;
584 const char *str;
585 const char *regexp;
586
587 va_start (args, type);
588
589 str = va_arg (args, char *);
590 regexp = va_arg (args, char *);
591
592 rv = (char *) re_cmp (str, regexp);
593
594 va_end (args);
595 *type = CFAPI_STRING;
596 return rv;
597}
598
599void *
600cfapi_system_directory (int *type, ...) 561cfapi_system_directory (int *type, ...)
601{ 562{
602 va_list args; 563 va_list args;
603 int dirtype; 564 int dirtype;
604 565
2455 if (op->contr) 2416 if (op->contr)
2456 { 2417 {
2457 oparg = va_arg (args, object *); 2418 oparg = va_arg (args, object *);
2458 2419
2459 op->contr->mark = oparg; 2420 op->contr->mark = oparg;
2460 if (oparg)
2461 op->contr->mark_count = oparg->count;
2462 } 2421 }
2463 break; 2422 break;
2464 2423
2465 case CFAPI_PLAYER_PROP_PARTY: 2424 case CFAPI_PLAYER_PROP_PARTY:
2466 if (op->contr) 2425 if (op->contr)
2645 op = va_arg (args, object *); 2604 op = va_arg (args, object *);
2646 2605
2647 va_end (args); 2606 va_end (args);
2648 2607
2649 send_removed_object (op); 2608 send_removed_object (op);
2650 remove_ob (op); 2609 op->remove ();
2651 *type = CFAPI_NONE; 2610 *type = CFAPI_NONE;
2652 return NULL; 2611 return NULL;
2653} 2612}
2654 2613
2655void * 2614void *
2662 2621
2663 op = va_arg (args, object *); 2622 op = va_arg (args, object *);
2664 2623
2665 va_end (args); 2624 va_end (args);
2666 2625
2667 free_object (op); 2626 op->destroy ();
2668 2627
2669 *type = CFAPI_NONE; 2628 *type = CFAPI_NONE;
2670 return NULL; 2629 return NULL;
2671} 2630}
2672 2631
2691 } 2650 }
2692 else 2651 else
2693 { 2652 {
2694 object *tmp; 2653 object *tmp;
2695 2654
2696 tmp = get_object (); 2655 tmp = object::create ();
2697 copy_object (op, tmp); 2656 op->copy_to (tmp);
2698 *type = CFAPI_POBJECT; 2657 *type = CFAPI_POBJECT;
2699 return tmp; 2658 return tmp;
2700 } 2659 }
2701} 2660}
2702void * 2661void *
2766 *type = CFAPI_POBJECT; 2725 *type = CFAPI_POBJECT;
2767 switch (ival) 2726 switch (ival)
2768 { 2727 {
2769 case 0: 2728 case 0:
2770 va_end (args); 2729 va_end (args);
2771 return get_object (); 2730 return object::create ();
2772 break; 2731 break;
2773 2732
2774 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 */
2775 { 2734 {
2776 char *sval; 2735 char *sval;
2779 2738
2780 op = get_archetype_by_object_name (sval); 2739 op = get_archetype_by_object_name (sval);
2781 2740
2782 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2741 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2783 { 2742 {
2784 free_object (op); 2743 op->destroy ();
2785 /* Try with archetype names... */ 2744 /* Try with archetype names... */
2786 op = get_archetype (sval); 2745 op = get_archetype (sval);
2787 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0) 2746 if (strncmp (query_name (op), ARCH_SINGULARITY, ARCH_SINGULARITY_LEN) == 0)
2788 { 2747 {
2789 free_object (op); 2748 op->destroy ();
2790 *type = CFAPI_NONE; 2749 *type = CFAPI_NONE;
2791 va_end (args); 2750 va_end (args);
2792 return NULL; 2751 return NULL;
2793 } 2752 }
2794 } 2753 }
3263 x = map->enter_x; 3222 x = map->enter_x;
3264 y = map->enter_y; 3223 y = map->enter_y;
3265 } 3224 }
3266 3225
3267/* 3226/*
3268 originator = get_object(); 3227 originator = object::create();
3269 EXIT_PATH(originator) = add_string(map->path); 3228 EXIT_PATH(originator) = add_string(map->path);
3270 EXIT_X(originator) = x; 3229 EXIT_X(originator) = x;
3271 EXIT_Y(originator) = y; 3230 EXIT_Y(originator) = y;
3272 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);*/
3273 /*enter_exit(op, originator); */ 3232 /*enter_exit(op, originator); */
3274 insert_ob_in_map_at (op, map, NULL, 0, x, y); 3233 insert_ob_in_map_at (op, map, NULL, 0, x, y);
3275 /*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);
3276 free_object(originator); 3235 originator->destroy ();
3277 */ 3236 */
3278 *type = CFAPI_INT; 3237 *type = CFAPI_INT;
3279 return &rv; 3238 return &rv;
3280 break; 3239 break;
3281 3240
3470 result = 1; 3429 result = 1;
3471 return &result; 3430 return &result;
3472 } 3431 }
3473 3432
3474 send_removed_object (who); 3433 send_removed_object (who);
3475 remove_ob (who); 3434 who->remove ();
3476 3435
3477 for (tmp = who; tmp != NULL; tmp = tmp->more) 3436 for (tmp = who; tmp != NULL; tmp = tmp->more)
3478 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),
3479 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);
3480 3439

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines