-
Notifications
You must be signed in to change notification settings - Fork 36
/
callfromcli.c
2059 lines (1836 loc) · 60.4 KB
/
callfromcli.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "version.h"
#include <stdio.h>
#include <time.h>
#include<stdlib.h>
#include "common.h"
#include "util.h"
#include "lssproto_serv.h"
#include "saacproto_cli.h"
#include "net.h"
#include "char.h"
#include "object.h"
#include "readmap.h"
#include "addressbook.h"
#include "handletime.h"
#include "configfile.h"
#include "event.h"
#include "pet.h"
#include "battle.h"
#include "battle_command.h"
#include "magic.h"
#include "petmail.h"
#include "item_gen.h"
#include "pet_skill.h"
#include "log.h" //add this because the second had it
#include "map_deal.h" // CoolFish: 2001/4/18
#include "trade.h" // CoolFish: Trade 2001/4/18
#include "family.h" // CoolFish: Family 2001/5/24
#include "item_event.h" // shan: blackmarket
#ifdef _PROFESSION_SKILL // WON ADD 人物职业技能
#include "profession_skill.h"
#endif
#ifdef _CHATROOMPROTOCOL // (不可开) Syu ADD 聊天室频道
#include "chatroom.h"
#endif
BOOL checkStringErr( char * );
// shan add
extern struct FM_PKFLOOR fmpkflnum[FAMILY_FMPKFLOOR];
/* -----------------------------------------------------------------------
* 蓟 仄凶 读及 寞井日平乓仿奶件犯永弁旦毛 月
* ----------------------------------------------------------------------*/
static int Callfromcli_Util_getTargetCharaindex( int fd, int toindex)
{
int to_charaindex = -1;
int fd_charaindex = CONNECT_getCharaindex( fd );
/* 愤坌愤褥 */
if( toindex == 0 ) {
to_charaindex = fd_charaindex;
}
/* 矢永玄 1 5 */
else if( toindex > 0 && toindex < 6 ) {
to_charaindex = CHAR_getCharPet( fd_charaindex, toindex-1);
if( !CHAR_CHECKINDEX( to_charaindex)) {
to_charaindex = -1;
}
}
/* 醮棉 6 10 */
else if( toindex > 5 && toindex < 11 ) {
to_charaindex = CHAR_getPartyIndex( fd_charaindex, toindex - 6);
}
return to_charaindex;
}
/*----------------------------------------
* 弁仿奶失件玄互夫弘奶件允月 匹手丢乒伉卞卺户月分仃卅及匹民尼永弁反卅中
* 仇木毛裟少午 CLI 卞卅月[
----------------------------------------*/
void lssproto_ClientLogin_recv( int fd,char* cdkey, char* passwd )
{
/* 2褐卞仇木互裟壬木月及反中中 */
/* 由旦伐□玉 凳毛仄化岳 分匀凶日疯太仇木毛裟少仪[*/
{//ttom avoid the restore 2001/01/09
int fd_charaindex;
Char *chwk;
// CoolFish: +2 2001/4/18
fd_charaindex = CONNECT_getCharaindex(fd);
chwk = CHAR_getCharPointer(fd_charaindex);
if(CONNECT_isNOTLOGIN(fd)==FALSE){
print("\n the Client had Logined fd=%d",fd);
return;
}
}
//print( "CliLogin cdkey=%s\n" , cdkey );
/* connect卞戊疋□允月 */
CONNECT_setCdkey( fd, cdkey );
CONNECT_setPasswd( fd, passwd );
CONNECT_setCtype( fd, CLI );
{//ttom
unsigned long ip;
int a,b,c,d;
ip=CONNECT_get_userip(fd);
a=(ip % 0x100); ip=ip / 0x100;
b=(ip % 0x100); ip=ip / 0x100;
c=(ip % 0x100); ip=ip / 0x100;
d=(ip % 0x100);
print( "CliLogin cdkey=%s from %d.%d.%d.%d \n",cdkey,a,b,c,d);
}
/* 忒蚕 */
lssproto_ClientLogin_send( fd , "ok" );
}
void lssproto_CreateNewChar_recv( int fd,int dataplacenum,char* charname,
int imgno,int faceimgno,
int vital,int str,int tgh,int dex,
int earth,int water,int fire,int wind,
int hometown )
{
char cdkey[CDKEYLEN];
if( CONNECT_isCLI( fd ) == FALSE )return;
if( CONNECT_isNOTLOGIN(fd) == FALSE ){
lssproto_CreateNewChar_send( fd, FAILED, "Not NOTLOGIN State\n" );
return;
}
#ifdef _DEATH_FAMILY_LOGIN_CHECK // pk战无法创新人物
lssproto_CreateNewChar_send( fd, FAILED, "" );
return;
#endif
#ifdef _DEATH_CONTEND // pk战无法创新人物
lssproto_CreateNewChar_send( fd, FAILED, "" );
return;
#endif
if( strlen( charname ) == 0 ){
lssproto_CreateNewChar_send(fd,FAILED, "0 length name\n");
return;
}else if( strlen(charname) >= 32 ){
lssproto_CreateNewChar_send(fd,FAILED, "Too long charname\n");
return;
// Nuke start 0711: Avoid naming as WAEI
}else if (strstr(charname,"华义")
// WON ADD
|| strstr(charname,"gm") || strstr(charname,"GM")
|| strstr(charname,"Gm") || strstr(charname,"gM")
|| strstr(charname,"gm") || strstr(charname,"GM")
|| strstr(charname,"Gm") || strstr(charname,"gM")
|| strstr(charname,"神秘人物")
// WON END
) {
unsigned ip=CONNECT_get_userip(fd);
int a, b, c, d, ck;
a=(ip % 0x100); ip=ip / 0x100;
b=(ip % 0x100); ip=ip / 0x100;
c=(ip % 0x100); ip=ip / 0x100;
d=(ip % 0x100);
ck= (
( (a== 10) && (b==0) && (c==0) ) ||
( (a==211) && (b==76) && (c==176) && (d==21) ) || // 台北wayi
( (a==210) && (b==64) && (c==97) && ((d>=21)&&(d<=25)) ) ||
( (a==61) && (b==222) && (c==142) && (d==66) )
);
print(" name_WAEI_IP:%d.%d.%d.%d ck:%d ",a,b,c,d,ck );
if( !ck ) {
lssproto_CreateNewChar_send(fd,FAILED, "Invalid charname\n");
return;
}
}
{
// Nuke start 0801,0916: Avoid strange name
int i,ach;
for (i=0,ach=0;i<strlen(charname);i++) {
if ((unsigned char)charname[i]==0xff) { ach=1; break; } // Force no 0xff
if (((unsigned char)charname[i]>=0x7f)&&
((unsigned char)charname[i]<=0xa0)) { ach=1; break; } // Force no 0x7f~0xa0
if ((unsigned char)charname[i]<=0x20) { ach=1; break; } // Force greater than 0x20
if (ach) {
if ((((unsigned char)charname[i]>=0x40)&&((unsigned char)charname[i]<=0x7e))||
(((unsigned char)charname[i]>=0xa1)&&((unsigned char)charname[i]<=0xfe))) ach=0;
} else {
if (((unsigned char)charname[i]>=0xa1)&&((unsigned char)charname[i]<=0xfe)) ach=1;
}
}
if (ach) { lssproto_CreateNewChar_send(fd,FAILED, "Error in Chinese\n"); return; }
// Nuke end
}
// Nuke end
CONNECT_getCdkey( fd, cdkey, sizeof( cdkey ));
CHAR_createNewChar( fd, dataplacenum, charname ,imgno, faceimgno,
vital, str, tgh, dex,
earth, water, fire, wind,
hometown , cdkey );
}
void lssproto_CharLogin_recv( int fd,char* charname )
{
char cdkey[CDKEYLEN], passwd[PASSWDLEN];
if( CONNECT_isCLI( fd ) == FALSE )return;
print( "Attempt to login: charaname=%s\n", charname);
if( charname[0] == '\0' ){
lssproto_CharLogin_send( fd, FAILED, "Can't access char have no name\n" );
return;
}
if( CONNECT_isNOTLOGIN(fd) == FALSE ){
lssproto_CharLogin_send( fd, FAILED, "Already Logged in\n" );
return;
}
CONNECT_setCharname( fd, charname );
CONNECT_getCdkey( fd, cdkey, sizeof( cdkey ));
CONNECT_getPasswd( fd, passwd, sizeof(passwd));
saacproto_ACCharLoad_send( acfd, cdkey,passwd, charname,1,"",
CONNECT_getFdid(fd) );
CONNECT_setState( fd, WHILELOGIN );
}
#ifdef _ITEM_CHECKDROPATLOGOUT
BOOL CheckDropatLogout(int charaindex )
{
int i;
int itemindex;
for( i=0 ; i<CHAR_MAXITEMHAVE ; i++ ){
itemindex = CHAR_getItemIndex(charaindex,i);
if( ITEM_CHECKINDEX(itemindex) == FALSE )continue;
if( ITEM_getInt(itemindex,ITEM_DROPATLOGOUT ) == TRUE ) {
return TRUE;
}
}
return FALSE;
}
#endif
void lssproto_CharLogout_recv( int fd, int flg)
{
char cdkey[CDKEYLEN] , charname[CHARNAMELEN];
if( CONNECT_isCLI( fd ) == FALSE )return;
if( CONNECT_isLOGIN(fd) == FALSE ){
lssproto_CharLogout_send( fd, FAILED, "Not Logged in\n" );
return;
}
{
int charaindex=CONNECT_getCharaindex(fd);
int fl,x,y;
// CoolFish: 2001/10/18
if (!CHAR_CHECKINDEX(charaindex)) return;
if( CHAR_getInt( charaindex, CHAR_LASTTALKELDER) >= 0 )
{
CHAR_getElderPosition( CHAR_getInt( charaindex, CHAR_LASTTALKELDER), &fl, &x, &y );
if( CHAR_getInt(charaindex,CHAR_FLOOR ) == 117){
CHAR_setInt(charaindex,CHAR_X,225);
CHAR_setInt(charaindex,CHAR_Y,13);
lssproto_CharLogout_send( fd, SUCCESSFUL, "success" );
}else{
CHAR_setInt(charaindex,CHAR_FLOOR,fl);
CHAR_setInt(charaindex,CHAR_X,x);
CHAR_setInt(charaindex,CHAR_Y,y);
lssproto_CharLogout_send( fd, SUCCESSFUL, "success" );
}
}
// Robin add
//CHAR_setInt( charaindex, CHAR_LASTLEAVETIME, (int)time(NULL));
}
CHAR_logout(fd,TRUE);
CONNECT_setState( fd, WHILELOGOUTSAVE );
CONNECT_setCharaindex( fd, -1 );
CONNECT_getCdkey( fd, cdkey, sizeof(cdkey ));
CONNECT_getCharname( fd, charname, sizeof(charname));
print( "Logout cdkey:%s charname=%s\n" , cdkey, charname );
}
void lssproto_CharDelete_recv( int fd , char* charname)
{
char cdkey[CDKEYLEN],passwd[PASSWDLEN];
int fdid;
if( CONNECT_isCLI( fd ) == FALSE )return;
if( CONNECT_isNOTLOGIN( fd ) == FALSE ){
lssproto_CharDelete_send( fd, FAILED, "Already Logged in\n" );
return;
}
CONNECT_getCdkey( fd, cdkey, sizeof(cdkey));
CONNECT_getPasswd( fd, passwd, sizeof(passwd));
fdid = CONNECT_getFdid(fd);
saacproto_ACCharDelete_send( acfd, cdkey,passwd, charname , "" ,fdid );
#ifndef _DEATH_CONTEND
{
char buff[512];
char escapebuf[1024];
snprintf( buff, sizeof(buff), "%s_%s", cdkey, charname);
makeEscapeString( buff, escapebuf, sizeof(escapebuf));
saacproto_DBDeleteEntryInt_send(acfd, DB_DUELPOINT, escapebuf, fdid, 0 );
saacproto_DBDeleteEntryString_send( acfd, DB_ADDRESSBOOK, escapebuf, fdid, 0 );
}
saacproto_Broadcast_send( acfd, cdkey, charname, "chardelete", 0);
#endif
CONNECT_setState( fd, WHILECHARDELETE );
}
void lssproto_CharList_recv( int fd )
{
char cdkey[CDKEYLEN], passwd[PASSWDLEN];
int fdid=-1;
if( CONNECT_isCLI( fd ) == FALSE )return;
if( CONNECT_isNOTLOGIN( fd ) == FALSE ){
lssproto_CharList_send( fd, FAILED, "Already Logged in\n" );
return;
}
CONNECT_getCdkey( fd, cdkey, sizeof(cdkey));
CONNECT_getPasswd( fd, passwd, sizeof(passwd));
fdid = CONNECT_getFdid( fd );
/*{
int i;
int playernum = CHAR_getPlayerMaxNum();
for( i=0; i<playernum; i++){
if( !CHAR_CHECKINDEX( i) )continue;
if( !strcmp( CHAR_getChar( i, CHAR_CDKEY), cdkey) ){
lssproto_CharList_send( fd, FAILED, "-1" );
CONNECT_setState( fd, NOTLOGIN );
return;
}
}
}*/
//#ifdef _PKSEVER_VER
// saacproto_ACCharList_send(acfd, cdkey, passwd, fdid, star);
//#else
saacproto_ACCharList_send(acfd, cdkey, passwd, fdid );
//#endif
CONNECT_setState( fd, WHILEDOWNLOADCHARLIST );
}
void lssproto_Echo_recv( int fd,char* arg0 )
{
lssproto_Echo_send( fd , arg0 );
}
#define CHECKFD if( CONNECT_isCLI( fd ) == FALSE )return; if( CONNECT_isLOGIN(fd) == FALSE )return;
#define CHECKFDANDTIME if( CONNECT_isCLI(fd) == FALSE )return; if( CONNECT_isLOGIN(fd) == FALSE )return;
void lssproto_W_recv( int fd,int x,int y,char* direction )
{
//ttom +3
int fd_charaindex, ix, iy;
fd_charaindex = CONNECT_getCharaindex( fd );
ix=CHAR_getInt(fd_charaindex, CHAR_X);
iy=CHAR_getInt(fd_charaindex, CHAR_Y);
// CoolFish: Prevent Trade Cheat 2001/4/18
if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE)
return;
// nuke 0407
if (checkNu(fd)<0) {
// Robin 0521
print(" NU-Err ");
CHAR_talkToCli(fd_charaindex, -1, "讯号错误。", CHAR_COLORYELLOW);
CONNECT_setCloseRequest( fd , 1 );
return;
}
//ttom debug
if((x==0)&&(y==0)){
//CHAR_talkToCli(fd_charaindex, -1, "因座标错误而断线。", CHAR_COLORYELLOW);
// Roibn 03/14
return;
}
//ttom avoid the warp at will 11/6
{
int i_diff_x,i_diff_y;
i_diff_x=abs(ix-x);
i_diff_y=abs(iy-y);
// Robin 03/14
if( (i_diff_x>1)||(i_diff_y>1) ){
// Robin 0518
//CHAR_talkToCli(fd_charaindex, -1, "因走路座标错误而断线。", CHAR_COLORYELLOW);
//return;
x = ix;
y = iy;
}
}
if(!(MAP_walkAble(fd_charaindex,CHAR_getInt(fd_charaindex, CHAR_FLOOR),x,y))){
// Robin 03/14
x = ix;
y = iy;
}else{
}
CHAR_walk_init( fd, x, y, direction, TRUE);
}
/*------------------------------------------------------------
* 汹仁
------------------------------------------------------------*/
void lssproto_W2_recv( int fd,int x,int y,char* direction )
{
//ttom +3
int fd_charaindex, ix, iy, i_fl;
//Char *chwk;// CoolFish: Rem 2001/4/18
fd_charaindex = CONNECT_getCharaindex( fd );
ix=CHAR_getInt(fd_charaindex, CHAR_X);
iy=CHAR_getInt(fd_charaindex, CHAR_Y);
i_fl=CHAR_getInt(fd_charaindex, CHAR_FLOOR);
// CoolFish: Prevent Trade Cheat 2001/4/18
if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE)
return;
//ttom avoid the warp at will 11/6
{
int i_diff_x,i_diff_y;
//ix=CHAR_getInt(fd_charaindex, CHAR_X);
//iy=CHAR_getInt(fd_charaindex, CHAR_Y);
//i_fl=CHAR_getInt(fd_charaindex, CHAR_FLOOR);
i_diff_x=abs(ix-x);
i_diff_y=abs(iy-y);
if( (i_diff_x>1)||(i_diff_y>1) ){//2
//print("\n<www>Warp Error!!!!!!!!!");
//print("\n<www>the origion->fd=%d,x=%d,y=%d",fd,ix,iy);
//print("\n<www>the modify-->fd=%d,X=%d,Y=%d,dir=%s",fd,x,y,direction);
x=ix;
y=iy;
// Robin 03/14
//return;
}
//if((i_fl==117)&&(ix==225)&&(iy==13)) goto END_w;
}//ttom
if(!(MAP_walkAble(fd_charaindex,CHAR_getInt(fd_charaindex, CHAR_FLOOR),x,y))){
print("\n<wwww> the map is invaild(f:%d,x:%d,y:%d)",CHAR_getInt(fd_charaindex, CHAR_FLOOR),x,y);
x = ix;
y = iy;
}
//END_w:
CHAR_walk_init( fd, x, y, direction, FALSE);
}
void lssproto_SKD_recv( int fd,int dir, int index)
{
CHECKFDANDTIME;
}
void lssproto_ID_recv( int fd,int x,int y,int haveitemindex,int toindex )
{
int to_charaindex;
int fd_charaindex;
CHECKFDANDTIME;
fd_charaindex = CONNECT_getCharaindex( fd );
// CoolFish: Prevent Trade Cheat 2001/4/18
if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE)
return;
/* 爵 凛反轮仁 仿弘匹仇木卞娄匀井井月第 岭丐曰 */
if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE)
!= BATTLE_CHARMODE_NONE) return ;
//ttom avoid the warp at will 12/5
{
int ix,iy;
ix=CHAR_getInt(fd_charaindex, CHAR_X);
iy=CHAR_getInt(fd_charaindex, CHAR_Y);
x=ix;
y=iy;
}
CHAR_setMyPosition( fd_charaindex, x,y,TRUE);
to_charaindex = Callfromcli_Util_getTargetCharaindex( fd, toindex);
CHAR_ItemUse( fd_charaindex, to_charaindex, haveitemindex );
}
/*------------------------------------------------------------
* 惫寞毛蓟少
------------------------------------------------------------*/
void lssproto_ST_recv( int fd,int titleindex )
{
CHECKFDANDTIME;
CHAR_selectTitle( CONNECT_getCharaindex( fd) , titleindex );
}
/*------------------------------------------------------------
* 惫寞毛绰轮允月
------------------------------------------------------------*/
void lssproto_DT_recv( int fd,int titleindex )
{
CHECKFDANDTIME;
CHAR_deleteTitle( CONNECT_getCharaindex(fd) , titleindex );
}
/*------------------------------------------------------------
* 愤裘惫寞毛 允月
------------------------------------------------------------*/
void lssproto_FT_recv( int fd,char* data )
{
CHECKFDANDTIME;
// Robin 04/23 debug
if( strlen(data) > 12 ) return;
if( checkStringErr(data) ) return;
CHAR_inputOwnTitle( CONNECT_getCharaindex(fd) , data);
}
/*------------------------------------------------------------
* 失奶 丞毛胶丹
------------------------------------------------------------*/
void lssproto_PI_recv( int fd,int x, int y, int dir )
{
int fd_charaindex;
CHECKFDANDTIME;
fd_charaindex = CONNECT_getCharaindex( fd );
{//ttom avoid warp at will
int ix,iy;
ix=CHAR_getInt(fd_charaindex, CHAR_X);
iy=CHAR_getInt(fd_charaindex, CHAR_Y);
if( (ix!=x)||(iy!=y)){
//print("\n<PI>--Error!!!!");
//print("\n<PI>origion x=%d,y=%d",ix,iy);
//print("\n<PI>modify X=%d,Y=%d",x,y);
x=ix;
y=iy;
}
}//ttom end
CHAR_setMyPosition( fd_charaindex, x,y,TRUE);
if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE)
!= BATTLE_CHARMODE_NONE) return ;
CHAR_PickUpItem( fd_charaindex, dir);
}
void lssproto_DI_recv( int fd,int x, int y, int itemindex )
{
int charaindex;
CHECKFDANDTIME;
charaindex = CONNECT_getCharaindex( fd );
if( CHAR_getWorkInt(charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE) return;
if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE) return;
CHAR_setMyPosition( charaindex ,
CHAR_getInt( charaindex, CHAR_X), CHAR_getInt( charaindex, CHAR_Y), TRUE);
CHAR_DropItem( charaindex, itemindex );
}
void lssproto_DP_recv( int fd,int x, int y, int petindex )
{
int fd_charaindex;
CHECKFDANDTIME;
fd_charaindex = CONNECT_getCharaindex( fd );
if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE)
return;
{
int ix,iy;
ix=CHAR_getInt(fd_charaindex, CHAR_X);
iy=CHAR_getInt(fd_charaindex, CHAR_Y);
x=ix;
y=iy;
}
CHAR_setMyPosition( fd_charaindex , x,y,TRUE);
if( CHAR_getWorkInt( fd_charaindex , CHAR_WORKBATTLEMODE)
!= BATTLE_CHARMODE_NONE) return ;
PET_dropPet( fd_charaindex, petindex);
}
/*------------------------------------------------------------
* 嗯毛 仁
------------------------------------------------------------*/
void lssproto_DG_recv( int fd,int x, int y, int amount )
{
int fd_charaindex;
CHECKFDANDTIME;
fd_charaindex = CONNECT_getCharaindex( fd );
//ttom avoid the warp at will 12/15
{
int ix,iy;
ix=CHAR_getInt(fd_charaindex, CHAR_X);
iy=CHAR_getInt(fd_charaindex, CHAR_Y);
x=ix;
y=iy;
}
CHAR_setMyPosition( fd_charaindex, x,y,TRUE);
/* 爵 反轮仁 仿弘匹仇木卞娄匀井井月第 岭丐曰 */
if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE)
!= BATTLE_CHARMODE_NONE) return ;
// CoolFish: Prevent Trade Cheat 2001/4/18
if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE)
return;
CHAR_DropMoney( fd_charaindex, amount );
}
/*------------------------------------------------------------
* 失奶 丞毛啖 允月[隶 手仇木匹
------------------------------------------------------------*/
void lssproto_MI_recv( int fd,int fromindex,int toindex )
{
int fd_charaindex;
CHECKFDANDTIME;
fd_charaindex = CONNECT_getCharaindex( fd );
// CoolFish: Prevent Trade Cheat 2001/4/18
if (CHAR_getWorkInt(fd_charaindex, CHAR_WORKTRADEMODE) != CHAR_TRADE_FREE)
return;
/* 爵 反轮仁 仿弘匹仇木卞娄匀井井月第 岭丐曰 */
if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE)
!= BATTLE_CHARMODE_NONE) return ;
CHAR_moveEquipItem( fd_charaindex, fromindex, toindex );
}
/*------------------------------------------------------------
* 旦平伙失永皿
------------------------------------------------------------*/
void lssproto_SKUP_recv( int fd,int skillid )
{
int fd_charaindex;
CHECKFDANDTIME;
fd_charaindex = CONNECT_getCharaindex(fd);
/* 爵 反轮仁 仿弘匹仇木卞娄匀井井月第 岭丐曰 */
if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKBATTLEMODE)
!= BATTLE_CHARMODE_NONE) return ;
CHAR_SkillUp(fd_charaindex,skillid);
}
/*------------------------------------------------------------
* 戊生弁扑亦件锹澎卞丢永本□斥毛霜耨
------------------------------------------------------------*/
void lssproto_MSG_recv( int fd,int index,char* message, int color )
{
int fd_charaindex;
CHECKFD;
fd_charaindex = CONNECT_getCharaindex( fd);
ADDRESSBOOK_sendMessage( fd_charaindex, index,message, color );
}
/*------------------------------------------------------------
* 失玉伊旦皮永弁及 毛母它件夫□玉允月邰菲互 凶
------------------------------------------------------------*/
void lssproto_AB_recv( int fd )
{
int fd_charaindex;
CHECKFDANDTIME;
fd_charaindex = CONNECT_getCharaindex( fd );
ADDRESSBOOK_sendAddressbookTable( fd_charaindex );
}
/*------------------------------------------------------------
* 失玉伊旦皮永弁及嫩 毛绰轮允月
------------------------------------------------------------*/
void lssproto_DAB_recv( int fd , int index)
{
int fd_charaindex;
CHECKFDANDTIME;
fd_charaindex = CONNECT_getCharaindex( fd );
ADDRESSBOOK_deleteEntry( fd_charaindex ,index);
}
void lssproto_AAB_recv( int fd , int x, int y)
{
int fd_charaindex;
CHECKFDANDTIME;
fd_charaindex = CONNECT_getCharaindex( fd );
{
int ix,iy;
ix=CHAR_getInt(fd_charaindex, CHAR_X);
iy=CHAR_getInt(fd_charaindex, CHAR_Y);
if( (ix!=x)||(iy!=y)){
x=ix;
y=iy;
}
}
CHAR_setMyPosition( fd_charaindex , x,y,TRUE);
ADDRESSBOOK_addEntry( fd_charaindex );
}
void lssproto_L_recv( int fd, int dir )
{
int fd_charaindex;
CHECKFDANDTIME;
fd_charaindex = CONNECT_getCharaindex( fd );
CHAR_Look( fd_charaindex ,dir );
}
/*------------------------------------------------------------
* 民乓永玄迕丢永本□斥及霜耨
------------------------------------------------------------*/
void lssproto_TK_recv( int fd,int x, int y,char* message,int color, int area )
{
int fd_charaindex,ix,iy;//ttom+2
int fmindex, channel;
CHECKFD;
fd_charaindex = CONNECT_getCharaindex( fd );
fmindex = CHAR_getInt( fd_charaindex, CHAR_FMINDEX );
channel = CHAR_getWorkInt( fd_charaindex, CHAR_WORKFMCHANNEL );
{// Robin 0629 silent
int silentSec, talkCount;
silentSec = CHAR_getInt(fd_charaindex,CHAR_SILENT);
if( silentSec > 0 ) {
int loginTime;
char buf[256];
int leftSec;
loginTime = CHAR_getWorkInt(fd_charaindex, CHAR_WORKLOGINTIME );
// 防止时间修正回朔後 异常禁言 Robin 20040817
if( (int)NowTime.tv_sec < loginTime) {
CHAR_setInt(fd_charaindex, CHAR_SILENT, 0 );
return;
}
if( ((int)NowTime.tv_sec -loginTime) > silentSec ) {
CHAR_setInt(fd_charaindex, CHAR_SILENT, 0 );
return;
}
silentSec += 10; //多禁10秒
leftSec = silentSec - ((int)NowTime.tv_sec - loginTime);
sprintf(buf, "禁言中!!还有%d秒,再讲多禁10秒钟。", leftSec );
CHAR_talkToCli(fd_charaindex, -1, buf, color);
CHAR_setInt(fd_charaindex, CHAR_SILENT, silentSec );
return;
}
talkCount = CHAR_getWorkInt(fd_charaindex, CHAR_WORKTALKCOUNT );
talkCount ++;
CHAR_setWorkInt( fd_charaindex, CHAR_WORKTALKCOUNT, talkCount);
if( talkCount > 8 ) {
int lastTalkTime = CHAR_getWorkInt(fd_charaindex, CHAR_WORKTALKTIME );
if( (int)NowTime.tv_sec - lastTalkTime < 10 ) {
CHAR_setInt( fd_charaindex,CHAR_SILENT, 60 );
CHAR_setWorkInt( fd_charaindex, CHAR_WORKLOGINTIME, (int)NowTime.tv_sec );
CHAR_talkToCli( fd_charaindex, -1, "你太多话了唷,请你的嘴巴先休息个一分钟吧!", color);
CHAR_setWorkInt(fd_charaindex, CHAR_WORKTALKCOUNT, 0 );
return;
}else {
CHAR_setWorkInt( fd_charaindex, CHAR_WORKTALKTIME, (int)NowTime.tv_sec );
CHAR_setWorkInt(fd_charaindex, CHAR_WORKTALKCOUNT, 0 );
}
}
}
ix=CHAR_getInt(fd_charaindex, CHAR_X);
iy=CHAR_getInt(fd_charaindex, CHAR_Y);
x=ix;
y=iy;
CHAR_setMyPosition( fd_charaindex, x,y,TRUE);
if(!CONNECT_get_shutup(fd)){ //ttom add the shut up function
CHAR_Talk( fd,fd_charaindex, message, color, area );
}
}
void lssproto_M_recv( int fd, int fl, int x1, int y1 , int x2, int y2 )
{
char* mapdata;
RECT seek={x1,y1,x2-x1,y2-y1},ret;
CHECKFD;
mapdata = MAP_getdataFromRECT(fl,&seek,&ret);
if( mapdata != NULL ){
lssproto_M_send( fd, fl, ret.x, ret.y,
ret.x+ret.width, ret.y+ret.height, mapdata );
}
}
/*------------------------------------------------------------
* 平乓仿犯□正 邰菲[
------------------------------------------------------------*/
void lssproto_C_recv( int fd, int index )
{
/* 仇木分仃凛棉及涩烂毛苇卅中仪卞允月 */
CHECKFD;
CHAR_sendCSpecifiedObjindex( fd, index);
}
void lssproto_S_recv( int fd, char* category )
{
char* string;
int fd_charaindex;
fd_charaindex = CONNECT_getCharaindex( fd );
string = CHAR_makeStatusString( fd_charaindex, category );
if( string != NULL )
lssproto_S_send( fd , string );
}
void lssproto_EV_recv( int fd,int event,int seqno,int x,int y, int dir )
{
int rc;
int fx,fy;
int fd_charaindex;
CHECKFD;
fd_charaindex = CONNECT_getCharaindex( fd );
{
int ix,iy;
ix=CHAR_getInt(fd_charaindex, CHAR_X);
iy=CHAR_getInt(fd_charaindex, CHAR_Y);
if( ( ix != x ) || ( iy != y ) ){
goto CK1;
}
goto OK;
}
CK1:
{
OBJECT object;
int ix,iy,ifloor,i,j;
int warp_point_x[9];
int warp_point_y[9];
int warp_point=0;
int o,etype,charaindex;
ix=CHAR_getInt(fd_charaindex, CHAR_X);
iy=CHAR_getInt(fd_charaindex, CHAR_Y);
ifloor=CHAR_getInt(fd_charaindex,CHAR_FLOOR);
for(i=iy-1;i<=iy+1;i++){
for(j=ix-1;j<=ix+1;j++){
for( object = MAP_getTopObj(ifloor,j,i) ; object ;object = NEXT_OBJECT(object ) ){
o = GET_OBJINDEX(object);
if( OBJECT_getType(o) == OBJTYPE_CHARA ){
charaindex=OBJECT_getIndex(o);
if( !CHAR_CHECKINDEX(charaindex) ) continue;
etype = CHAR_getWorkInt( charaindex, CHAR_WORKEVENTTYPE);
if( etype != CHAR_EVENT_NONE ) {
if(etype==CHAR_EVENT_WARP){
warp_point_x[warp_point]=j;
warp_point_y[warp_point]=i;
warp_point++;
}
}
}
#ifdef _MAP_WARPPOINT
else if( OBJECT_getType(o) == OBJTYPE_WARPPOINT ){
etype = OBJECT_getchartype( o);
if( etype != CHAR_EVENT_NONE ) {
warp_point_x[warp_point]=j;
warp_point_y[warp_point]=i;
warp_point++;
break;
}
}
#endif
}
}
}
for(i=0;i<warp_point;i++){
if((x==warp_point_x[i])&& (y==warp_point_y[i]))
goto OK;
}
x=CHAR_getInt(fd_charaindex, CHAR_X);
y=CHAR_getInt(fd_charaindex, CHAR_Y);
}
OK:
CHAR_setMyPosition( fd_charaindex, x,y,TRUE);
CHAR_setWorkChar( fd_charaindex , CHAR_WORKWALKARRAY,"");
if( dir < 0 || dir > 7) {
fx = CHAR_getInt(fd_charaindex, CHAR_X);
fy = CHAR_getInt(fd_charaindex, CHAR_Y);
}else {
CHAR_getCoordinationDir( dir, CHAR_getInt(fd_charaindex, CHAR_X),
CHAR_getInt(fd_charaindex, CHAR_Y),1,&fx,&fy);
}
rc = EVENT_main(fd_charaindex, event,fx,fy);
lssproto_EV_send( fd, seqno, rc);
}
/*------------------------------------------------------------
* 巨件市它件玄 戏
------------------------------------------------------------*/
void lssproto_EN_recv( int fd , int x,int y )
{
int ret = FALSE, err = 0;
int fd_charaindex;
CHECKFD;
fd_charaindex = CONNECT_getCharaindex( fd);
//print(" EN_recv ");
if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE) != CHAR_PARTY_CLIENT){
CHAR_setMyPosition( fd_charaindex, x,y,TRUE);
CHAR_setWorkChar( fd_charaindex, CHAR_WORKWALKARRAY,"");
err = BATTLE_CreateVsEnemy( fd_charaindex,0, -1);
if( err != 0 ){
ret = FALSE;
}else{
ret = TRUE;
}
}
}
/*------------------------------------------------------------
* 皿伊奶乩□ 衔匹巨件市它件玄 瑁 戏
------------------------------------------------------------*/
void lssproto_DU_recv( int fd , int x,int y )
{
OBJECT object;
int fd_charaindex;
int ret = FALSE, charaindex = -1, enemyindex;
int frontx,fronty;
int cnt = 0;
BOOL found = FALSE;
CHECKFDANDTIME;
fd_charaindex = CONNECT_getCharaindex( fd );
{//ttom avoid warp at will
int ix,iy;
ix=CHAR_getInt(fd_charaindex, CHAR_X);
iy=CHAR_getInt(fd_charaindex, CHAR_Y);
if( (ix!=x)||(iy!=y)){
//print("\n<DU>--Error!!!!");
//print("\n<DU>origion x=%d,y=%d",ix,iy);
//print("\n<DU>modify X=%d,Y=%d",x,y);
x=ix;
y=iy;
}
}
/* 阂及凛反 骰允月 */
if( CHAR_getWorkInt( fd_charaindex, CHAR_WORKPARTYMODE)
!= CHAR_PARTY_CLIENT)
{
int i;
// 愤坌及奶件犯永弁旦
charaindex = fd_charaindex;
CHAR_setMyPosition( charaindex, x,y,TRUE);
/* WALKARRAY毛弁伉失允月 */
CHAR_setWorkChar( charaindex, CHAR_WORKWALKARRAY,"");
/* 赓渝祭允月 */
for( i = 0; i < CONNECT_WINDOWBUFSIZE ; i ++ ) {
CONNECT_setDuelcharaindex( fd, i, -1 );
}
/* 及蟆及甄 毛 月 */
CHAR_getCoordinationDir( CHAR_getInt( charaindex, CHAR_DIR ) ,
CHAR_getInt( charaindex , CHAR_X ),
CHAR_getInt( charaindex , CHAR_Y ) ,
1 , &frontx , &fronty );
int toindex ,objindex,tmpindex;
/*愤坌及 及蟆及平乓仿毛潸 允月 */
for( object = MAP_getTopObj( CHAR_getInt( charaindex, CHAR_FLOOR),
frontx,fronty) ;
object ;
object = NEXT_OBJECT(object ) )
{
objindex = GET_OBJINDEX(object);
/* 平乓仿弁正□元扎卅中 */
if( OBJECT_getType( objindex) != OBJTYPE_CHARA) continue;
toindex = OBJECT_getIndex( objindex);
/* 皿伊奶乩□元扎卅中 */
if( CHAR_getInt( toindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER ) continue;
found = TRUE;
/* 爵 分匀凶日蛲 */
if( CHAR_getWorkInt( toindex, CHAR_WORKBATTLEMODE) != BATTLE_CHARMODE_NONE ){
continue;
}
/* 辅爵蛐 卅日蛲 */
if( !CHAR_getFlg( toindex, CHAR_ISDUEL)) continue;
// shan begin
{
for( i=0; i<FAMILY_FMPKFLOOR; i++){
if( fmpkflnum[i].fl == CHAR_getInt( charaindex, CHAR_FLOOR) ){
if( CHAR_getWorkInt( charaindex, CHAR_WORKBATTLEFLAG) == -1 ){
lssproto_EN_send( fd, FALSE, 0 );
return;
}
if(CHAR_getInt( charaindex, CHAR_FMINDEX) == CHAR_getInt( toindex, CHAR_FMINDEX)){
lssproto_EN_send( fd, FALSE, 0 );
return;
}
}
}
}
// shan end
// 阂间卅日褪毛裟氏匹仁月
if( CHAR_getWorkInt( toindex, CHAR_WORKPARTYMODE )
== CHAR_PARTY_CLIENT )
{
tmpindex = CHAR_getWorkInt( toindex, CHAR_WORKPARTYINDEX1 );
/* 锹澎互皿伊奶乩□匹卅中仪手丐月 */
if( CHAR_CHECKINDEX( tmpindex)) {
if( CHAR_getWorkInt( tmpindex, CHAR_WHICHTYPE) != CHAR_TYPEPLAYER){