------------------------------------------------
DSProtocol.cpp
------------------------------------------------
case 0x0F:
switch(((lpMsg[0]==0xC1)?lpMsg[3]:lpMsg[4]))
{
case 0x00:
gCommandManager.DGCommandResetRecv((SDHP_COMMAND_RESET_RECV*)lpMsg);
break;
case 0x01:
gCommandManager.DGCommandMasterResetRecv((SDHP_COMMAND_MASTER_RESET_RECV*)lpMsg);
break;
case 0x02:
gCommandManager.DGCommandMarryRecv((SDHP_COMMAND_MARRY_RECV*)lpMsg);
break;
}
break;
void GDMarryInfoSaveSend(int aIndex,char* marryname,char* mode) // OK
{
LPOBJ lpObj = &gObj[aIndex];
SDHP_MARRY_INFO_SAVE_SEND pMsg;
pMsg.header.set(0xF0,sizeof(pMsg));
pMsg.index = aIndex;
memcpy(pMsg.name,lpObj->Name,sizeof(pMsg.name));
memcpy(pMsg.marryname,marryname,sizeof(pMsg.marryname));
memcpy(pMsg.mode,mode,sizeof(pMsg.mode));
//pMsg.name = name;
//pMsg.marryname = marryname;
gDataServerConnection.DataSend((BYTE*)&pMsg,pMsg.header.size);
}
------------------------------------------------
User.h
------------------------------------------------
DWORD MarryTimeMsj;
------------------------------------------------
DSProtocol.h
------------------------------------------------
struct SDHP_MARRY_INFO_SAVE_SEND
{
PBMSG_HEAD header; // C1:39
WORD index;
char name[11];
char marryname[11];
char mode[11];
UINT countyou;
UINT counthim;
UINT marriedon;
};
void GDMarryInfoSaveSend(int aIndex,char* marryname,char* mode);
------------------------------------------------
CommandManager.h
------------------------------------------------
struct SDHP_COMMAND_MARRY_RECV
{
PSBMSG_HEAD header; // C1:0F:02
WORD index;
char name[11];
char marryname[11];
char mode[11];
char NameGet1[11];
char NameGet2[11];
UINT countyou;
UINT counthim;
UINT marriedon;
};
struct SDHP_COMMAND_MARRY_SEND
{
PSBMSG_HEAD header; // C1:0F:02
WORD index;
char name[11];
char marryname[11];
char mode[11];
};
void DGCommandMarryRecv(SDHP_COMMAND_MARRY_RECV* lpMsg);
void CommandMarry(LPOBJ lpObj,char* arg);
------------------------------------------------
CommandManager.cpp
------------------------------------------------
case COMMAND_MARRY:
this->CommandMarry(lpObj,argument);
break;
void CCommandManager::CommandMarry(LPOBJ lpObj,char* arg) // OK
{
char mode[11] = {0};
this->GetString(arg,mode,sizeof(mode),0);
if(gServerInfo.m_CommandMarrySwitch == 0)
{
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(619));
return;
}
if (mode[0] == NULL){
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(606));
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(623),gServerInfo.m_CommandMarryLevel,gServerInfo.m_CommandMarryCost);
return;
}
if(strcmp(mode,"to") == 0)
{
char MarryName[11] = {0};
this->GetString(arg,MarryName,sizeof(MarryName),1);
LPOBJ lpTarget = gObjFind(MarryName);
if (lpTarget == 0)
{
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(111));
return;
}
if (strcmp(MarryName,lpObj->Name) == 0)
{
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(602));
return;
}
SDHP_COMMAND_MARRY_SEND pMsg;
pMsg.header.set(0x0F,0x02,sizeof(pMsg));
pMsg.index = lpObj->Index;
memcpy(pMsg.name,lpObj->Name,sizeof(pMsg.name));
memcpy(pMsg.marryname,MarryName,sizeof(pMsg.marryname));
memcpy(pMsg.mode,"marry",sizeof(pMsg.mode));
gDataServerConnection.DataSend((BYTE*)&pMsg,pMsg.header.size);
}
else if(strcmp(mode,"divorce") == 0)
{
SDHP_COMMAND_MARRY_SEND pMsg;
pMsg.header.set(0x0F,0x02,sizeof(pMsg));
pMsg.index = lpObj->Index;
memcpy(pMsg.name,lpObj->Name,sizeof(pMsg.name));
memcpy(pMsg.marryname,lpObj->Name,sizeof(pMsg.marryname));
memcpy(pMsg.mode,"divorce",sizeof(pMsg.mode));
gDataServerConnection.DataSend((BYTE*)&pMsg,pMsg.header.size);
}
else if(strcmp(mode,"track") == 0)
{
if (lpObj->Money < (DWORD)gServerInfo.m_CommandMarryCost) {
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(620),gServerInfo.m_CommandMarryCost);
return;
}
SDHP_COMMAND_MARRY_SEND pMsg;
pMsg.header.set(0x0F,0x02,sizeof(pMsg));
pMsg.index = lpObj->Index;
memcpy(pMsg.name,lpObj->Name,sizeof(pMsg.name));
memcpy(pMsg.marryname,lpObj->Name,sizeof(pMsg.marryname));
memcpy(pMsg.mode,"track",sizeof(pMsg.mode));
gDataServerConnection.DataSend((BYTE*)&pMsg,pMsg.header.size);
}
else if(strcmp(mode,"trace") == 0)
{
if (lpObj->Money < (DWORD)gServerInfo.m_CommandMarryCost) {
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(620),gServerInfo.m_CommandMarryCost);
return;
}
SDHP_COMMAND_MARRY_SEND pMsg;
pMsg.header.set(0x0F,0x02,sizeof(pMsg));
pMsg.index = lpObj->Index;
memcpy(pMsg.name,lpObj->Name,sizeof(pMsg.name));
memcpy(pMsg.marryname,lpObj->Name,sizeof(pMsg.marryname));
memcpy(pMsg.mode,"trace",sizeof(pMsg.mode));
gDataServerConnection.DataSend((BYTE*)&pMsg,pMsg.header.size);
}
else {
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(606));
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(623),gServerInfo.m_CommandMarryLevel,gServerInfo.m_CommandMarryCost);
return;
}
}
void CCommandManager::DGCommandMarryRecv(SDHP_COMMAND_MARRY_RECV* lpMsg) // OK
{
LPOBJ lpObj = &gObj[lpMsg->index];
LPOBJ lpTarget = gObjFind(lpMsg->marryname);
//lpMsg->name;
if(strcmp(lpMsg->mode,"marry") == 0)
{
if (lpMsg->countyou > 0){
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(604));
return;
}
if (lpMsg->counthim > 0){
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(605));
return;
}
//
int minx = 12;
int maxx = 15;
int miny = 23;
int maxy = 28;
if (lpObj->Map == 2 && lpObj->X >= minx && lpObj->X <= maxx && lpObj->Y >= miny && lpObj->Y <= maxy)
{
//good to go for you
}
else {
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(621));
return;
}
if (lpTarget->Map == 2 && lpTarget->X >= minx && lpTarget->X <= maxx && lpTarget->Y >= miny && lpTarget->Y <= maxy)
{
//good to go for the other person
}
else {
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(622));
return;
}
//
int first_classtype = 0;
if(
(lpObj->DBClass == DB_CLASS_DW) || (lpObj->DBClass == DB_CLASS_SM) || (lpObj->DBClass == DB_CLASS_GM) || (lpObj->DBClass == DB_CLASS_DK) ||
(lpObj->DBClass == DB_CLASS_BK) || (lpObj->DBClass == DB_CLASS_BM) || (lpObj->DBClass == DB_CLASS_MG) || (lpObj->DBClass == DB_CLASS_DM) ||
(lpObj->DBClass == DB_CLASS_DL) || (lpObj->DBClass == DB_CLASS_LE) || (lpObj->DBClass == DB_CLASS_RF) || (lpObj->DBClass == DB_CLASS_FM) ) {
first_classtype=0;
}
else if(
(lpObj->DBClass == DB_CLASS_FE) || (lpObj->DBClass == DB_CLASS_ME) || (lpObj->DBClass == DB_CLASS_HE) || (lpObj->DBClass == DB_CLASS_SU) ||
(lpObj->DBClass == DB_CLASS_BS) || (lpObj->DBClass == DB_CLASS_DS) ) {
first_classtype=1;
}
//
int second_classtype = 0;
if(
(lpTarget->DBClass == DB_CLASS_DW) || (lpTarget->DBClass == DB_CLASS_SM) || (lpTarget->DBClass == DB_CLASS_GM) || (lpTarget->DBClass == DB_CLASS_DK) ||
(lpTarget->DBClass == DB_CLASS_BK) || (lpTarget->DBClass == DB_CLASS_BM) || (lpTarget->DBClass == DB_CLASS_MG) || (lpTarget->DBClass == DB_CLASS_DM) ||
(lpTarget->DBClass == DB_CLASS_DL) || (lpTarget->DBClass == DB_CLASS_LE) || (lpTarget->DBClass == DB_CLASS_RF) || (lpTarget->DBClass == DB_CLASS_FM) ) {
second_classtype=0;
}
else if(
(lpTarget->DBClass == DB_CLASS_FE) || (lpTarget->DBClass == DB_CLASS_ME) || (lpTarget->DBClass == DB_CLASS_HE) || (lpTarget->DBClass == DB_CLASS_SU) ||
(lpTarget->DBClass == DB_CLASS_BS) || (lpTarget->DBClass == DB_CLASS_DS) ) {
second_classtype=1;
}
char fulltext_new[256];
wsprintf(fulltext_new,gMessage.GetMessage(615),lpMsg->name,lpMsg->marryname);
if ((first_classtype == 0) && (second_classtype == 0)) {
if((GetTickCount()-lpObj->MarryTimeMsj) > (DWORD)(gServerInfo.m_CommandMarryNoticeDelay*1000))
{
GDGlobalNoticeSend(gMapServerManager.GetMapServerGroup(),0,0,0,0,0,0,gMessage.GetMessage(616));//nohomo allowed
GDGlobalNoticeSend(gMapServerManager.GetMapServerGroup(),0,0,0,0,0,0,fulltext_new);//nohomo allowed
}
lpObj->MarryTimeMsj = GetTickCount();
return;
}
if ((first_classtype == 1) && (second_classtype == 1)) {
if((GetTickCount()-lpObj->MarryTimeMsj) > (DWORD)(gServerInfo.m_CommandMarryNoticeDelay*1000))
{
GDGlobalNoticeSend(gMapServerManager.GetMapServerGroup(),0,0,0,0,0,0,gMessage.GetMessage(616));//nohomo allowed
GDGlobalNoticeSend(gMapServerManager.GetMapServerGroup(),0,0,0,0,0,0,fulltext_new);//nohomo allowed
}
lpObj->MarryTimeMsj = GetTickCount();
return;
}
//
GDGlobalNoticeSend(gMapServerManager.GetMapServerGroup(),0,0,0,0,0,0,gMessage.GetMessage(614));
GDMarryInfoSaveSend(lpObj->Index,lpMsg->marryname,lpMsg->mode);
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(603),lpMsg->marryname);
char fulltext[256];
wsprintf(fulltext,gMessage.GetMessage(612),lpObj->Name,lpMsg->marryname);
GDGlobalNoticeSend(gMapServerManager.GetMapServerGroup(),0,0,0,0,0,0,fulltext);
for(int n=0;n < 15;n++)
{
GCFireworksSend(lpObj,(lpObj->X+(((GetLargeRand()%5)*2)-4)),(lpObj->Y+(((GetLargeRand()%5)*2)-4)));
}
//
}
else if(strcmp(lpMsg->mode,"divorce") == 0)
{
if (lpMsg->countyou == 0){
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(609));
return;
}
time_t timer;
struct tm y2k = {0};
UINT seconds;
y2k.tm_hour = 0; y2k.tm_min = 0; y2k.tm_sec = 0;
y2k.tm_year = 116; y2k.tm_mon = 0; y2k.tm_mday = 1;
time(&timer); /* get current time; same as: timer = time(NULL) */
seconds = static_cast<UINT>(difftime(timer,mktime(&y2k)));
UINT value = seconds - lpMsg->marriedon;
if (value < (UINT)gServerInfo.m_CommandMarryMinTime){
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(607));
return;
}
LPOBJ lpTarget1 = gObjFind(lpMsg->NameGet1);
LPOBJ lpTarget2 = gObjFind(lpMsg->NameGet2);
if (lpTarget1 == 0 && lpTarget2 == 0) {
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(624));
return;
}
char fulltext[256];
GDGlobalNoticeSend(gMapServerManager.GetMapServerGroup(),0,0,0,0,0,0,gMessage.GetMessage(614));
if(lpTarget1 == 0)
{
wsprintf(fulltext,gMessage.GetMessage(613),lpObj->Name,lpMsg->NameGet2);
GDGlobalNoticeSend(gMapServerManager.GetMapServerGroup(),0,0,0,0,0,0,fulltext);
}
if(lpTarget2 == 0)
{
wsprintf(fulltext,gMessage.GetMessage(613),lpObj->Name,lpMsg->NameGet1);
GDGlobalNoticeSend(gMapServerManager.GetMapServerGroup(),0,0,0,0,0,0,fulltext);
}
//
GDMarryInfoSaveSend(lpObj->Index,lpMsg->marryname,lpMsg->mode);
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(608));
//
}
else if(strcmp(lpMsg->mode,"track") == 0)
{
if (lpMsg->countyou == 0){
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(609));
return;
}
LPOBJ lpTarget1 = gObjFind(lpMsg->NameGet1);
LPOBJ lpTarget2 = gObjFind(lpMsg->NameGet2);
if (lpTarget1 == 0 && lpTarget2 == 0) {
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(625));
return;
}
if (lpObj->Level >= gServerInfo.m_CommandMarryLevel) {
if(lpTarget1 == 0)
{
gObjTeleport(lpObj->Index,lpTarget2->Map,lpTarget2->X,lpTarget2->Y);
gObjTeleport(lpTarget2->Index,lpTarget2->Map,lpTarget2->X,lpTarget2->Y);
}
if(lpTarget2 == 0)
{
gObjTeleport(lpObj->Index,lpTarget1->Map,lpTarget1->X,lpTarget1->Y);
gObjTeleport(lpTarget1->Index,lpTarget1->Map,lpTarget1->X,lpTarget1->Y);
}
}
else{
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(617),gServerInfo.m_CommandMarryLevel);
return;
}
//
GDMarryInfoSaveSend(lpObj->Index,lpMsg->marryname,lpMsg->mode);
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(610),lpMsg->marryname);
lpObj->Money -= gServerInfo.m_CommandMarryCost;
GCMoneySend(lpObj->Index,lpObj->Money);
//
}
else if(strcmp(lpMsg->mode,"trace") == 0)
{
if (lpMsg->countyou == 0){
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(609));
return;
}
LPOBJ lpTarget1 = gObjFind(lpMsg->NameGet1);
LPOBJ lpTarget2 = gObjFind(lpMsg->NameGet2);
//
if (lpTarget1 == 0 && lpTarget2 == 0) {
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(625));
return;
}
if(lpTarget1 == 0)
{
if (lpTarget2->Level >= gServerInfo.m_CommandMarryLevel) {
gObjTeleport(lpTarget2->Index,lpObj->Map,lpObj->X,lpObj->Y);
gObjTeleport(lpObj->Index,lpObj->Map,lpObj->X,lpObj->Y);
}
else {
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(618),gServerInfo.m_CommandMarryLevel);
return;
}
}
if(lpTarget2 == 0)
{
if (lpTarget1->Level >= gServerInfo.m_CommandMarryLevel) {
gObjTeleport(lpTarget1->Index,lpObj->Map,lpObj->X,lpObj->Y);
gObjViewportListProtocolDestroy(lpObj);
}
else {
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(618),gServerInfo.m_CommandMarryLevel);
return;
}
}
//
GDMarryInfoSaveSend(lpObj->Index,lpMsg->marryname,lpMsg->mode);
gNotice.GCNoticeSend(lpObj->Index,1,0,0,0,0,0,gMessage.GetMessage(611),lpMsg->marryname);
lpObj->Money -= gServerInfo.m_CommandMarryCost;
GCMoneySend(lpObj->Index,lpObj->Money);
//
}
gLog.Output(LOG_COMMAND,"[CommandMarry][%s][%d][%d][%d][%s][%s][%s]",lpObj->Account,lpMsg->countyou,lpMsg->counthim,lpMsg->marriedon,lpMsg->marryname,lpMsg->NameGet1,lpMsg->NameGet2);
}
------------------------------------------------
ServerInfo.h
------------------------------------------------
int m_CommandMarrySwitch;
int m_CommandMarryLevel;
int m_CommandMarryCost;
int m_CommandMarryNoticeDelay;
int m_CommandMarryMinTime;
------------------------------------------------
ServerInfo.cpp
------------------------------------------------
this->m_CommandMarrySwitch = GetPrivateProfileInt(section,"CommandMarrySwitch",0,path);
this->m_CommandMarryLevel = GetPrivateProfileInt(section,"CommandMarryLevel",0,path);
this->m_CommandMarryCost = GetPrivateProfileInt(section,"CommandMarryCost",0,path);
this->m_CommandMarryMinTime = GetPrivateProfileInt(section,"CommandMarryMinTime",0,path);
this->m_CommandMarryNoticeDelay = GetPrivateProfileInt(section,"CommandMarryNoticeDelay",0,path);
--Gameserverinfo - Command.txt inside gs/Data folder
;==================================================
; Marry Command Settings
;==================================================
CommandMarrySwitch = 1
CommandMarryLevel = 150
CommandMarryCost = 350
CommandMarryNoticeDelay = 60
CommandMarryMinTime = 604800