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.31 by root, Thu Dec 21 23:37:06 2006 UTC vs.
Revision 1.37 by root, Sat Dec 30 10:16:11 2006 UTC

130 */ 130 */
131static void 131static void
132send_changed_object (object *op) 132send_changed_object (object *op)
133{ 133{
134 object *tmp; 134 object *tmp;
135 player *pl;
136 135
137 if (op->env) 136 if (op->env)
138 { 137 {
139 tmp = op->in_player (); 138 tmp = op->in_player ();
140 139
141 if (!tmp) 140 if (!tmp)
142 { 141 {
143 for (pl = first_player; pl; pl = pl->next) 142 for_all_players (pl)
144 if (pl->ob->container == op->env) 143 if (pl->ob->container == op->env)
144 {
145 tmp = pl->ob;
145 break; 146 break;
146 147 }
147 if (pl)
148 tmp = pl->ob;
149 else
150 tmp = NULL;
151 } 148 }
152 149
153 if (tmp) 150 if (tmp)
154 esrv_send_item (tmp, op); 151 esrv_send_item (tmp, op);
155 } 152 }
169 */ 166 */
170static void 167static void
171send_removed_object (object *op) 168send_removed_object (object *op)
172{ 169{
173 object *tmp; 170 object *tmp;
174 player *pl;
175 171
176 if (op->env == NULL) 172 if (op->env == NULL)
177 { 173 {
178 /* no action necessary: remove_ob() notifies the client */ 174 /* no action necessary: remove_ob() notifies the client */
179 return; 175 return;
180 } 176 }
181 177
182 tmp = op->in_player (); 178 tmp = op->in_player ();
183 if (!tmp) 179 if (!tmp)
184 { 180 {
185 for (pl = first_player; pl; pl = pl->next) 181 for_all_players (pl)
186 if (pl->ob->container == op->env) 182 if (pl->ob->container == op->env)
183 {
184 tmp = pl->ob;
187 break; 185 break;
188 if (pl) 186 }
189 tmp = pl->ob;
190 else
191 tmp = NULL;
192 } 187 }
188
193 if (tmp) 189 if (tmp)
194 esrv_del_item (tmp->contr, op->count); 190 esrv_del_item (tmp->contr, op->count);
195} 191}
196 192
197extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr); 193extern "C" int cfperl_initPlugin (const char *iversion, f_plug_api gethooksptr);
613/* MAP RELATED HOOKS */ 609/* MAP RELATED HOOKS */
614 610
615void * 611void *
616cfapi_map_get_map (int *type, ...) 612cfapi_map_get_map (int *type, ...)
617{ 613{
618 va_list args; 614 abort ();
619 maptile *rv;
620 int ctype;
621 int x, y;
622 sint16 nx, ny;
623 char *name;
624 maptile *m;
625
626 va_start (args, type);
627
628 ctype = va_arg (args, int);
629
630 switch (ctype)
631 {
632 case 0:
633 x = va_arg (args, int);
634 y = va_arg (args, int);
635
636 rv = get_empty_map (x, y);
637 break;
638
639 case 1:
640 name = va_arg (args, char *);
641 x = va_arg (args, int);
642
643 rv = ready_map_name (name, x);
644 break;
645
646 case 2:
647 m = va_arg (args, maptile *);
648 nx = va_arg (args, int);
649 ny = va_arg (args, int);
650
651 rv = get_map_from_coord (m, &nx, &ny);
652 break;
653
654 case 3:
655 rv = first_map;
656 break;
657
658 default:
659 *type = CFAPI_NONE;
660 va_end (args);
661 return NULL;
662 break;
663 }
664 va_end (args);
665 *type = CFAPI_PMAP;
666 return rv;
667} 615}
668 616
669void * 617void *
670cfapi_map_has_been_loaded (int *type, ...) 618cfapi_map_has_been_loaded (int *type, ...)
671{ 619{
672 va_list args; 620 abort ();
673 maptile *map;
674 char *string;
675
676 va_start (args, type);
677 string = va_arg (args, char *);
678
679 map = has_been_loaded (string);
680 va_end (args);
681 *type = CFAPI_PMAP;
682 return map;
683} 621}
684 622
685void * 623void *
686cfapi_map_create_path (int *type, ...) 624cfapi_map_create_path (int *type, ...)
687{ 625{
688 va_list args; 626 abort ();
689 int ctype;
690 const char *str;
691 char *rv;
692
693 va_start (args, type);
694
695 ctype = va_arg (args, int);
696 str = va_arg (args, char *);
697
698 *type = CFAPI_STRING;
699
700 switch (ctype)
701 {
702 case 0:
703 rv = (char *) create_pathname (str);
704 break;
705
706 case 1:
707 rv = (char *) create_overlay_pathname (str);
708 break;
709
710 /*case 2:
711 rv = create_items_path(str);
712 break; */
713
714 default:
715 rv = NULL;
716 *type = CFAPI_NONE;
717 break;
718 }
719 va_end (args);
720 return rv;
721} 627}
722 628
723void * 629void *
724cfapi_map_get_map_property (int *type, ...) 630cfapi_map_get_map_property (int *type, ...)
725{ 631{
726 va_list args; 632 abort ();
727 int x, y;
728 sint16 nx, ny;
729 maptile *map;
730 maptile *newmap;
731 static int rv;
732 int property;
733 char *buf;
734
735 va_start (args, type);
736
737 property = va_arg (args, int);
738
739 switch (property)
740 {
741 case CFAPI_MAP_PROP_FLAGS:
742 map = va_arg (args, maptile *);
743 newmap = va_arg (args, maptile *);
744 x = va_arg (args, int);
745 y = va_arg (args, int);
746 nx = va_arg (args, int);
747 ny = va_arg (args, int);
748
749 rv = get_map_flags (map, &newmap, x, y, &nx, &ny);
750 va_end (args);
751 *type = CFAPI_INT;
752 return &rv;
753 break;
754
755 case CFAPI_MAP_PROP_DIFFICULTY:
756 map = va_arg (args, maptile *);
757
758 rv = calculate_difficulty (map);
759 va_end (args);
760 *type = CFAPI_INT;
761 return &rv;
762 break;
763
764 case CFAPI_MAP_PROP_PATH:
765 map = va_arg (args, maptile *);
766
767 buf = map->path;
768 *type = CFAPI_STRING;
769 va_end (args);
770 return buf;
771 break;
772
773 case CFAPI_MAP_PROP_TMPNAME:
774 map = va_arg (args, maptile *);
775
776 buf = map->tmpname;
777 *type = CFAPI_STRING;
778 va_end (args);
779 return buf;
780 break;
781
782 case CFAPI_MAP_PROP_NAME:
783 map = va_arg (args, maptile *);
784
785 buf = map->name;
786 *type = CFAPI_STRING;
787 va_end (args);
788 return buf;
789 break;
790
791 case CFAPI_MAP_PROP_RESET_TIME:
792 map = va_arg (args, maptile *);
793
794 rv = map->reset_time;
795 *type = CFAPI_INT;
796 va_end (args);
797 return &rv;
798 break;
799
800 case CFAPI_MAP_PROP_RESET_TIMEOUT:
801 map = va_arg (args, maptile *);
802
803 rv = map->reset_timeout;
804 *type = CFAPI_INT;
805 va_end (args);
806 return &rv;
807 break;
808
809 case CFAPI_MAP_PROP_PLAYERS:
810 map = va_arg (args, maptile *);
811
812 rv = map->players;
813 *type = CFAPI_INT;
814 va_end (args);
815 return &rv;
816 break;
817
818 case CFAPI_MAP_PROP_DARKNESS:
819 map = va_arg (args, maptile *);
820
821 rv = map->darkness;
822 *type = CFAPI_INT;
823 va_end (args);
824 return &rv;
825 break;
826
827 case CFAPI_MAP_PROP_WIDTH:
828 map = va_arg (args, maptile *);
829
830 rv = map->width;
831 *type = CFAPI_INT;
832 va_end (args);
833 return &rv;
834 break;
835
836 case CFAPI_MAP_PROP_HEIGHT:
837 map = va_arg (args, maptile *);
838
839 rv = map->height;
840 *type = CFAPI_INT;
841 va_end (args);
842 return &rv;
843 break;
844
845 case CFAPI_MAP_PROP_ENTER_X:
846 map = va_arg (args, maptile *);
847
848 rv = map->enter_x;
849 *type = CFAPI_INT;
850 va_end (args);
851 return &rv;
852 break;
853
854 case CFAPI_MAP_PROP_ENTER_Y:
855 map = va_arg (args, maptile *);
856
857 rv = map->enter_y;
858 *type = CFAPI_INT;
859 va_end (args);
860 return &rv;
861 break;
862
863 case CFAPI_MAP_PROP_TEMPERATURE:
864 map = va_arg (args, maptile *);
865
866 rv = map->temp;
867 *type = CFAPI_INT;
868 va_end (args);
869 return &rv;
870 break;
871
872 case CFAPI_MAP_PROP_PRESSURE:
873 map = va_arg (args, maptile *);
874
875 rv = map->pressure;
876 *type = CFAPI_INT;
877 va_end (args);
878 return &rv;
879 break;
880
881 case CFAPI_MAP_PROP_HUMIDITY:
882 map = va_arg (args, maptile *);
883
884 rv = map->humid;
885 *type = CFAPI_INT;
886 va_end (args);
887 return &rv;
888 break;
889
890 case CFAPI_MAP_PROP_WINDSPEED:
891 map = va_arg (args, maptile *);
892
893 rv = map->windspeed;
894 *type = CFAPI_INT;
895 va_end (args);
896 return &rv;
897 break;
898
899 case CFAPI_MAP_PROP_WINDDIR:
900 map = va_arg (args, maptile *);
901
902 rv = map->winddir;
903 *type = CFAPI_INT;
904 va_end (args);
905 return &rv;
906 break;
907
908 case CFAPI_MAP_PROP_SKY:
909 map = va_arg (args, maptile *);
910
911 rv = map->sky;
912 *type = CFAPI_INT;
913 va_end (args);
914 return &rv;
915 break;
916
917 case CFAPI_MAP_PROP_WPARTX:
918 map = va_arg (args, maptile *);
919
920 rv = map->wpartx;
921 *type = CFAPI_INT;
922 va_end (args);
923 return &rv;
924 break;
925
926 case CFAPI_MAP_PROP_WPARTY:
927 map = va_arg (args, maptile *);
928
929 rv = map->wparty;
930 *type = CFAPI_INT;
931 va_end (args);
932 return &rv;
933 break;
934
935 case CFAPI_MAP_PROP_MESSAGE:
936 map = va_arg (args, maptile *);
937
938 buf = map->msg;
939 *type = CFAPI_STRING;
940 va_end (args);
941 return buf;
942 break;
943
944 case CFAPI_MAP_PROP_NEXT:
945 map = va_arg (args, maptile *);
946
947 *type = CFAPI_PMAP;
948 va_end (args);
949 return map->next;
950 break;
951
952 case CFAPI_MAP_PROP_REGION:
953 map = va_arg (args, maptile *);
954
955 *type = CFAPI_PREGION;
956 va_end (args);
957 return get_region_by_map (map);
958 break;
959
960 default:
961 *type = CFAPI_NONE;
962 va_end (args);
963 return NULL;
964 break;
965 }
966} 633}
967 634
968void * 635void *
969cfapi_map_set_map_property (int *type, ...) 636cfapi_map_set_map_property (int *type, ...)
970{ 637{
971 va_list args; 638 abort ();
972 static int rv;
973 maptile *map;
974 int val;
975 int property;
976
977 va_start (args, type);
978
979 property = va_arg (args, int);
980
981 switch (property)
982 {
983 case CFAPI_MAP_PROP_LIGHT:
984 map = va_arg (args, maptile *);
985 val = va_arg (args, int);
986
987 rv = change_map_light (map, val);
988 *type = CFAPI_INT;
989 va_end (args);
990 return &rv;
991 break;
992
993 case CFAPI_MAP_PROP_RESET_TIME:
994 map = va_arg (args, maptile *);
995
996 *type = CFAPI_NONE;
997 va_end (args);
998 return NULL;
999 break;
1000
1001 default:
1002 *type = CFAPI_NONE;
1003 va_end (args);
1004 return NULL;
1005 break;
1006 }
1007} 639}
640
1008void * 641void *
1009cfapi_map_out_of_map (int *type, ...) 642cfapi_map_out_of_map (int *type, ...)
1010{ 643{
644 abort ();
645}
646
647void *
648cfapi_map_update_position (int *type, ...)
649{
1011 va_list args; 650 va_list args;
1012 static int rv;
1013 maptile *map; 651 maptile *map;
1014 int x, y; 652 int x, y;
1015 653
1016 va_start (args, type); 654 va_start (args, type);
655
1017 map = va_arg (args, maptile *); 656 map = va_arg (args, maptile *);
1018 x = va_arg (args, int); 657 x = va_arg (args, int);
1019 y = va_arg (args, int); 658 y = va_arg (args, int);
1020 659
1021 rv = out_of_map (map, x, y);
1022 va_end (args);
1023 *type = CFAPI_INT;
1024 return &rv;
1025}
1026
1027void *
1028cfapi_map_update_position (int *type, ...)
1029{
1030 va_list args;
1031 maptile *map;
1032 int x, y;
1033
1034 va_start (args, type);
1035
1036 map = va_arg (args, maptile *);
1037 x = va_arg (args, int);
1038 y = va_arg (args, int);
1039
1040 map->at (x, y).flags_ |= P_NEED_UPDATE; 660 map->at (x, y).flags_ |= P_NEED_UPDATE;
1041 661
1042 va_end (args); 662 va_end (args);
1043 *type = CFAPI_NONE; 663 *type = CFAPI_NONE;
1044 return NULL; 664 return NULL;
1045} 665}
1046 666
1047void * 667void *
1048cfapi_map_delete_map (int *type, ...) 668cfapi_map_delete_map (int *type, ...)
1049{ 669{
1050 va_list args; 670 abort ();
1051 maptile *map;
1052
1053 va_start (args, type);
1054
1055 map = va_arg (args, maptile *);
1056
1057 delete_map (map);
1058
1059 va_end (args);
1060 *type = CFAPI_NONE;
1061 return NULL;
1062} 671}
1063 672
1064void * 673void *
1065cfapi_map_message (int *type, ...) 674cfapi_map_message (int *type, ...)
1066{ 675{
1970 if (op->nrof > (uint32) iarg) 1579 if (op->nrof > (uint32) iarg)
1971 decrease_ob_nr (op, op->nrof - iarg); 1580 decrease_ob_nr (op, op->nrof - iarg);
1972 else if (op->nrof < (uint32) iarg) 1581 else if (op->nrof < (uint32) iarg)
1973 { 1582 {
1974 object *tmp; 1583 object *tmp;
1975 player *pl;
1976 1584
1977 op->nrof = iarg; 1585 op->nrof = iarg;
1978 if (op->env != NULL) 1586 if (op->env != NULL)
1979 { 1587 {
1980 tmp = op->in_player (); 1588 tmp = op->in_player ();
1981 if (!tmp) 1589 if (!tmp)
1982 { 1590 {
1983 for (pl = first_player; pl; pl = pl->next) 1591 for_all_players (pl)
1984 if (pl->ob->container == op->env) 1592 if (pl->ob->container == op->env)
1593 {
1594 tmp = pl->ob;
1985 break; 1595 break;
1986 if (pl)
1987 tmp = pl->ob;
1988 else 1596 }
1989 tmp = NULL;
1990 } 1597 }
1991 else 1598 else
1992 { 1599 {
1993 sum_weight (tmp); 1600 sum_weight (tmp);
1994 fix_player (tmp); 1601 tmp->update_stats ();
1995 } 1602 }
1996 if (tmp) 1603 if (tmp)
1997 esrv_send_item (tmp, op); 1604 esrv_send_item (tmp, op);
1998 } 1605 }
1999 else 1606 else
2131 iarg = va_arg (args, int); 1738 iarg = va_arg (args, int);
2132 1739
2133 if (op->weight != iarg) 1740 if (op->weight != iarg)
2134 { 1741 {
2135 object *tmp; 1742 object *tmp;
2136 player *pl;
2137 1743
2138 op->weight = iarg; 1744 op->weight = iarg;
2139 if (op->env != NULL) 1745 if (op->env != NULL)
2140 { 1746 {
2141 tmp = op->in_player (); 1747 tmp = op->in_player ();
2142 if (!tmp) 1748 if (!tmp)
2143 { 1749 {
2144 for (pl = first_player; pl; pl = pl->next) 1750 for_all_players (pl)
2145 if (pl->ob->container == op->env) 1751 if (pl->ob->container == op->env)
1752 {
1753 tmp = pl->ob;
2146 break; 1754 break;
2147 if (pl)
2148 tmp = pl->ob;
2149 else 1755 }
2150 tmp = NULL;
2151 } 1756 }
2152 else 1757 else
2153 { 1758 {
2154 sum_weight (tmp); 1759 sum_weight (tmp);
2155 fix_player (tmp); 1760 tmp->update_stats ();
2156 } 1761 }
2157 if (tmp) 1762 if (tmp)
2158 esrv_send_item (tmp, op); 1763 esrv_send_item (tmp, op);
2159 } 1764 }
2160 else 1765 else
2520} 2125}
2521 2126
2522void * 2127void *
2523cfapi_object_drain (int *type, ...) 2128cfapi_object_drain (int *type, ...)
2524{ 2129{
2525 va_list args; 2130 abort ();
2131}
2526 2132
2133void *
2134cfapi_object_fix (int *type, ...)
2135{
2136 va_list args;
2527 object *op; 2137 object *op;
2528 int ds;
2529 2138
2530 va_start (args, type); 2139 va_start (args, type);
2531 2140
2532 op = va_arg (args, object *); 2141 op = va_arg (args, object *);
2533 ds = va_arg (args, int);
2534 2142
2535 va_end (args); 2143 va_end (args);
2536 2144
2537 drain_specific_stat (op, ds); 2145 op->update_stats ();
2538
2539 *type = CFAPI_NONE;
2540 return NULL;
2541}
2542
2543void *
2544cfapi_object_fix (int *type, ...)
2545{
2546 va_list args;
2547 object *op;
2548
2549 va_start (args, type);
2550
2551 op = va_arg (args, object *);
2552
2553 va_end (args);
2554
2555 fix_player (op);
2556 2146
2557 *type = CFAPI_NONE; 2147 *type = CFAPI_NONE;
2558 return NULL; 2148 return NULL;
2559} 2149}
2560 2150
2904} 2494}
2905 2495
2906void * 2496void *
2907cfapi_object_clear (int *type, ...) 2497cfapi_object_clear (int *type, ...)
2908{ 2498{
2909 va_list args; 2499 abort ();
2910 object *op;
2911
2912 va_start (args, type);
2913
2914 op = va_arg (args, object *);
2915
2916 va_end (args);
2917
2918 op->clear ();
2919 *type = CFAPI_NONE;
2920 return NULL;
2921} 2500}
2922 2501
2923void * 2502void *
2924cfapi_object_reset (int *type, ...) 2503cfapi_object_reset (int *type, ...)
2925{ 2504{
2958} 2537}
2959 2538
2960void * 2539void *
2961cfapi_object_clean_object (int *type, ...) 2540cfapi_object_clean_object (int *type, ...)
2962{ 2541{
2963 va_list args; 2542 abort ();
2964 object *op;
2965
2966 va_start (args, type);
2967 op = va_arg (args, object *);
2968
2969 clean_object (op);
2970 va_end (args);
2971 *type = CFAPI_NONE;
2972 return NULL;
2973} 2543}
2974 2544
2975void * 2545void *
2976cfapi_object_on_same_map (int *type, ...) 2546cfapi_object_on_same_map (int *type, ...)
2977{ 2547{
3557 3127
3558 case CFAPI_PARTY_PROP_PLAYER: 3128 case CFAPI_PARTY_PROP_PLAYER:
3559 *type = CFAPI_PPLAYER; 3129 *type = CFAPI_PPLAYER;
3560 obarg = va_arg (args, object *); 3130 obarg = va_arg (args, object *);
3561 3131
3562 pl = (obarg ? obarg->contr : first_player); 3132 pl = (obarg ? (player *)obarg->contr : first_player);
3563 rv = NULL; 3133 rv = NULL;
3564 for (; pl != NULL; pl = pl->next) 3134 for (; pl != NULL; pl = pl->next)
3565 if (pl->ob->contr->party == party) 3135 if (pl->ob->contr->party == party)
3566 { 3136 {
3567 rv = (void *) pl; 3137 rv = (void *) pl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines