-
Notifications
You must be signed in to change notification settings - Fork 36
/
callfromac.c
1853 lines (1678 loc) · 53.4 KB
/
callfromac.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 <stdio.h>
#include "version.h"
#include "common.h"
#include "saacproto_cli.h"
#include "lssproto_serv.h"
#include "net.h"
#include "char.h"
#include "object.h"
#include "readmap.h"
#include "msignal.h"
#include "map_deal.h"
#include "npc_duelranking.h"
#include "npc_warpman.h"
#include "handletime.h"
#include "npc_scheduleman.h"
#include "configfile.h"
#include "chatroom.h"
#ifdef _PAUCTION_MAN
#include "npc_pauctionman.h"
#endif
#include "npc_eventaction.h"
// CoolFish: Family 2001/5/24
#include "family.h"
#include "defend.h"
#include "log.h"
#include "buf.h"
#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC
#include "npc_alldoman.h"
#endif
#ifdef _RACEMAN
#include "npc_raceman.h"
#endif
#ifdef _DEATH_CONTEND
#include "deathcontend.h"
#endif
time_t initTime =0;
extern BOOL bNewServer;
extern int i_shutdown_time;//ttom
void saacproto_ACGmsvDownRequest_recv( int fd, int min)
{
char buff[256];
int i;
int playernum = CHAR_getPlayerMaxNum();
snprintf( buff, sizeof( buff),"怀念石器系统公告。");
for( i = 0 ; i < playernum ; i++) {
if( CHAR_getCharUse(i) != FALSE ) {
CHAR_talkToCli( i, -1, buff, CHAR_COLORYELLOW);
}
}
SERVSTATE_setLimittime(min);
SERVSTATE_setShutdown( NowTime.tv_sec );
SERVSTATE_setDsptime( 0 );
}
//检查是否有和ac连接,以及载入家族
void saacproto_ACServerLogin_recv (int fd, char* result,char* data)
{
if( strcmp( result , SUCCESSFUL ) != 0 ){
/* 夫弘奶件撩 */
print( "saacproto_ACServerLogin fail! so quitting...[%s][%s]\n",
result,data );
shutdownProgram( );
exit(1);
}
print("ac login ok\n");
time(&initTime);
if( bNewServer )
print(" New Server! ");
else
print(" Old Server! ");
#ifdef _SERVER_NUMS
print( " version : <%s>" , SERVER_VERSION);
#endif
print(" NORMAL_SERVER! ");
// Robin 0530
//saacproto_ACShowFMList_send( acfd );
FAMILY_Init();
#ifdef _UNIVERSE_CHATROOM
CHATROOM_getChatRoomList();
#endif
#ifdef _ANGEL_SUMMON
saacproto_ACMissionTable_send( acfd, -1, 1, "", "");
#endif
}
void saacproto_ACCharList_recv(int fd, char* result, char* data,int retfd)
{
int clifd = getfdFromFdid(retfd);
if( CONNECT_checkfd(clifd) == FALSE ){
return;
}
lssproto_CharList_send( clifd, result , data );
CONNECT_setState( clifd, NOTLOGIN );
}
void saacproto_ACCharLoad_recv(int fd , char* result,char* data,int retfd,int saveindex)
{
int clifd = getfdFromFdid(retfd);
if( CONNECT_checkfd( clifd ) == FALSE )return;
if(( strcmp( result , SUCCESSFUL ) == 0 )&&(data[0])) {
#ifdef _BAD_PLAYER // WON ADD 送坏玩家去关
CHAR_login( clifd, data, saveindex, 0 ); // 正常玩家
}else if( ( strcmp( result , BADPLAYER ) == 0 ) && (data[0]) ){
CHAR_login( clifd, data, saveindex, 1 ); // 坏玩家
#else
CHAR_login( clifd,data,saveindex );
#endif
}else{
char cdkey[64];
#ifndef _FIX_MESSAGE // WON ADD 修改WORKER封包内容
data = "";
#endif
CONNECT_getCdkey( clifd, cdkey , sizeof( cdkey ));
print(" (%s)ACCharLoad错误:%s ", cdkey, data);
lssproto_CharLogin_send( clifd, result ,data );
CONNECT_setState( clifd, NOTLOGIN );
}
}
#ifdef _DEATH_CONTEND
void saacproto_LoadPkTeamListData_recv(int fd , char* result, char* data, int ti )
{
//andy_log
print("LoadPkTeamListData_recv( %s, %d) data len:%d\n", result, ti, strlen(data) );
if( !strcmp( result, "success") ){
if( PKLIST_LoadPkTeamListData() == FALSE ) return;
if( ti != - 1 )
saacproto_LoadPkTeamListData_send( fd , ti, 1000);
}
}
//要求资讯
void saacproto_PKLISTCHARTS_recv( int fd, char *data, int type, int flg)
{
//andy_log
print("PKLISTCHARTS_recv() \n");
if( data == NULL ) return;
PKLIST_HandleChartsMess( fd, data, type, flg);
}
#endif
#ifdef _PAUCTION_MAN
void saacproto_ACItemAuction_recv( int fd, char *ITEMNAME, char *data, int itemID, int ret, int flg)
{
//物品处理
switch( flg) {
case 1:
{
int itemindex=-1;
itemindex = NPC_PAItemShop_AddItem( itemID, ret);
if( !ITEM_CHECKINDEX( itemindex) )
return;
NPC_PAItemShop_reItem( itemindex, data);
}
break;
case 2:
{
NPC_PAItemShop_DelItem( ret, -1);
}
break;
}
}
#endif
/*
*本□皮卞凶中允月忒蚕[
* state卞方匀化质 毛坌仃月
*/
void saacproto_ACCharSave_recv(int fd ,char* result, char* data,int retfd)
{
int clifd = getfdFromFdid(retfd) , fdid;
char cdkey[CDKEYLEN], passwd[PASSWDLEN], charname[CHARNAMELEN];
/*
* 端巨仿□匹手卅中及卞仇仇匹反元井木月仪反丐月
* 公木反}中五卅曰涛粮毛濠匀凶凛分[
*/
if( CONNECT_checkfd( clifd )== FALSE ) return;
CONNECT_getCdkey( clifd, cdkey, sizeof( cdkey ));
CONNECT_getPasswd( clifd, passwd, sizeof( passwd));
CONNECT_getCharname( clifd, charname, sizeof( charname ));
fdid = CONNECT_getFdid( clifd );
switch( CONNECT_getState( clifd ) ){
case WHILECREATE:
/* 平乓仿综曰匹及本□皮 */
/* 公木毛弁仿奶失件玄卞中丹( 公及引引 )*/
if( strcmp(result,FAILED) ==0 ) data ="";
lssproto_CreateNewChar_send( clifd , result , data);
CONNECT_setState( clifd, NOTLOGIN );
break;
case WHILELOGOUTSAVE:
/* 骚及夫弘失它玄及凛及本□皮及忒蚕 */
if( strcmp( result , SUCCESSFUL ) == 0 )
/* 岳 */
lssproto_CharLogout_send( clifd, result , "success" );
else
/* 巨仿□支午仄扎屯月 */
lssproto_CharLogout_send( clifd, result , "Cannot save" );
CONNECT_setState( clifd, NOTLOGIN );
CONNECT_setCharaindex( clifd, -1 );
break;
case WHILELOSTCHARSAVE:
/* 瑛绊互升丹匹丐木}仇及平乓仿反绰轮允月 */
saacproto_ACCharDelete_send( acfd, cdkey,passwd,charname,"",fdid );
CONNECT_setState( clifd, WHILELOSTCHARDELETE );
CONNECT_setCharaindex( clifd, -1 );
break;
case WHILECLOSEALLSOCKETSSAVE:
CONNECT_setState( clifd, NOTLOGIN );
// Arminius debug
// CONNECT_endOne_debug(clifd);
CONNECT_setUse( clifd , FALSE);
SERVSTATE_decrementCloseallsocketnum();
if( SERVSTATE_getCloseallsocketnum() == 0 ) {
SERVSTATE_SetAcceptMore( -1 );
print( "All character saved\n" );
print("\n the shutdown time =%d",i_shutdown_time);//ttom
if(i_shutdown_time==1){
system( "touch normalstop" );
sigshutdown( 0 );
}
}
default:
break;
}
}
void saacproto_ACCharDelete_recv(int fd,char* result,char* data,int retfd)
{
int clifd = getfdFromFdid(retfd);
if( CONNECT_checkfd( clifd ) == FALSE )return;
switch( CONNECT_getState(clifd) ){
case WHILELOSTCHARDELETE:
/* 夫旦玄匹平乓仿壅仄 及忒蚕 */
/* 窒手仄卅中 */
/* 橇谪毛 允 */
CONNECT_setState(clifd, NOTLOGIN );
CONNECT_setCharaindex( clifd, -1 );
break;
case WHILECHARDELETE:
/* 骚及平乓仿壅仄 */
/* 公及引引霜月 */
if( strcmp(result,FAILED) == 0)data="";
lssproto_CharDelete_send( clifd, result , data );
CONNECT_setState( clifd, NOTLOGIN );
CONNECT_setCharaindex( clifd, -1 );
break;
default:
break;
}
}
/*
* 夫永弁及忒蚕[仇木反荸轮卞仄井银歹卅中[蜇箕幻廿银歹木月 烂反卅中
*/
void saacproto_ACLock_recv(int fd , char* result, char* data ,int retfd)
{
int clifd = getfdFromFdid(retfd);
char cdkey[CDKEYLEN];
int cindex = getCharindexFromFdid(retfd);
if( CONNECT_checkfd(clifd) == FALSE) return;
// Arminius 7.25 GM unlock test
if (strncmp(data, "USRLOCKED", 9)==0) {
char buf[4096];
sprintf(buf, "%s", &data[10]);
CHAR_talkToCli(cindex, -1, buf, CHAR_COLORYELLOW);
return;
} else if (strncmp(data, "USRUNLOCKED", 11)==0) {
CHAR_talkToCli(cindex, -1, "User not locked.", CHAR_COLORYELLOW);
return;
} else if (strncmp(data, "GMUNLOCKSUCCESS", 15)==0) {
CHAR_talkToCli(cindex, -1, "User unlock success", CHAR_COLORYELLOW);
return;
} else if (strncmp(data, "GMUNLOCKFAIL", 12)==0) {
CHAR_talkToCli(cindex, -1, "User unlock failed", CHAR_COLORYELLOW);
return;
} else if (strncmp(data, "GMUNLOCKALL", 11)==0) {
CHAR_talkToCli(cindex, -1, "Server unlocked", CHAR_COLORYELLOW);
return;
}
CONNECT_getCdkey( clifd, cdkey , sizeof( cdkey ));
switch( CONNECT_getState( clifd ) ){
case WHILECANNOTLOGIN:
/* 夫弘奶件撩 仄凶凛及夫永弁及忒蚕 */
if( strcmp( result , SUCCESSFUL ) == 0 ){
/* 岳 匹窒手仄化中卅中橇谪卞允月 */
CONNECT_setState( clifd, NOTLOGIN );
}else{
/*
* 丢永本□斥毛苇月
*/
char mesg[128];
snprintf( mesg ,sizeof( mesg ), "%s hasn't been locked" ,cdkey);
if( strcmp( data , mesg ) == 0 ){
/*
* 夫永弁今木化中卅中及匹手丹窒手仄卅中[
* 岳 仄凶及午 元健中卞允月[
*/
CONNECT_setState( clifd, NOTLOGIN );
}else{
/*
* 疯蘸夫永弁荸轮仄方丹午允月
* state 及 祭卅仄[
*/
saacproto_ACLock_send(fd, cdkey ,
UNLOCK, CONNECT_getFdid( clifd) );
}
}
break;
default:
break;
}
}
void saacproto_ACUCheck_recv( int fd , char *cd )
{
int conind;
int flag = 0;
conind = getfdFromCdkeyWithLogin( cd );
flag = ( conind >= 0 ) ? 1 : 0;
saacproto_ACUCheck_send( fd , cd , flag );
}
/* ---------------------------------------------
* 犯□正矛□旦凳蕙熬仃午曰质 醒袄
* --------------------------------------------*/
void saacproto_DBUpdateEntryInt_recv( int fd,char* result,
char* table,char* key,int msgid,int msgid2 )
{
if( strcmp( result, NET_STRING_FAILED) == 0 ) {
print( "failed: DBUpdateEntryInt\n");
return;
}
}
/* ---------------------------------------------
* 犯□正矛□旦凳蕙熬仃午曰质 侬
* --------------------------------------------*/
void saacproto_DBUpdateEntryString_recv( int fd,char* result,
char* table,char* key,int msgid,int msgid2 )
{
if( strcmp( result, NET_STRING_FAILED) == 0 ) {
print( "failed: DBUpdateEntryString\n");
return;
}
}
/* ---------------------------------------------
* 犯□正矛□旦熬仃午曰质 仿件弁
* --------------------------------------------*/
void saacproto_DBGetEntryRank_recv( int fd,char* result,int rank,int count,
char* table,char* key,int msgid,int msgid2 )
{
if( strcmp( result, NET_STRING_FAILED) == 0 ) {
print( "failed: DBGetEntryRank\n");
return;
}
if( strcmp( table, DB_DUELPOINT) == 0 ) {
if( CHAR_getInt( OBJECT_getIndex( msgid2), CHAR_WHICHTYPE) == CHAR_TYPEDUELRANKING){
NPC_Duelranking_CallMyRanking( count, msgid, msgid2);
}else {
NPC_GetDuelRank( rank, msgid, msgid2);
}
}
}
void saacproto_DBDeleteEntryInt_recv( int fd,char* result,
char* table,char* key,int msgid,int msgid2 )
{
if( strcmp( result, NET_STRING_FAILED) == 0 ) {
print( "failed: DBDeleteEntryInt\n");
return;
}
}
/* ---------------------------------------------
* 犯□正矛□旦绰轮熬仃午曰质 侬
* --------------------------------------------*/
void saacproto_DBDeleteEntryString_recv( int fd,char* result,
char* table,char* key,int msgid,int msgid2 )
{
if( strcmp( result, NET_STRING_FAILED) == 0 ) {
print( "failed: DBDeleteEntryString\n");
return;
}
}
/* ---------------------------------------------
* 犯□正矛□旦熬仃午曰质 醒袄
* --------------------------------------------*/
void saacproto_DBGetEntryInt_recv( int fd,char* result,int value,
char* table,char* key,int msgid,int msgid2 )
{
if( strcmp( result, NET_STRING_FAILED) == 0 ) {
print( "failed: DBGetEntryInt\n");
return;
}
}
/* ---------------------------------------------
* 犯□正矛□旦熬仃午曰质 侬
* --------------------------------------------*/
void saacproto_DBGetEntryString_recv( int fd,char* result,char *value,
char* table,char* key,int msgid,int msgid2 )
{
char cdkey[32];
char charaname[32];
if( strcmp( table, DB_ADDRESSBOOK) == 0 ){
int mode = 1;
if( strcmp( result, NET_STRING_FAILED) == 0 ) {
mode = 0;
}
makeStringFromEscaped( key);
if( !getStringFromIndexWithDelim( key, "_", 1, cdkey, sizeof( cdkey)) ){
return;
}
if( !getStringFromIndexWithDelim( key, "_", 2, charaname, sizeof( charaname)) ){
return;
}
ADDRESSBOOK_DispatchMessage( cdkey, charaname, value, mode);
}else {
if( strcmp( result, NET_STRING_FAILED) == 0 ) {
print( "failed: DBGetEntryString\n");
return;
}
}
}
void saacproto_DBGetEntryByRank_recv( int fd,char* result,char* list,
char* table,int msgid,int msgid2 )
{
if( strcmp( result, NET_STRING_FAILED) == 0 ) {
print( "failed: DBGetEntryByRank\n");
return;
}
}
/* ---------------------------------------------
* 犯□正矛□旦熬仃午曰质 市它件玄
* --------------------------------------------*/
void saacproto_DBGetEntryByCount_recv( int fd,char* result,char* list,
char* table,int count_start,int msgid,int msgid2 )
{
if( strcmp( result, NET_STRING_FAILED) == 0 ) {
print( "failed: DBGetEntryByCount\n");
return;
}
/* duelpoint database 及质 */
if( strcmp( table, DB_DUELPOINT) == 0 ) {
NPC_Duelranking_PrintRanking( list, count_start, msgid, msgid2);
}
}
#ifdef _ALLDOMAN // (不可开) Syu ADD 排行榜NPC
void saacproto_UpdataStele_recv( int fd , char *token)
{
NPC_AlldomanWriteStele( token );
}
void saacproto_S_UpdataStele_recv( int i , char *ocdkey , char *oname , char *ncdkey ,
char *nname , char *title , int level , int trns , int floor )
{
print("\nSyu log 收到Single=> %s , %s , %s , %s ",ocdkey , oname , ncdkey , nname);
NPC_Alldoman_S_WriteStele( ocdkey , oname , ncdkey , nname , title , level , trns , floor ) ;
}
#endif
/* ---------------------------------------------
* 皮夫□玉平乓旦玄丢永本□斥熬仃午曰
* --------------------------------------------*/
void saacproto_Broadcast_recv( int fd,char* id,char* charname,char *message )
{
#ifndef _DEATH_CONTEND
if( strstr( message, "online") == 0 ||
strstr( message, "offline") == 0 ||
strstr( message, "param") == 0 ||
strstr( message, "chardelete") == 0 ){
char buff[512];
char escapebuf[1024];
snprintf( buff, sizeof( buff),"%s_%s", id, charname );
makeEscapeString( buff, escapebuf, sizeof(escapebuf));
saacproto_DBGetEntryString_send( acfd, DB_ADDRESSBOOK, escapebuf, 0,0);
}
#endif
}
void saacproto_Message_recv( int fd,char* id_from,char* charname_from,
char* id_to,char* charname_to,
char* message,int option,int mesgid )
{
BOOL ret;
ret = ADDRESSBOOK_sendMessage_FromOther( id_from, charname_from,
id_to, charname_to,
message, option
);
if( ret == TRUE) {
saacproto_MessageAck_send( acfd, id_to, charname_to,
"successful",mesgid);
}
}
/* ---------------------------------------------
* CoolFish: Family 2001/5/9
* --------------------------------------------*/
void saacproto_ACAddFM_recv(int fd, char *result, int fmindex, int charfdid,
int index)
{
int ret;
int clifd = getfdFromFdid(charfdid);
// print("ACAddFM_0\n");
if (CONNECT_checkfd(clifd) == FALSE) return;
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
// print("ACAddFM_1 clifd:%d ret:%d fmindex:%d index:%d\n",
// clifd, ret, fmindex, index);
ACAddFM(clifd, ret, fmindex, index);
}
void saacproto_ACJoinFM_recv(int fd, char *result, int recv, int charfdid)
{
int ret;
int clifd = getfdFromFdid(charfdid);
if (CONNECT_checkfd(clifd) == FALSE) return;
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
ACJoinFM(clifd, ret, recv);
}
void saacproto_ACLeaveFM_recv(int fd, char *result, int resultflag, int charfdid)
{
int ret;
int clifd = getfdFromFdid(charfdid);
if (CONNECT_checkfd(clifd) == FALSE) return;
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
ACLeaveFM(clifd, ret, resultflag);
print(" ACLeaveFM_%d ", ret );
}
void saacproto_ACChangeFM_recv(int fd, char *result, int charfdid)
{
}
void saacproto_ACDelFM_recv(int fd, char *result, int charfdid)
{
int ret;
int clifd = getfdFromFdid(charfdid);
if (CONNECT_checkfd(clifd) == FALSE) return;
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
ACDelFM(clifd, ret);
print(" ACDelFM_%d ", ret);
}
void saacproto_ACShowFMList_recv(int fd, char *result, int fmnum, char *data)
{
int ret;
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
ACShowFMList(ret, fmnum, data);
}
#ifdef _DEATH_FAMILY_GM_COMMAND // WON ADD 家族战GM指令
void saacproto_ACRELOADFMOK_recv( int fd, int charindex )
{
CHAR_talkToCli( charindex, -1, "重读家族资料OK!", CHAR_COLORYELLOW);
}
void saacproto_ACSHOWMEMBERLIST2_recv( int fd, int charaindex, int fm1, char *fm1_name, int fm2, char *fm2_name, int time, int id )
{
#define SCHEDULEFILEDIR "./Schedule/"
#define floor 141
int i, hour = 0, min = 0;
int fmpks_pos = id * 24;
char f1[20] = {0}, f2[20] = {0};
hour = time / 100;
min = time % 100;
if( fm1_name == NULL || fm2_name == NULL ) return;
sprintf( f1, "%s", fm1_name );
sprintf( f2, "%s", fm2_name );
char msg[256],filename[256],tmp[4096],n1[256],n2[256];
FILE *f;
int j, x, y;
for( i=0; i<MAX_SCHEDULE; i++){
if( fmpks[fmpks_pos+i].dueltime == hour*100 ){
fmpks[fmpks_pos+i].host_index = fm1;
fmpks[fmpks_pos+i].guest_index = fm2;
strcpy( fmpks[fmpks_pos+i].host_name, f1 );
strcpy( fmpks[fmpks_pos+i].guest_name, f2 );
fmpks[fmpks_pos+i].prepare_time = min;
fmpks[fmpks_pos+i].max_player = 50; // 乱斗生存战
fmpks[fmpks_pos+i].win = 0;
fmpks[fmpks_pos+i].flag = FMPKS_FLAG_SCHEDULED;
fmpks[fmpks_pos+i].setting_timeout = 60 * 2; // 二小时
sprintf( msg, "%s 对 %s 家族挑战设定完成", f1, f2 );
CHAR_talkToCli( charaindex, -1, msg, CHAR_COLORYELLOW );
// save file
{
x=0;
y=0;
switch( id ){
case 10: x = 46;
y = 17;
break;
case 11: x = 46;
y = 34;
break;
case 12: x = 29;
y = 46;
break;
case 13: x = 3;
y = 31;
break;
case 14: x = 3;
y = 15;
break;
}
snprintf(filename,sizeof(filename), "%s%d_%d_%d", SCHEDULEFILEDIR, floor, x, y );
if( (f=fopen(filename, "w") ) ){
for( j = 0; j < MAX_SCHEDULE; j++ ){
makeEscapeString(fmpks[fmpks_pos+j].host_name,n1,sizeof(n1));
makeEscapeString(fmpks[fmpks_pos+j].guest_name,n2,sizeof(n2));
sprintf(tmp, "%d|%d|%s|%d|%s|%d|%d|%d|%d\n",
fmpks[fmpks_pos+j].dueltime,
fmpks[fmpks_pos+j].host_index,
n1,
fmpks[fmpks_pos+j].guest_index,
n2,
fmpks[fmpks_pos+j].prepare_time,
fmpks[fmpks_pos+j].max_player,
fmpks[fmpks_pos+j].flag,
fmpks[fmpks_pos+j].win);
fwrite(tmp, strlen(tmp), 1, f);
}
fclose(f);
}else{
print("\n open %s Err", filename );
}
}
return;
}
}
}
#endif
#ifdef _DEATH_FAMILY_STRUCT // WON ADD 家族战存放胜负资料
void saacproto_ACSendFmPkStruct_recv( int fd, char *data )
{
int i;
char all_data[fm_pk_max][128] = {0};
FILE *f;
char buf1[128] = {0};
for( i=0; i<fm_pk_max; i++ ){
if( getStringFromIndexWithDelim( data, "|", i, buf1, sizeof( buf1)) )
sprintf( all_data[i], "%s", buf1 );
}
if( (f=fopen( "d_fm_pk_log.txt", "w+") ) ){
for( i=0; i<fm_pk_max; i++ ){
if( all_data[i][0] != 0 )
fprintf( f, "%s\n", all_data[i] );
}
fclose( f );
}else{
print("\n open d_fm_pk_log.txt Err !!");
}
}
#endif
#ifdef _DEATH_FAMILY_LOGIN_CHECK // WON ADD 家族战登入检查
void saacproto_ACSendMember_recv(int fd, char *result, char *data, int charindex )
{
char token[128] = {0};
int fmarray = -1;
if( strcmp( result, "failed" ) == 0 ){
CHAR_warpToSpecificPoint( charindex, 887, 57, 14 );
CHAR_talkToCli( charindex, -1, "您未报名跨星系家族战", CHAR_COLORYELLOW);
return;
}
SetFMPetVarInit(charindex); // 清除守护兽 Flag
if(getStringFromIndexWithDelim(data,"|",1,token,sizeof(token))){
fmarray = atoi(token);
if( fmarray < 0 ){
CHAR_warpToSpecificPoint( charindex, 887, 57, 14 );
CHAR_talkToCli( charindex, -1, "您未报名跨星系家族战", CHAR_COLORYELLOW);
return;
}
CHAR_setInt( charindex, CHAR_FMINDEX, fmarray + 1 );
CHAR_setWorkInt( charindex, CHAR_WORKFMINDEXI, fmarray );
JoinMemberIndex( charindex, fmarray );
}
if(getStringFromIndexWithDelim(data,"|",2,token,sizeof(token))){
CHAR_setInt( charindex, CHAR_FMSPRITE, atoi(token) );
}
if(getStringFromIndexWithDelim(data,"|",3,token,sizeof(token))){
CHAR_setInt( charindex, CHAR_FMLEADERFLAG, atoi(token) );
}
if(getStringFromIndexWithDelim(data,"|",4,token,sizeof(token))){
CHAR_setWorkInt( charindex, CHAR_WORKFMSETUPFLAG, atoi(token) );
}
if(getStringFromIndexWithDelim(data,"|",5,token,sizeof(token))){
CHAR_setChar( charindex, CHAR_FMNAME, token );
}
CHAR_setWorkInt(charindex, CHAR_WORKFMCHARINDEX, charindex );
CHAR_sendStatusString(charindex, "f");
CHAR_complianceParameter( charindex );
CHAR_sendCToArroundCharacter( CHAR_getWorkInt( charindex , CHAR_WORKOBJINDEX ));
}
#endif
void saacproto_ACShowMemberList_recv(int fd, char *result, int index, int fmmemnum,
int fmacceptflag, int fmjoinnum, char *data)
{
int ret;
// fmmemnum -1:无此索引值, -2:无更新 else:表示此家族人数
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
ACShowMemberList(ret, index, fmmemnum, fmacceptflag, fmjoinnum, data);
}
void saacproto_ACFMDetail_recv(int fd, char *result, char *data, int charfdid)
{
int ret;
int clifd = getfdFromFdid(charfdid);
if (CONNECT_checkfd(clifd) == FALSE) return;
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
ACFMDetail(ret, data, clifd );
}
void saacproto_ACMemberJoinFM_recv(int fd, char *result, char *data, int charfdid)
{
}
void saacproto_ACMemberLeaveFM_recv(int fd, char *result, char *data, int charfdid)
{
}
#ifdef _PERSONAL_FAME // Arminius: 家族个人声望
void saacproto_ACFMCharLogin_recv(int fd, char *result, int index, int floor,
int fmdp, int joinflag, int fmsetupflag, int flag, int charindex,
int charfame, int charfdid
#ifdef _NEW_MANOR_LAW
,int momentum
#endif
)
#else
void saacproto_ACFMCharLogin_recv(int fd, char *result, int index, int floor,
int fmdp, int joinflag, int fmsetupflag, int flag, int charindex,
int charfdid)
#endif
{
int ret;
int clifd = getfdFromFdid(charfdid);
if (CONNECT_checkfd(clifd) == FALSE) return;
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
// print("Login fd:%d result:%s index:%d floor:%d fmdp:%d joinflag:%d setup:%d charfdid:%d\n",
// fd, result, index, floor, fmdp, joinflag, fmsetupflag, charfdid);
#ifdef _PERSONAL_FAME // Arminius: 家族个人声望
// print("Login charfame:%d\n", charfame);
ACFMCharLogin(clifd, ret, index, floor, fmdp, joinflag, fmsetupflag,
flag, charindex, charfame
#ifdef _NEW_MANOR_LAW
,momentum
#endif
);
#else
ACFMCharLogin(clifd, ret, index, floor, fmdp, joinflag, fmsetupflag,
flag, charindex);
#endif
}
void saacproto_ACFMCharLogout_recv(int fd, char *result, int charfdid)
{
}
void saacproto_ACFMReadMemo_recv(int fd, char *result, int index, int num,
int dataindex, char *data)
{
int ret;
// index(家族 WORK 的索引),num(资料笔数,最大35笔)
// dataindex(最新的资料数),data(资料)。
// 注:num -1:无此索引值, -2:无更新 else:表示此家族人数
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
ACShowFMMemo(ret, index, num, dataindex, data);
}
void saacproto_ACFMWriteMemo_recv(int fd, char *result, int index)
{
}
void saacproto_ACFMPointList_recv(int fd, char *result, char *data)
{
int ret;
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
ACShowPointList(ret, data);
}
void saacproto_ACSetFMPoint_recv(int fd, char *result, int r, int charfdid)
{
int ret;
int clifd = getfdFromFdid(charfdid);
if( CONNECT_checkfd(clifd) == FALSE )return;
if (strcmp(result, SUCCESSFUL) == 0){
ret = 1;
}else{
ret = 0;
}
ACSetFMPoint(ret, r, clifd);
}
void saacproto_ACFixFMPoint_recv(int fd, char *result, int r)
{
}
void saacproto_ACFMAnnounce_recv(int fd, char *result, char *fmname,
int fmindex, int index, int kindflag, char *data, int color)
{
int ret;
if (strcmp(result, SUCCESSFUL) == 0){
ret = 1;
}else{
ret = 0;
}
ACFMAnnounce(ret, fmname, fmindex, index, kindflag, data, color);
}
#ifdef _NEW_MANOR_LAW
extern void SortManorSchedule();
#endif
void saacproto_ACShowTopFMList_recv(int fd, char *result, int kindflag, int num, char *data)
{
int ret;
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
ACShowDpTop(ret, num, data, kindflag);
#ifdef _NEW_MANOR_LAW
SortManorSchedule();
#endif
}
#ifdef _FAMILYBANKSTONELOG
void saacproto_ACgetFMBankgold_recv(int fd, int charfdid,int r)
{
int clifd=getfdFromFdid(charfdid);
int charaindex = CONNECT_getCharaindex( clifd);
if( CONNECT_checkfd(clifd) == FALSE) return;
CHAR_setInt(charaindex,CHAR_FMBANKGOLD,r);
}
#endif
#ifdef _NEW_MANOR_LAW
extern struct FMS_DPTOP fmdptop;
#endif
void saacproto_ACFixFMData_recv(int fd, char *result, int kindflag, char *data1,
char *data2, int charfdid)
{
int ret;
int intdata;
int clifd = getfdFromFdid(charfdid);
int charaindex = CONNECT_getCharaindex( clifd );
if( CONNECT_checkfd(clifd) == FALSE )return;
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;
if( !CHAR_CHECKINDEX(charaindex) ) return;
if( kindflag == FM_FIX_FMRULE ){
CHAR_talkToCli( charaindex , -1, "家族主旨修改OK!", CHAR_COLORWHITE);
}else if( kindflag == FM_FIX_FMGOLD ) {
intdata = atoi( data1 );
if( ret == 0 ) {
if( atoi(data1) > 0 ) {
CHAR_setInt( charaindex, CHAR_GOLD, CHAR_getInt( charaindex, CHAR_GOLD ) +atoi(data1) );
}
CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_GOLD);
return;
}else {
if( atoi(data1) < 0 ) {
CHAR_setInt( charaindex, CHAR_GOLD, CHAR_getInt( charaindex, CHAR_GOLD ) -atoi(data1) );
CHAR_send_P_StatusString( charaindex , CHAR_P_STRING_GOLD);
}
#ifdef _FAMILYBANKSTONELOG
CHAR_setInt(charaindex,CHAR_FMBANKGOLD,CHAR_getInt(charaindex,CHAR_FMBANKGOLD)+intdata);
LogFamilyBankStone(
CHAR_getChar( charaindex, CHAR_NAME ),
CHAR_getChar( charaindex, CHAR_CDKEY ),
intdata,
CHAR_getInt( charaindex, CHAR_GOLD ),
(intdata>0)?"FMBank(存款)(家族银行)":"FMBank(取款)(家族银行)",
CHAR_getInt( charaindex,CHAR_FLOOR),
CHAR_getInt( charaindex,CHAR_X ),
CHAR_getInt( charaindex,CHAR_Y ),
CHAR_getInt( charaindex,CHAR_FMBANKGOLD)
);
#else
LogStone(
atoi(data2),
CHAR_getChar( charaindex, CHAR_NAME ),
CHAR_getChar( charaindex, CHAR_CDKEY ),
-intdata,
CHAR_getInt( charaindex, CHAR_GOLD ),
"FMBank(家族银行)",
CHAR_getInt( charaindex,CHAR_FLOOR),
CHAR_getInt( charaindex,CHAR_X ),
CHAR_getInt( charaindex,CHAR_Y )
);
#endif
}
}else if( kindflag == FM_FIX_FMLEADERCHANGE ){
ACFMJob( clifd, ret, data1, data2 );
}
// CoolFish: 2001/10/03
else if (kindflag == FM_FIX_FMADV || kindflag == FM_FIX_FMFEED
|| kindflag == FM_FIX_FMSYNTHESIZE || kindflag == FM_FIX_FMDEALFOOD)
{
char tmpbuf[1024], flag[128];
#ifdef _NEW_MANOR_LAW
int i;
#endif
if (kindflag == FM_FIX_FMADV) strcpy(flag, "ADV");
else if (kindflag == FM_FIX_FMFEED) strcpy(flag, "FEED");
else if (kindflag == FM_FIX_FMSYNTHESIZE) strcpy(flag, "SYN");
else if (kindflag == FM_FIX_FMDEALFOOD) strcpy(flag, "FOOD");
sprintf(tmpbuf, "%s::%d %s %s", flag,
CHAR_getInt(charaindex, CHAR_FMINDEX),
CHAR_getChar(charaindex, CHAR_FMNAME), data1);
// print("ACFixFMData tmpbuf:%s\n", tmpbuf);
LogFMPOP(tmpbuf);
#ifdef _NEW_MANOR_LAW
for(i=0;i<FAMILY_MAXNUM;i++){
// 家族索引
if(fmdptop.fmtopid[i] == CHAR_getWorkInt(charaindex,CHAR_WORKFMINDEXI)) break;
}
if(i < FAMILY_MAXNUM){
sprintf(tmpbuf, "MOMENTUM::%d %s %d",CHAR_getInt(charaindex,CHAR_FMINDEX),
CHAR_getChar(charaindex,CHAR_FMNAME),fmdptop.fmMomentum[i]);
LogFMPOP(tmpbuf);
}
#endif
}
}
void saacproto_ACFixFMPK_recv(int fd, char *result, int data, int winindex,
int loseindex)
{
int ret;
if (strcmp(result, SUCCESSFUL) == 0) ret = 1;
else ret = 0;