Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion DboServer/Server/GameServer/gm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ ACMD(do_exp);
ACMD(do_resetexp);
ACMD(do_starthoneybee);
ACMD(do_stophoneybee);
ACMD(do_createguild);
ACMD(do_deleteguild);
ACMD(do_cancelah);
ACMD(do_addmudosa);
Expand Down Expand Up @@ -169,6 +170,7 @@ struct command_info cmd_info[] =
{ L"@resetexp", do_resetexp, ADMIN_LEVEL_NONE },
{ L"@starthoneybee", do_starthoneybee, ADMIN_LEVEL_COMMUNITY_MANAGER },
{ L"@stophoneybee", do_stophoneybee, ADMIN_LEVEL_COMMUNITY_MANAGER },
{ L"@createguild", do_createguild, ADMIN_LEVEL_GAME_MASTER }, // Haven't tested if it works for others. Create a single party first.
{ L"@deleteguild", do_deleteguild, ADMIN_LEVEL_COMMUNITY_MANAGER },
{ L"@cancelah", do_cancelah, ADMIN_LEVEL_GAME_MASTER },
{ L"@addmudosa", do_addmudosa, ADMIN_LEVEL_ADMIN },
Expand Down Expand Up @@ -1576,6 +1578,48 @@ ACMD(do_stophoneybee)
NTL_PRINT(PRINT_APP, "HoneybeeEvent Stopped");
}

// Maybe remove later after testing if it's needed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below defines are already defined on DboShared/NtlShared2/NtlSharedDef.h. Maybe reuse them? NTL_MIN_SIZE_GUILD_NAME seems to be 2 instead of 3 too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that would be the better choice? I could change and test it later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that way we avoid code duplicity.

#ifndef NTL_MIN_SIZE_GUILD_NAME
#define NTL_MIN_SIZE_GUILD_NAME 3
#endif
#ifndef NTL_MAX_SIZE_GUILD_NAME
#define NTL_MAX_SIZE_GUILD_NAME 16
#endif

ACMD(do_createguild)
{
CGameServer* app = (CGameServer*)g_pApp;

pToken->PopToPeek();
std::wstring wTok = pToken->PeekNextToken(NULL, &iLine);

std::string name = ws2s(wTok); // keep storage alive
if (name.empty())
return;

// Basic validation (optional)
if (name.length() < NTL_MIN_SIZE_GUILD_NAME || name.length() > NTL_MAX_SIZE_GUILD_NAME)
return;
if (name.find_first_not_of("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890") != std::string::npos)
return;

WCHAR* wchName = Ntl_MB2WC((char*)name.c_str());

CNtlPacket cPacket(sizeof(sGT_GUILD_CREATE));
sGT_GUILD_CREATE* req = (sGT_GUILD_CREATE*)cPacket.GetPacketData();
req->wOpCode = GT_GUILD_CREATE;
req->creatorCharId = pPlayer->GetCharID();
NTL_SAFE_WCSCPY(req->wszGuildName, wchName);
cPacket.SetPacketLen(sizeof(sGT_GUILD_CREATE));

app->SendTo(app->GetChatServerSession(), &cPacket);

Ntl_CleanUpHeapStringW(wchName);

// Strongly recommend a log so you can prove it fired
ERR_LOG(LOG_USER, "GM @createguild fired: charId=%u name=%s", pPlayer->GetCharID(), name.c_str());
}

ACMD(do_deleteguild)
{
CGameServer* app = (CGameServer*)g_pApp;
Expand Down Expand Up @@ -1868,4 +1912,4 @@ ACMD(do_removeskillscd)
ACMD(do_test)
{
pPlayer->SendCharStateFalling(NTL_MOVE_NONE);
}
}