mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
Turn GenerateRandomNamePacket handling into a method.
This commit is contained in:
parent
211248b50e
commit
18da8fe44d
166
world/client.cpp
166
world/client.cpp
@ -520,6 +520,89 @@ bool Client::HandleNameApprovalPacket(const EQApplicationPacket *app) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Client::HandleGenerateRandomNamePacket(const EQApplicationPacket *app) {
|
||||||
|
// creates up to a 10 char name
|
||||||
|
char vowels[18]="aeiouyaeiouaeioe";
|
||||||
|
char cons[48]="bcdfghjklmnpqrstvwxzybcdgklmnprstvwbcdgkpstrkd";
|
||||||
|
char rndname[17]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||||
|
char paircons[33]="ngrkndstshthphsktrdrbrgrfrclcr";
|
||||||
|
int rndnum=MakeRandomInt(0, 75),n=1;
|
||||||
|
bool dlc=false;
|
||||||
|
bool vwl=false;
|
||||||
|
bool dbl=false;
|
||||||
|
if (rndnum>63)
|
||||||
|
{ // rndnum is 0 - 75 where 64-75 is cons pair, 17-63 is cons, 0-16 is vowel
|
||||||
|
rndnum=(rndnum-61)*2; // name can't start with "ng" "nd" or "rk"
|
||||||
|
rndname[0]=paircons[rndnum];
|
||||||
|
rndname[1]=paircons[rndnum+1];
|
||||||
|
n=2;
|
||||||
|
}
|
||||||
|
else if (rndnum>16)
|
||||||
|
{
|
||||||
|
rndnum-=17;
|
||||||
|
rndname[0]=cons[rndnum];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rndname[0]=vowels[rndnum];
|
||||||
|
vwl=true;
|
||||||
|
}
|
||||||
|
int namlen=MakeRandomInt(5, 10);
|
||||||
|
for (int i=n;i<namlen;i++)
|
||||||
|
{
|
||||||
|
dlc=false;
|
||||||
|
if (vwl) //last char was a vowel
|
||||||
|
{ // so pick a cons or cons pair
|
||||||
|
rndnum=MakeRandomInt(0, 62);
|
||||||
|
if (rndnum>46)
|
||||||
|
{ // pick a cons pair
|
||||||
|
if (i>namlen-3) // last 2 chars in name?
|
||||||
|
{ // name can only end in cons pair "rk" "st" "sh" "th" "ph" "sk" "nd" or "ng"
|
||||||
|
rndnum=MakeRandomInt(0, 7)*2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // pick any from the set
|
||||||
|
rndnum=(rndnum-47)*2;
|
||||||
|
}
|
||||||
|
rndname[i]=paircons[rndnum];
|
||||||
|
rndname[i+1]=paircons[rndnum+1];
|
||||||
|
dlc=true; // flag keeps second letter from being doubled below
|
||||||
|
i+=1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // select a single cons
|
||||||
|
rndname[i]=cons[rndnum];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // select a vowel
|
||||||
|
rndname[i]=vowels[MakeRandomInt(0, 16)];
|
||||||
|
}
|
||||||
|
vwl=!vwl;
|
||||||
|
if (!dbl && !dlc)
|
||||||
|
{ // one chance at double letters in name
|
||||||
|
if (!MakeRandomInt(0, i+9)) // chances decrease towards end of name
|
||||||
|
{
|
||||||
|
rndname[i+1]=rndname[i];
|
||||||
|
dbl=true;
|
||||||
|
i+=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rndname[0]=toupper(rndname[0]);
|
||||||
|
NameGeneration_Struct* ngs = (NameGeneration_Struct*)app->pBuffer;
|
||||||
|
memset(ngs->name,0,64);
|
||||||
|
strcpy(ngs->name,rndname);
|
||||||
|
|
||||||
|
// char names[8][64] = { "How", "About", "You", "Think", "Of", "Your", "Own", "Name" };
|
||||||
|
// //Could have parts of the random name in this struct and they compile together
|
||||||
|
// NameGeneration_Struct* ngs = (NameGeneration_Struct*)app->pBuffer;
|
||||||
|
// strncpy(ngs->name,"Notcreated",64);
|
||||||
|
|
||||||
|
QueuePacket(app);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Client::HandlePacket(const EQApplicationPacket *app) {
|
bool Client::HandlePacket(const EQApplicationPacket *app) {
|
||||||
const WorldConfig *Config=WorldConfig::get();
|
const WorldConfig *Config=WorldConfig::get();
|
||||||
@ -566,88 +649,7 @@ bool Client::HandlePacket(const EQApplicationPacket *app) {
|
|||||||
}
|
}
|
||||||
case OP_RandomNameGenerator:
|
case OP_RandomNameGenerator:
|
||||||
{
|
{
|
||||||
// creates up to a 10 char name
|
return HandleGenerateRandomNamePacket(app);
|
||||||
char vowels[18]="aeiouyaeiouaeioe";
|
|
||||||
char cons[48]="bcdfghjklmnpqrstvwxzybcdgklmnprstvwbcdgkpstrkd";
|
|
||||||
char rndname[17]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
|
||||||
char paircons[33]="ngrkndstshthphsktrdrbrgrfrclcr";
|
|
||||||
int rndnum=MakeRandomInt(0, 75),n=1;
|
|
||||||
bool dlc=false;
|
|
||||||
bool vwl=false;
|
|
||||||
bool dbl=false;
|
|
||||||
if (rndnum>63)
|
|
||||||
{ // rndnum is 0 - 75 where 64-75 is cons pair, 17-63 is cons, 0-16 is vowel
|
|
||||||
rndnum=(rndnum-61)*2; // name can't start with "ng" "nd" or "rk"
|
|
||||||
rndname[0]=paircons[rndnum];
|
|
||||||
rndname[1]=paircons[rndnum+1];
|
|
||||||
n=2;
|
|
||||||
}
|
|
||||||
else if (rndnum>16)
|
|
||||||
{
|
|
||||||
rndnum-=17;
|
|
||||||
rndname[0]=cons[rndnum];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rndname[0]=vowels[rndnum];
|
|
||||||
vwl=true;
|
|
||||||
}
|
|
||||||
int namlen=MakeRandomInt(5, 10);
|
|
||||||
for (int i=n;i<namlen;i++)
|
|
||||||
{
|
|
||||||
dlc=false;
|
|
||||||
if (vwl) //last char was a vowel
|
|
||||||
{ // so pick a cons or cons pair
|
|
||||||
rndnum=MakeRandomInt(0, 62);
|
|
||||||
if (rndnum>46)
|
|
||||||
{ // pick a cons pair
|
|
||||||
if (i>namlen-3) // last 2 chars in name?
|
|
||||||
{ // name can only end in cons pair "rk" "st" "sh" "th" "ph" "sk" "nd" or "ng"
|
|
||||||
rndnum=MakeRandomInt(0, 7)*2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // pick any from the set
|
|
||||||
rndnum=(rndnum-47)*2;
|
|
||||||
}
|
|
||||||
rndname[i]=paircons[rndnum];
|
|
||||||
rndname[i+1]=paircons[rndnum+1];
|
|
||||||
dlc=true; // flag keeps second letter from being doubled below
|
|
||||||
i+=1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // select a single cons
|
|
||||||
rndname[i]=cons[rndnum];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // select a vowel
|
|
||||||
rndname[i]=vowels[MakeRandomInt(0, 16)];
|
|
||||||
}
|
|
||||||
vwl=!vwl;
|
|
||||||
if (!dbl && !dlc)
|
|
||||||
{ // one chance at double letters in name
|
|
||||||
if (!MakeRandomInt(0, i+9)) // chances decrease towards end of name
|
|
||||||
{
|
|
||||||
rndname[i+1]=rndname[i];
|
|
||||||
dbl=true;
|
|
||||||
i+=1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rndname[0]=toupper(rndname[0]);
|
|
||||||
NameGeneration_Struct* ngs = (NameGeneration_Struct*)app->pBuffer;
|
|
||||||
memset(ngs->name,0,64);
|
|
||||||
strcpy(ngs->name,rndname);
|
|
||||||
|
|
||||||
// char names[8][64] = { "How", "About", "You", "Think", "Of", "Your", "Own", "Name" };
|
|
||||||
// //Could have parts of the random name in this struct and they compile together
|
|
||||||
// NameGeneration_Struct* ngs = (NameGeneration_Struct*)app->pBuffer;
|
|
||||||
// strncpy(ngs->name,"Notcreated",64);
|
|
||||||
|
|
||||||
QueuePacket(app);
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
case OP_CharacterCreateRequest: {
|
case OP_CharacterCreateRequest: {
|
||||||
// New OpCode in SoF
|
// New OpCode in SoF
|
||||||
|
|||||||
@ -97,9 +97,11 @@ private:
|
|||||||
bool firstlogin;
|
bool firstlogin;
|
||||||
bool seencharsel;
|
bool seencharsel;
|
||||||
bool realfirstlogin;
|
bool realfirstlogin;
|
||||||
|
|
||||||
bool HandlePacket(const EQApplicationPacket *app);
|
bool HandlePacket(const EQApplicationPacket *app);
|
||||||
bool HandleNameApprovalPacket(const EQApplicationPacket *app);
|
bool HandleNameApprovalPacket(const EQApplicationPacket *app);
|
||||||
bool HandleSendLoginInfoPacket(const EQApplicationPacket *app);
|
bool HandleSendLoginInfoPacket(const EQApplicationPacket *app);
|
||||||
|
bool HandleGenerateRandomNamePacket(const EQApplicationPacket *app);
|
||||||
|
|
||||||
EQStreamInterface* const eqs;
|
EQStreamInterface* const eqs;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user