-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dhewm3-no-cdkey.patch
943 lines (905 loc) · 30.6 KB
/
dhewm3-no-cdkey.patch
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
diff -Naur dhewm3-1.5.0.old/neo/framework/async/AsyncClient.cpp dhewm3-1.5.0/neo/framework/async/AsyncClient.cpp
--- dhewm3-1.5.0.old/neo/framework/async/AsyncClient.cpp 2019-01-06 16:58:20.380096648 +0100
+++ dhewm3-1.5.0/neo/framework/async/AsyncClient.cpp 2019-01-06 16:58:38.595434937 +0100
@@ -1262,93 +1262,6 @@
/*
==================
-idAsyncClient::ProcessAuthKeyMessage
-==================
-*/
-void idAsyncClient::ProcessAuthKeyMessage( const netadr_t from, const idBitMsg &msg ) {
- authKeyMsg_t authMsg;
- char read_string[ MAX_STRING_CHARS ];
- const char *retkey;
- authBadKeyStatus_t authBadStatus;
- int key_index;
- bool valid[ 2 ];
- idStr auth_msg;
-
- if ( clientState != CS_CONNECTING && !session->WaitingForGameAuth() ) {
- common->Printf( "clientState != CS_CONNECTING, not waiting for game auth, authKey ignored\n" );
- return;
- }
-
- authMsg = (authKeyMsg_t)msg.ReadByte();
- if ( authMsg == AUTHKEY_BADKEY ) {
- valid[ 0 ] = valid[ 1 ] = true;
- key_index = 0;
- authBadStatus = (authBadKeyStatus_t)msg.ReadByte();
- switch ( authBadStatus ) {
- case AUTHKEY_BAD_INVALID:
- valid[ 0 ] = ( msg.ReadByte() == 1 );
- valid[ 1 ] = ( msg.ReadByte() == 1 );
- idAsyncNetwork::BuildInvalidKeyMsg( auth_msg, valid );
- break;
- case AUTHKEY_BAD_BANNED:
- key_index = msg.ReadByte();
- auth_msg = common->GetLanguageDict()->GetString( va( "#str_0719%1d", 6 + key_index ) );
- auth_msg += "\n";
- auth_msg += common->GetLanguageDict()->GetString( "#str_04304" );
- valid[ key_index ] = false;
- break;
- case AUTHKEY_BAD_INUSE:
- key_index = msg.ReadByte();
- auth_msg = common->GetLanguageDict()->GetString( va( "#str_0719%1d", 8 + key_index ) );
- auth_msg += "\n";
- auth_msg += common->GetLanguageDict()->GetString( "#str_04304" );
- valid[ key_index ] = false;
- break;
- case AUTHKEY_BAD_MSG:
- // a general message explaining why this key is denied
- // no specific use for this atm. let's not clear the keys either
- msg.ReadString( read_string, MAX_STRING_CHARS );
- auth_msg = read_string;
- break;
- }
- common->DPrintf( "auth deny: %s\n", auth_msg.c_str() );
-
- // keys to be cleared. applies to both net connect and game auth
- session->ClearCDKey( valid );
-
- // get rid of the bad key - at least that's gonna annoy people who stole a fake key
- if ( clientState == CS_CONNECTING ) {
- while ( 1 ) {
- // here we use the auth status message
- retkey = session->MessageBox( MSG_CDKEY, auth_msg, common->GetLanguageDict()->GetString( "#str_04325" ), true );
- if ( retkey ) {
- if ( session->CheckKey( retkey, true, valid ) ) {
- cmdSystem->BufferCommandText( CMD_EXEC_NOW, "reconnect" );
- } else {
- // build a more precise message about the offline check failure
- idAsyncNetwork::BuildInvalidKeyMsg( auth_msg, valid );
- session->MessageBox( MSG_OK, auth_msg.c_str(), common->GetLanguageDict()->GetString( "#str_04327" ), true );
- continue;
- }
- } else {
- cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect" );
- }
- break;
- }
- } else {
- // forward the auth status information to the session code
- session->CDKeysAuthReply( false, auth_msg );
- }
- } else {
- msg.ReadString( read_string, MAX_STRING_CHARS );
- cvarSystem->SetCVarString( "com_guid", read_string );
- common->Printf( "guid set to %s\n", read_string );
- session->CDKeysAuthReply( true, NULL );
- }
-}
-
-/*
-==================
idAsyncClient::ProcessVersionMessage
==================
*/
@@ -1526,11 +1439,6 @@
return;
}
- if ( idStr::Icmp( string, "authKey" ) == 0 ) {
- ProcessAuthKeyMessage( from, msg );
- return;
- }
-
if ( idStr::Icmp( string, "newVersion" ) == 0 ) {
ProcessVersionMessage( from, msg );
return;
@@ -1677,13 +1585,7 @@
msg.WriteNetadr( serverAddress );
// if we don't have a com_guid, this will request a direct reply from auth with it
msg.WriteByte( cvarSystem->GetCVarString( "com_guid" )[0] ? 1 : 0 );
- // send the main key, and flag an extra byte to add XP key
- msg.WriteString( session->GetCDKey( false ) );
- const char *xpkey = session->GetCDKey( true );
- msg.WriteByte( xpkey ? 1 : 0 );
- if ( xpkey ) {
- msg.WriteString( xpkey );
- }
+
clientPort.SendPacket( idAsyncNetwork::GetMasterAddress(), msg.GetData(), msg.GetSize() );
}
#else
@@ -2133,28 +2035,6 @@
}
/*
-===============
-idAsyncClient::SendAuthCheck
-===============
-*/
-bool idAsyncClient::SendAuthCheck( const char *cdkey, const char *xpkey ) {
- idBitMsg msg;
- byte msgBuf[MAX_MESSAGE_SIZE];
-
- msg.Init( msgBuf, sizeof( msgBuf ) );
- msg.WriteShort( CONNECTIONLESS_MESSAGE_ID );
- msg.WriteString( "gameAuth" );
- msg.WriteInt( ASYNC_PROTOCOL_VERSION );
- msg.WriteByte( cdkey ? 1 : 0 );
- msg.WriteString( cdkey ? cdkey : "" );
- msg.WriteByte( xpkey ? 1 : 0 );
- msg.WriteString( xpkey ? xpkey : "" );
- InitPort();
- clientPort.SendPacket( idAsyncNetwork::GetMasterAddress(), msg.GetData(), msg.GetSize() );
- return true;
-}
-
-/*
===============
idAsyncClient::CheckTimeout
===============
diff -Naur dhewm3-1.5.0.old/neo/framework/async/AsyncClient.h dhewm3-1.5.0/neo/framework/async/AsyncClient.h
--- dhewm3-1.5.0.old/neo/framework/async/AsyncClient.h 2019-01-06 16:58:20.379096629 +0100
+++ dhewm3-1.5.0/neo/framework/async/AsyncClient.h 2019-01-06 16:58:38.596434956 +0100
@@ -114,9 +114,6 @@
void SendReliableGameMessage( const idBitMsg &msg );
void SendVersionCheck( bool fromMenu = false );
- // pass NULL for the keys you don't care to auth for
- // returns false if internet link doesn't appear to be available
- bool SendAuthCheck( const char *cdkey, const char *xpkey );
void PacifierUpdate( void );
@@ -201,7 +198,6 @@
void ProcessInfoResponseMessage( const netadr_t from, const idBitMsg &msg );
void ProcessPrintMessage( const netadr_t from, const idBitMsg &msg );
void ProcessServersListMessage( const netadr_t from, const idBitMsg &msg );
- void ProcessAuthKeyMessage( const netadr_t from, const idBitMsg &msg );
void ProcessVersionMessage( const netadr_t from, const idBitMsg &msg );
void ConnectionlessMessage( const netadr_t from, const idBitMsg &msg );
void ProcessMessage( const netadr_t from, idBitMsg &msg );
diff -Naur dhewm3-1.5.0.old/neo/framework/BuildDefines.h dhewm3-1.5.0/neo/framework/BuildDefines.h
--- dhewm3-1.5.0.old/neo/framework/BuildDefines.h 2019-01-06 16:58:20.378096611 +0100
+++ dhewm3-1.5.0/neo/framework/BuildDefines.h 2019-01-06 16:58:38.597434974 +0100
@@ -75,24 +75,6 @@
#define ID_ALLOW_TOOLS
#endif
-#define ID_ENFORCE_KEY 0
-
-#ifndef ID_ENFORCE_KEY
-# if !defined( ID_DEDICATED )
-# define ID_ENFORCE_KEY 1
-# else
-# define ID_ENFORCE_KEY 0
-# endif
-#endif
-
-#ifndef ID_ENFORCE_KEY_CLIENT
-# if ID_ENFORCE_KEY
-# define ID_ENFORCE_KEY_CLIENT 1
-# else
-# define ID_ENFORCE_KEY_CLIENT 0
-# endif
-#endif
-
// async network
/*
diff -Naur dhewm3-1.5.0.old/neo/framework/Common.cpp dhewm3-1.5.0/neo/framework/Common.cpp
--- dhewm3-1.5.0.old/neo/framework/Common.cpp 2019-01-06 16:58:20.378096611 +0100
+++ dhewm3-1.5.0/neo/framework/Common.cpp 2019-01-06 16:58:38.598434993 +0100
@@ -1068,7 +1068,6 @@
com_developer.SetBool( false );
WriteConfigToFile( CONFIG_FILE );
- session->WriteCDKey( );
// restore the developer cvar
com_developer.SetBool( developer );
@@ -2939,11 +2938,7 @@
InitGame();
// don't add startup commands if no CD key is present
-#if ID_ENFORCE_KEY
- if ( !session->CDKeysAreValid( false ) || !AddStartupCommands() ) {
-#else
if ( !AddStartupCommands() ) {
-#endif
// if the user didn't give any commands, run default action
session->StartMenu( true );
}
diff -Naur dhewm3-1.5.0.old/neo/framework/FileSystem.cpp dhewm3-1.5.0/neo/framework/FileSystem.cpp
--- dhewm3-1.5.0.old/neo/framework/FileSystem.cpp 2019-01-06 16:58:20.380096648 +0100
+++ dhewm3-1.5.0/neo/framework/FileSystem.cpp 2019-01-06 16:58:38.600435030 +0100
@@ -2969,12 +2969,6 @@
return NULL;
}
- // make sure the doomkey file is only readable by game at initialization
- // any other time the key should only be accessed in memory using the provided functions
- if( common->IsInitialized() && ( idStr::Icmp( relativePath, CDKEY_FILE ) == 0 || idStr::Icmp( relativePath, XPKEY_FILE ) == 0 ) ) {
- return NULL;
- }
-
//
// search through the path, one element at a time
//
diff -Naur dhewm3-1.5.0.old/neo/framework/Licensee.h dhewm3-1.5.0/neo/framework/Licensee.h
--- dhewm3-1.5.0.old/neo/framework/Licensee.h 2019-01-06 16:58:20.380096648 +0100
+++ dhewm3-1.5.0/neo/framework/Licensee.h 2019-01-06 16:58:38.600435030 +0100
@@ -101,12 +101,4 @@
#define LINUX_DEFAULT_PATH "/usr/local/games/doom3"
#endif
-// CD Key file info
-// goes into BASE_GAMEDIR whatever the fs_game is set to
-// two distinct files for easier win32 installer job
-#define CDKEY_FILE "doomkey"
-#define XPKEY_FILE "xpkey"
-#define CDKEY_TEXT "\n// Do not give this file to ANYONE.\n" \
- "// id Software or Zenimax will NEVER ask you to send this file to them.\n"
-
#define CONFIG_SPEC "config.spec"
diff -Naur dhewm3-1.5.0.old/neo/framework/Session.cpp dhewm3-1.5.0/neo/framework/Session.cpp
--- dhewm3-1.5.0.old/neo/framework/Session.cpp 2019-01-06 16:58:20.377096593 +0100
+++ dhewm3-1.5.0/neo/framework/Session.cpp 2019-01-06 16:58:38.601435048 +0100
@@ -218,86 +218,6 @@
}
/*
-===============
-idSessionLocal::MaybeWaitOnCDKey
-===============
-*/
-bool idSessionLocal::MaybeWaitOnCDKey( void ) {
- if ( authEmitTimeout > 0 ) {
- authWaitBox = true;
- sessLocal.MessageBox( MSG_WAIT, common->GetLanguageDict()->GetString( "#str_07191" ), NULL, true, NULL, NULL, true );
- return true;
- }
- return false;
-}
-
-/*
-===================
-Session_PromptKey_f
-===================
-*/
-static void Session_PromptKey_f( const idCmdArgs &args ) {
- const char *retkey;
- bool valid[ 2 ];
- static bool recursed = false;
-
- if ( recursed ) {
- common->Warning( "promptKey recursed - aborted" );
- return;
- }
- recursed = true;
-
- do {
- // in case we're already waiting for an auth to come back to us ( may happen exceptionally )
- if ( sessLocal.MaybeWaitOnCDKey() ) {
- if ( sessLocal.CDKeysAreValid( true ) ) {
- recursed = false;
- return;
- }
- }
- // the auth server may have replied and set an error message, otherwise use a default
- const char *prompt_msg = sessLocal.GetAuthMsg();
- if ( prompt_msg[ 0 ] == '\0' ) {
- prompt_msg = common->GetLanguageDict()->GetString( "#str_04308" );
- }
- retkey = sessLocal.MessageBox( MSG_CDKEY, prompt_msg, common->GetLanguageDict()->GetString( "#str_04305" ), true, NULL, NULL, true );
- if ( retkey ) {
- if ( sessLocal.CheckKey( retkey, false, valid ) ) {
- // if all went right, then we may have sent an auth request to the master ( unless the prompt is used during a net connect )
- bool canExit = true;
- if ( sessLocal.MaybeWaitOnCDKey() ) {
- // wait on auth reply, and got denied, prompt again
- if ( !sessLocal.CDKeysAreValid( true ) ) {
- // server says key is invalid - MaybeWaitOnCDKey was interrupted by a CDKeysAuthReply call, which has set the right error message
- // the invalid keys have also been cleared in the process
- sessLocal.MessageBox( MSG_OK, sessLocal.GetAuthMsg(), common->GetLanguageDict()->GetString( "#str_04310" ), true, NULL, NULL, true );
- canExit = false;
- }
- }
- if ( canExit ) {
- // make sure that's saved on file
- sessLocal.WriteCDKey();
- sessLocal.MessageBox( MSG_OK, common->GetLanguageDict()->GetString( "#str_04307" ), common->GetLanguageDict()->GetString( "#str_04305" ), true, NULL, NULL, true );
- break;
- }
- } else {
- // offline check sees key invalid
- // build a message about keys being wrong. do not attempt to change the current key state though
- // ( the keys may be valid, but user would have clicked on the dialog anyway, that kind of thing )
- idStr msg;
- idAsyncNetwork::BuildInvalidKeyMsg( msg, valid );
- sessLocal.MessageBox( MSG_OK, msg, common->GetLanguageDict()->GetString( "#str_04310" ), true, NULL, NULL, true );
- }
- } else if ( args.Argc() == 2 && idStr::Icmp( args.Argv(1), "force" ) == 0 ) {
- // cancelled in force mode
- cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "quit\n" );
- cmdSystem->ExecuteCommandBuffer();
- }
- } while ( retkey );
- recursed = false;
-}
-
-/*
===============================================================================
SESSION LOCAL
@@ -1159,23 +1079,6 @@
common->Printf( "Dedicated servers cannot start singleplayer games.\n" );
return;
#else
-#if ID_ENFORCE_KEY
- // strict check. don't let a game start without a definitive answer
- if ( !CDKeysAreValid( true ) ) {
- bool prompt = true;
- if ( MaybeWaitOnCDKey() ) {
- // check again, maybe we just needed more time
- if ( CDKeysAreValid( true ) ) {
- // can continue directly
- prompt = false;
- }
- }
- if ( prompt ) {
- cmdSystem->BufferCommandText( CMD_EXEC_NOW, "promptKey force" );
- cmdSystem->ExecuteCommandBuffer();
- }
- }
-#endif
if ( idAsyncNetwork::server.IsActive() ) {
common->Printf("Server running, use si_map / serverMapRestart\n");
return;
@@ -2609,16 +2512,9 @@
StopBox();
authWaitBox = false;
}
- if ( cdkey_state == CDKEY_CHECKING ) {
- cdkey_state = CDKEY_OK;
- }
- if ( xpkey_state == CDKEY_CHECKING ) {
- xpkey_state = CDKEY_OK;
- }
// maintain this empty as it's set by auth denials
authMsg.Empty();
authEmitTimeout = 0;
- SetCDKeyGuiVars();
}
}
@@ -2877,8 +2773,6 @@
cmdSystem->AddCommand( "rescanSI", Session_RescanSI_f, CMD_FL_SYSTEM, "internal - rescan serverinfo cvars and tell game" );
- cmdSystem->AddCommand( "promptKey", Session_PromptKey_f, CMD_FL_SYSTEM, "prompt and sets the CD Key" );
-
cmdSystem->AddCommand( "hitch", Session_Hitch_f, CMD_FL_SYSTEM|CMD_FL_CHEAT, "hitches the game" );
// the same idRenderWorld will be used for all games
@@ -2907,8 +2801,6 @@
guiActive = NULL;
guiHandle = NULL;
-
- ReadCDKey();
}
/*
@@ -2958,335 +2850,6 @@
}
/*
-=================
-idSessionLocal::ReadCDKey
-=================
-*/
-void idSessionLocal::ReadCDKey( void ) {
- idStr filename;
- idFile *f;
- char buffer[32];
-
- cdkey_state = CDKEY_UNKNOWN;
-
- filename = CDKEY_FILEPATH;
- f = fileSystem->OpenExplicitFileRead( fileSystem->RelativePathToOSPath( filename, "fs_configpath" ) );
-
- // try the install path, which is where the cd installer and steam put it
- if ( !f )
- f = fileSystem->OpenExplicitFileRead( fileSystem->RelativePathToOSPath( filename, "fs_basepath" ) );
-
- if ( !f ) {
- common->Printf( "Couldn't read %s.\n", filename.c_str() );
- cdkey[ 0 ] = '\0';
- } else {
- memset( buffer, 0, sizeof(buffer) );
- f->Read( buffer, CDKEY_BUF_LEN - 1 );
- fileSystem->CloseFile( f );
- idStr::Copynz( cdkey, buffer, CDKEY_BUF_LEN );
- }
-
- xpkey_state = CDKEY_UNKNOWN;
-
- filename = XPKEY_FILEPATH;
- f = fileSystem->OpenExplicitFileRead( fileSystem->RelativePathToOSPath( filename, "fs_configpath" ) );
-
- // try the install path, which is where the cd installer and steam put it
- if ( !f )
- f = fileSystem->OpenExplicitFileRead( fileSystem->RelativePathToOSPath( filename, "fs_basepath" ) );
-
- if ( !f ) {
- common->Printf( "Couldn't read %s.\n", filename.c_str() );
- xpkey[ 0 ] = '\0';
- } else {
- memset( buffer, 0, sizeof(buffer) );
- f->Read( buffer, CDKEY_BUF_LEN - 1 );
- fileSystem->CloseFile( f );
- idStr::Copynz( xpkey, buffer, CDKEY_BUF_LEN );
- }
-}
-
-/*
-================
-idSessionLocal::WriteCDKey
-================
-*/
-void idSessionLocal::WriteCDKey( void ) {
- idStr filename;
- idFile *f;
- const char *OSPath;
-
- filename = CDKEY_FILEPATH;
- // OpenFileWrite advertises creating directories to the path if needed, but that won't work with a '..' in the path
- // occasionally on windows, but mostly on Linux and OSX, the fs_configpath/base may not exist in full
- OSPath = fileSystem->BuildOSPath( cvarSystem->GetCVarString( "fs_configpath" ), BASE_GAMEDIR, CDKEY_FILE );
- fileSystem->CreateOSPath( OSPath );
- f = fileSystem->OpenFileWrite( filename, "fs_configpath" );
- if ( !f ) {
- common->Printf( "Couldn't write %s.\n", filename.c_str() );
- return;
- }
- f->Printf( "%s%s", cdkey, CDKEY_TEXT );
- fileSystem->CloseFile( f );
-
- filename = XPKEY_FILEPATH;
- f = fileSystem->OpenFileWrite( filename, "fs_configpath" );
- if ( !f ) {
- common->Printf( "Couldn't write %s.\n", filename.c_str() );
- return;
- }
- f->Printf( "%s%s", xpkey, CDKEY_TEXT );
- fileSystem->CloseFile( f );
-}
-
-/*
-===============
-idSessionLocal::ClearKey
-===============
-*/
-void idSessionLocal::ClearCDKey( bool valid[ 2 ] ) {
- if ( !valid[ 0 ] ) {
- memset( cdkey, 0, CDKEY_BUF_LEN );
- cdkey_state = CDKEY_UNKNOWN;
- } else if ( cdkey_state == CDKEY_CHECKING ) {
- // if a key was in checking and not explicitely asked for clearing, put it back to ok
- cdkey_state = CDKEY_OK;
- }
- if ( !valid[ 1 ] ) {
- memset( xpkey, 0, CDKEY_BUF_LEN );
- xpkey_state = CDKEY_UNKNOWN;
- } else if ( xpkey_state == CDKEY_CHECKING ) {
- xpkey_state = CDKEY_OK;
- }
- WriteCDKey( );
-}
-
-/*
-================
-idSessionLocal::GetCDKey
-================
-*/
-const char *idSessionLocal::GetCDKey( bool xp ) {
- if ( !xp ) {
- return cdkey;
- }
- if ( xpkey_state == CDKEY_OK || xpkey_state == CDKEY_CHECKING ) {
- return xpkey;
- }
- return NULL;
-}
-
-// digits to letters table
-#define CDKEY_DIGITS "TWSBJCGD7PA23RLH"
-
-/*
-===============
-idSessionLocal::EmitGameAuth
-we toggled some key state to CDKEY_CHECKING. send a standalone auth packet to validate
-===============
-*/
-void idSessionLocal::EmitGameAuth( void ) {
- // make sure the auth reply is empty, we use it to indicate an auth reply
- authMsg.Empty();
- if ( idAsyncNetwork::client.SendAuthCheck( cdkey_state == CDKEY_CHECKING ? cdkey : NULL, xpkey_state == CDKEY_CHECKING ? xpkey : NULL ) ) {
- authEmitTimeout = Sys_Milliseconds() + CDKEY_AUTH_TIMEOUT;
- common->DPrintf( "authing with the master..\n" );
- } else {
- // net is not available
- common->DPrintf( "sendAuthCheck failed\n" );
- if ( cdkey_state == CDKEY_CHECKING ) {
- cdkey_state = CDKEY_OK;
- }
- if ( xpkey_state == CDKEY_CHECKING ) {
- xpkey_state = CDKEY_OK;
- }
- }
-}
-
-/*
-================
-idSessionLocal::CheckKey
-the function will only modify keys to _OK or _CHECKING if the offline checks are passed
-if the function returns false, the offline checks failed, and offline_valid holds which keys are bad
-================
-*/
-bool idSessionLocal::CheckKey( const char *key, bool netConnect, bool offline_valid[ 2 ] ) {
- char lkey[ 2 ][ CDKEY_BUF_LEN ];
- char l_chk[ 2 ][ 3 ];
- char s_chk[ 3 ];
- int imax,i_key;
- unsigned int checksum, chk8;
- bool edited_key[ 2 ];
-
- // make sure have a right input string
- assert( strlen( key ) == ( CDKEY_BUF_LEN - 1 ) * 2 + 4 + 3 + 4 );
-
- edited_key[ 0 ] = ( key[0] == '1' );
- idStr::Copynz( lkey[0], key + 2, CDKEY_BUF_LEN );
- idStr::ToUpper( lkey[0] );
- idStr::Copynz( l_chk[0], key + CDKEY_BUF_LEN + 2, 3 );
- idStr::ToUpper( l_chk[0] );
- edited_key[ 1 ] = ( key[ CDKEY_BUF_LEN + 2 + 3 ] == '1' );
- idStr::Copynz( lkey[1], key + CDKEY_BUF_LEN + 7, CDKEY_BUF_LEN );
- idStr::ToUpper( lkey[1] );
- idStr::Copynz( l_chk[1], key + CDKEY_BUF_LEN * 2 + 7, 3 );
- idStr::ToUpper( l_chk[1] );
-
- if ( fileSystem->HasD3XP() ) {
- imax = 2;
- } else {
- imax = 1;
- }
- offline_valid[ 0 ] = offline_valid[ 1 ] = true;
- for( i_key = 0; i_key < imax; i_key++ ) {
- // check that the characters are from the valid set
- int i;
- for ( i = 0; i < CDKEY_BUF_LEN - 1; i++ ) {
- if ( !strchr( CDKEY_DIGITS, lkey[i_key][i] ) ) {
- offline_valid[ i_key ] = false;
- continue;
- }
- }
-
- if ( edited_key[ i_key ] ) {
- // verify the checksum for edited keys only
- checksum = CRC32_BlockChecksum( lkey[i_key], CDKEY_BUF_LEN - 1 );
- chk8 = ( checksum & 0xff ) ^ ( ( ( checksum & 0xff00 ) >> 8 ) ^ ( ( ( checksum & 0xff0000 ) >> 16 ) ^ ( ( checksum & 0xff000000 ) >> 24 ) ) );
- idStr::snPrintf( s_chk, 3, "%02X", chk8 );
- if ( idStr::Icmp( l_chk[i_key], s_chk ) != 0 ) {
- offline_valid[ i_key ] = false;
- continue;
- }
- }
- }
-
- if ( !offline_valid[ 0 ] || !offline_valid[1] ) {
- return false;
- }
-
- // offline checks passed, we'll return true and optionally emit key check requests
- // the function should only modify the key states if the offline checks passed successfully
-
- // set the keys, don't send a game auth if we are net connecting
- idStr::Copynz( cdkey, lkey[0], CDKEY_BUF_LEN );
- netConnect ? cdkey_state = CDKEY_OK : cdkey_state = CDKEY_CHECKING;
- if ( fileSystem->HasD3XP() ) {
- idStr::Copynz( xpkey, lkey[1], CDKEY_BUF_LEN );
- netConnect ? xpkey_state = CDKEY_OK : xpkey_state = CDKEY_CHECKING;
- } else {
- xpkey_state = CDKEY_NA;
- }
- if ( !netConnect ) {
- EmitGameAuth();
- }
- SetCDKeyGuiVars();
-
- return true;
-}
-
-/*
-===============
-idSessionLocal::CDKeysAreValid
-checking that the key is present and uses only valid characters
-if d3xp is installed, check for a valid xpkey as well
-emit an auth packet to the master if possible and needed
-===============
-*/
-bool idSessionLocal::CDKeysAreValid( bool strict ) {
- int i;
- bool emitAuth = false;
-
- if ( cdkey_state == CDKEY_UNKNOWN ) {
- if ( strlen( cdkey ) != CDKEY_BUF_LEN - 1 ) {
- cdkey_state = CDKEY_INVALID;
- } else {
- for ( i = 0; i < CDKEY_BUF_LEN-1; i++ ) {
- if ( !strchr( CDKEY_DIGITS, cdkey[i] ) ) {
- cdkey_state = CDKEY_INVALID;
- break;
- }
- }
- }
- if ( cdkey_state == CDKEY_UNKNOWN ) {
- cdkey_state = CDKEY_CHECKING;
- emitAuth = true;
- }
- }
- if ( xpkey_state == CDKEY_UNKNOWN ) {
- if ( fileSystem->HasD3XP() ) {
- if ( strlen( xpkey ) != CDKEY_BUF_LEN -1 ) {
- xpkey_state = CDKEY_INVALID;
- } else {
- for ( i = 0; i < CDKEY_BUF_LEN-1; i++ ) {
- if ( !strchr( CDKEY_DIGITS, xpkey[i] ) ) {
- xpkey_state = CDKEY_INVALID;
- }
- }
- }
- if ( xpkey_state == CDKEY_UNKNOWN ) {
- xpkey_state = CDKEY_CHECKING;
- emitAuth = true;
- }
- } else {
- xpkey_state = CDKEY_NA;
- }
- }
- if ( emitAuth ) {
- EmitGameAuth();
- }
- // make sure to keep the mainmenu gui up to date in case we made state changes
- SetCDKeyGuiVars();
- if ( strict ) {
- return cdkey_state == CDKEY_OK && ( xpkey_state == CDKEY_OK || xpkey_state == CDKEY_NA );
- } else {
- return ( cdkey_state == CDKEY_OK || cdkey_state == CDKEY_CHECKING ) && ( xpkey_state == CDKEY_OK || xpkey_state == CDKEY_CHECKING || xpkey_state == CDKEY_NA );
- }
-}
-
-/*
-===============
-idSessionLocal::WaitingForGameAuth
-===============
-*/
-bool idSessionLocal::WaitingForGameAuth( void ) {
- return authEmitTimeout != 0;
-}
-
-/*
-===============
-idSessionLocal::CDKeysAuthReply
-===============
-*/
-void idSessionLocal::CDKeysAuthReply( bool valid, const char *auth_msg ) {
- //assert( authEmitTimeout > 0 );
- if ( authWaitBox ) {
- // close the wait box
- StopBox();
- authWaitBox = false;
- }
- if ( !valid ) {
- common->DPrintf( "auth key is invalid\n" );
- authMsg = auth_msg;
- if ( cdkey_state == CDKEY_CHECKING ) {
- cdkey_state = CDKEY_INVALID;
- }
- if ( xpkey_state == CDKEY_CHECKING ) {
- xpkey_state = CDKEY_INVALID;
- }
- } else {
- common->DPrintf( "client is authed in\n" );
- if ( cdkey_state == CDKEY_CHECKING ) {
- cdkey_state = CDKEY_OK;
- }
- if ( xpkey_state == CDKEY_CHECKING ) {
- xpkey_state = CDKEY_OK;
- }
- }
- authEmitTimeout = 0;
- SetCDKeyGuiVars();
-}
-
-/*
===============
idSessionLocal::GetCurrentMapName
===============
diff -Naur dhewm3-1.5.0.old/neo/framework/Session.h dhewm3-1.5.0/neo/framework/Session.h
--- dhewm3-1.5.0.old/neo/framework/Session.h 2019-01-06 16:58:20.378096611 +0100
+++ dhewm3-1.5.0/neo/framework/Session.h 2019-01-06 16:58:38.601435048 +0100
@@ -60,7 +60,6 @@
MSG_OKCANCEL,
MSG_YESNO,
MSG_PROMPT,
- MSG_CDKEY,
MSG_INFO,
MSG_WAIT
} msgBoxType_t;
@@ -113,7 +112,6 @@
// fires up the optional GUI event, also returns them if you set wait to true
// if MSG_PROMPT and wait, returns the prompt string or NULL if aborted
- // if MSG_CDKEY and want, returns the cd key or NULL if aborted
// network tells wether one should still run the network loop in a wait dialog
virtual const char *MessageBox( msgBoxType_t type, const char *message, const char *title = NULL, bool wait = false, const char *fire_yes = NULL, const char *fire_no = NULL, bool network = false ) = 0;
virtual void StopBox( void ) = 0;
@@ -126,32 +124,6 @@
// doesn't advance and get things out of sync
virtual void TimeHitch( int msec ) = 0;
- // read and write the cd key data to files
- // doesn't perform any validity checks
- virtual void ReadCDKey( void ) = 0;
- virtual void WriteCDKey( void ) = 0;
-
- // returns NULL for if xp is true and xp key is not valid or not present
- virtual const char *GetCDKey( bool xp ) = 0;
-
- // check keys for validity when typed in by the user ( with checksum verification )
- // store the new set of keys if they are found valid
- virtual bool CheckKey( const char *key, bool netConnect, bool offline_valid[ 2 ] ) = 0;
-
- // verify the current set of keys for validity
- // strict -> keys in state CDKEY_CHECKING state are not ok
- virtual bool CDKeysAreValid( bool strict ) = 0;
- // wipe the key on file if the network check finds it invalid
- virtual void ClearCDKey( bool valid[ 2 ] ) = 0;
-
- // configure gui variables for mainmenu.gui and cd key state
- virtual void SetCDKeyGuiVars( void ) = 0;
-
- virtual bool WaitingForGameAuth( void ) = 0;
-
- // got reply from master about the keys. if !valid, auth_msg given
- virtual void CDKeysAuthReply( bool valid, const char *auth_msg ) = 0;
-
virtual const char *GetCurrentMapName( void ) = 0;
virtual int GetSaveGameVersion( void ) = 0;
diff -Naur dhewm3-1.5.0.old/neo/framework/Session_local.h dhewm3-1.5.0/neo/framework/Session_local.h
--- dhewm3-1.5.0.old/neo/framework/Session_local.h 2019-01-06 16:58:20.379096629 +0100
+++ dhewm3-1.5.0/neo/framework/Session_local.h 2019-01-06 16:58:38.601435048 +0100
@@ -124,16 +124,6 @@
virtual void TimeHitch( int msec );
- virtual void ReadCDKey( void );
- virtual void WriteCDKey( void );
- virtual const char *GetCDKey( bool xp );
- virtual bool CheckKey( const char *key, bool netConnect, bool offline_valid[ 2 ] );
- virtual bool CDKeysAreValid( bool strict );
- virtual void ClearCDKey( bool valid[ 2 ] );
- virtual void SetCDKeyGuiVars( void );
- virtual bool WaitingForGameAuth( void );
- virtual void CDKeysAuthReply( bool valid, const char *auth_msg );
-
virtual int GetSaveGameVersion( void );
virtual const char *GetCurrentMapName();
@@ -312,9 +302,6 @@
void ExecuteMapChange( bool noFadeWipe = false );
void UnloadMap();
- // return true if we actually waiting on an auth reply
- bool MaybeWaitOnCDKey( void );
-
//------------------
// Session_menu.cpp
@@ -347,21 +334,6 @@
bool BoxDialogSanityCheck( void );
void EmitGameAuth( void );
- typedef enum {
- CDKEY_UNKNOWN, // need to perform checks on the key
- CDKEY_INVALID, // that key is wrong
- CDKEY_OK, // valid
- CDKEY_CHECKING, // sent a check request ( gameAuth only )
- CDKEY_NA // does not apply, xp key when xp is not present
- } cdKeyState_t;
-
- static const int CDKEY_BUF_LEN = 17;
- static const int CDKEY_AUTH_TIMEOUT = 5000;
-
- char cdkey[ CDKEY_BUF_LEN ];
- cdKeyState_t cdkey_state;
- char xpkey[ CDKEY_BUF_LEN ];
- cdKeyState_t xpkey_state;
int authEmitTimeout;
bool authWaitBox;
diff -Naur dhewm3-1.5.0.old/neo/framework/Session_menu.cpp dhewm3-1.5.0/neo/framework/Session_menu.cpp
--- dhewm3-1.5.0.old/neo/framework/Session_menu.cpp 2019-01-06 16:58:20.380096648 +0100
+++ dhewm3-1.5.0/neo/framework/Session_menu.cpp 2019-01-06 16:58:38.601435048 +0100
@@ -313,7 +313,6 @@
guiMainMenu->SetStateString( "inGame", "0" );
}
- SetCDKeyGuiVars( );
guiMainMenu->SetStateString( "nightmare", cvarSystem->GetCVarBool( "g_nightmare" ) ? "1" : "0" );
guiMainMenu->SetStateString( "browser_levelshot", "guis/assets/splash/pdtempa" );
@@ -1255,7 +1254,6 @@
}
guiMsg->SetStateString( "visible_entry", "0" );
- guiMsg->SetStateString( "visible_cdkey", "0" );
switch ( type ) {
case MSG_INFO:
guiMsg->SetStateString( "mid", "" );
@@ -1298,32 +1296,6 @@
guiMsg->SetStateString( "visible_entry", "1" );
guiMsg->HandleNamedEvent( "Prompt" );
break;
- case MSG_CDKEY:
- guiMsg->SetStateString( "left", common->GetLanguageDict()->GetString( "#str_04339" ) );
- guiMsg->SetStateString( "right", common->GetLanguageDict()->GetString( "#str_04340" ) );
- guiMsg->SetStateString( "visible_msgbox", "0" );
- guiMsg->SetStateString( "visible_cdkey", "1" );
- guiMsg->SetStateString( "visible_hasxp", fileSystem->HasD3XP() ? "1" : "0" );
- // the current cdkey / xpkey values may have bad/random data in them
- // it's best to avoid printing them completely, unless the key is good
- if ( cdkey_state == CDKEY_OK ) {
- guiMsg->SetStateString( "str_cdkey", cdkey );
- guiMsg->SetStateString( "visible_cdchk", "0" );
- } else {
- guiMsg->SetStateString( "str_cdkey", "" );
- guiMsg->SetStateString( "visible_cdchk", "1" );
- }
- guiMsg->SetStateString( "str_cdchk", "" );
- if ( xpkey_state == CDKEY_OK ) {
- guiMsg->SetStateString( "str_xpkey", xpkey );
- guiMsg->SetStateString( "visible_xpchk", "0" );
- } else {
- guiMsg->SetStateString( "str_xpkey", "" );
- guiMsg->SetStateString( "visible_xpchk", "1" );
- }
- guiMsg->SetStateString( "str_xpchk", "" );
- guiMsg->HandleNamedEvent( "CDKey" );
- break;
case MSG_WAIT:
break;
default:
@@ -1357,20 +1329,6 @@
} else {
return NULL;
}
- } else if ( type == MSG_CDKEY ) {
- if ( msgRetIndex == 0 ) {
- // the visible_ values distinguish looking at a valid key, or editing it
- sprintf( msgFireBack[ 0 ], "%1s;%16s;%2s;%1s;%16s;%2s",
- guiMsg->State().GetString( "visible_cdchk" ),
- guiMsg->State().GetString( "str_cdkey" ),
- guiMsg->State().GetString( "str_cdchk" ),
- guiMsg->State().GetString( "visible_xpchk" ),
- guiMsg->State().GetString( "str_xpkey" ),
- guiMsg->State().GetString( "str_xpchk" ) );
- return msgFireBack[ 0 ].c_str();
- } else {
- return NULL;
- }
} else {
return msgFireBack[ msgRetIndex ].c_str();
}
@@ -1397,7 +1355,6 @@
guiMsg->SetStateString( "visible_waitbox", "0" );
guiMsg->SetStateString( "visible_entry", "0" );
- guiMsg->SetStateString( "visible_cdkey", "0" );
guiMsg->SetStateString( "mid", "Cancel" );
guiMsg->SetStateString( "visible_mid", "1" );
@@ -1625,15 +1582,3 @@
}
}
-/*
-===============
-idSessionLocal::SetCDKeyGuiVars
-===============
-*/
-void idSessionLocal::SetCDKeyGuiVars( void ) {
- if ( !guiMainMenu ) {
- return;
- }
- guiMainMenu->SetStateString( "str_d3key_state", common->GetLanguageDict()->GetString( va( "#str_071%d", 86 + cdkey_state ) ) );
- guiMainMenu->SetStateString( "str_xpkey_state", common->GetLanguageDict()->GetString( va( "#str_071%d", 86 + xpkey_state ) ) );
-}