I`m in the process of making the teams harder - the only way at the moment is dropping the age of every player

Moderator: Moderators
andreasP199 wrote:I see you are able to display the names (last name and initials) of the players. I assume you are generating the names from the 8 hex digits for names stored for each player. I have been wondering how the names are generated. You seem to have figured out the algorithm. If this is the case, are you willing to share the algorithm (source, descripiton or something)?
Code: Select all
class cKORandom
{
public:
WORD GetNextRandom();
WORD GetCurrentRandom();
BYTE m_RND[6];
};
inline WORD cKORandom::GetNextRandom()
{
DWORD adr=(DWORD)&m_RND;
__asm
{
mov ebx,[adr]
mov ah,[ebx+3]
SHR ah,3
mov al,[ebx+5]
XOR ah,al
RCR ah,1
RCL [ebx+1],1
RCL [ebx+0],1
RCL [ebx+3],1
RCL [ebx+2],1
RCL [ebx+5],1
RCL [ebx+4],1
};
return GetCurrentRandom();
}
WORD cKORandom::GetCurrentRandom()
{
WORD ret=m_RND[0]<<8;
ret+=m_RND[1];
return ret;
}
BYTE TheInitialsTableDefault[]=
{
44, 4, 0x41, 0x44, 0x4a, 0x52, //if rnd <=44 then one of ADJR
76, 5, 0x43, 0x45, 0x47, 0x4d, 0x53, //if rnd <= 76 then one of CEGMS
99, 8, 0x42, 0x46, 0x48, 0x49, 0x4c, 0x4e, 0x54, 0x57, //if rnd <= 99 then one of BFHILNTW
100, 1, 0x4f, //if rnd < 100 then one of O
};
TCHAR * Surnames[]=
{
TEXT("Adams"),
TEXT("Adcock"),
TEXT("Addison"),
TEXT("Aldridge"),
TEXT("Alexander"),
TEXT("Allen"),
TEXT("Anderson"),
TEXT("Andrews"),
TEXT("Archer"),
TEXT("Armstrong"),
TEXT("Arnold"),
TEXT("Austin"),
TEXT("Bailey"),
TEXT("Baker"),
TEXT("Barber"),
TEXT("Barker"),
TEXT("Barnes"),
TEXT("Barrett"),
TEXT("Bell"),
TEXT("Bennett"),
TEXT("Berry"),
TEXT("Bishop"),
TEXT("Bloomfield"),
TEXT("Bond"),
TEXT("Bright"),
TEXT("Brookes"),
TEXT("Brown"),
TEXT("Bryant"),
TEXT("Carter"),
TEXT("Chamberlain"),
TEXT("Chapman"),
TEXT("Clark"),
TEXT("Clarke"),
TEXT("Clements"),
TEXT("Collins"),
TEXT("Cole"),
TEXT("Coleman"),
TEXT("Collins"),
TEXT("Cook"),
TEXT("Cooper"),
TEXT("Cox"),
TEXT("Cross"),
TEXT("Curtis"),
TEXT("Davies"),
TEXT("Davis"),
TEXT("Dawson"),
TEXT("Day"),
TEXT("Dennis"),
TEXT("Dickens"),
TEXT("Dixon"),
TEXT("Douglas"),
TEXT("Downs"),
TEXT("Dyer"),
TEXT("Edwards"),
TEXT("Elliott"),
TEXT("Ellis"),
TEXT("Evans"),
TEXT("Fairweather"),
TEXT("Farrell"),
TEXT("Ferguson"),
TEXT("Fisher"),
TEXT("Fletcher"),
TEXT("Foster"),
TEXT("Gibson"),
TEXT("Gilbert"),
TEXT("Goddard"),
TEXT("Gould"),
TEXT("Gray"),
TEXT("Green"),
TEXT("Gregory"),
TEXT("Griffiths"),
TEXT("Hall"),
TEXT("Hammond"),
TEXT("Harris"),
TEXT("Hart"),
TEXT("Harvey"),
TEXT("Hill"),
TEXT("Hodge"),
TEXT("Hopkins"),
TEXT("Hudson"),
TEXT("Hughes"),
TEXT("Hunt"),
TEXT("Jackson"),
TEXT("James"),
TEXT("Johnson"),
TEXT("Jones"),
TEXT("Jordan"),
TEXT("Judge"),
TEXT("Kelly"),
TEXT("Kemp"),
TEXT("King"),
TEXT("Knight"),
TEXT("Kirby"),
TEXT("Langley"),
TEXT("Law"),
TEXT("Lawrence"),
TEXT("Lee"),
TEXT("Lewis"),
TEXT("Lindsey"),
TEXT("Little"),
TEXT("Long"),
TEXT("Longhurst"),
TEXT("Lowe"),
TEXT("Macdonald"),
TEXT("Marshall"),
TEXT("Martin"),
TEXT("Martyn"),
TEXT("Mason"),
TEXT("Matthews"),
TEXT("McDermott"),
TEXT("Miller"),
TEXT("Mills"),
TEXT("Mitchell"),
TEXT("Moore"),
TEXT("Morgan"),
TEXT("Morris"),
TEXT("Morrison"),
TEXT("Murray"),
TEXT("Murphy"),
TEXT("Nelson"),
TEXT("Newman"),
TEXT("Nicholls"),
TEXT("Nixon"),
TEXT("Oates"),
TEXT("Osborne"),
TEXT("Owens"),
TEXT("Page"),
TEXT("Palmer"),
TEXT("Parker"),
TEXT("Payne"),
TEXT("Pearce"),
TEXT("Pearson"),
TEXT("Phillips"),
TEXT("Powell"),
TEXT("Price"),
TEXT("Quinn"),
TEXT("Randall"),
TEXT("Rose"),
TEXT("Reid"),
TEXT("Reynolds"),
TEXT("Richards"),
TEXT("Richardson"),
TEXT("Ritchie"),
TEXT("Roberts"),
TEXT("Robinson"),
TEXT("Rogers"),
TEXT("Russell"),
TEXT("Rowland"),
TEXT("Saunders"),
TEXT("Scott"),
TEXT("Scanlon"),
TEXT("Sharp"),
TEXT("Shaw"),
TEXT("Simpson"),
TEXT("Sinclair"),
TEXT("Smith"),
TEXT("Sawer"),
TEXT("Samuel"),
TEXT("Small"),
TEXT("Stanley"),
TEXT("Steel"),
TEXT("Stevens"),
TEXT("Stevenson"),
TEXT("Taylor"),
TEXT("Thomas"),
TEXT("Thompson"),
TEXT("Turner"),
TEXT("Underwood"),
TEXT("Walker"),
TEXT("Walsh"),
TEXT("Ward"),
TEXT("Watson"),
TEXT("Webb"),
TEXT("Webster"),
TEXT("Wells"),
TEXT("West"),
TEXT("White"),
TEXT("Wilkins"),
TEXT("Williams"),
TEXT("Wilson"),
TEXT("Wood"),
TEXT("Wright"),
TEXT("Young"),
};
void DecodeName(BYTE * pSeed, tstring &outstring)
{
outstring.clear();
cKORandom RND;
RND.m_RND[0]=pSeed[0];
RND.m_RND[1]=pSeed[1];
RND.m_RND[2]=pSeed[2];
RND.m_RND[3]=pSeed[3];
RND.m_RND[4]=0;
RND.m_RND[5]=0;
for (int r=0;r<20;r++)
RND.GetNextRandom();
int val=RND.GetNextRandom();
val=val%100;
int nInitials=3;
if (val<75)
nInitials=1;
else
{
if (val<98)
nInitials=2;
}
for (int i=0;i<nInitials;i++)
{
int x=RND.GetNextRandom();
x=x%100;
BYTE *A2=TheInitialsTableDefault;
if (g_bCustomNameMode)
A2=TheInitialsTableCustom;
while (x>=*A2++)
{
A2+=*A2++;
}
DWORD s=*A2++;
DWORD r=RND.GetNextRandom();
r=r%s;
BYTE c=A2[r];
outstring+=c;
outstring+='.';
}
int iSurnameIdx=RND.GetNextRandom();
int iNumberOfNamesInDB=sizeof(Surnames)/sizeof(TCHAR*);
iSurnameIdx%=iNumberOfNamesInDB; //=183
outstring+=Surnames[iSurnameIdx];
}
UltimateBinary wrote:Andreas, maybe this extract from the tool source will be of use. It is light on comments but should be self-explanatory.
Users browsing this forum: No registered users and 2 guests