fgsfdsfgs / ioq3

Nintendo Switch port of ioquake3
https://www.ioquake3.org/
GNU General Public License v2.0
21 stars 4 forks source link

Code mod - built in keygen #14

Open mrdude2478 opened 1 year ago

mrdude2478 commented 1 year ago

In ioq3\code\qcommon\common.c we can add our own keygen so that the user can generate their own key.

Code mod: Replace this line: Q_strncpyz( key, ikey, 17 );

With this:

//start of keygen
static char charset[] = "237abcdghjlprstw"; 
char *randomString = NULL;
srand ( time(NULL) );
int length = sizeof(charset)-1;
randomString = malloc(length +1);
if (randomString) {
  for (int n = 0;n < length;n++) {
    int key = rand() % (int)(sizeof(charset) -1);
    randomString[n] = charset[key];
 }
randomString[length] = '\0';
}
 //end of keygen

Q_strncpyz( key, randomString, 17 );

At the top of the file add this: //keygen stuff

include

//keygen stuff

Regards.