06-11-2022, 10:39 PM
Hello, I'm trying to make a daily reward system, I've never done something "so complex" so I'm pretty lost on the subject... I managed to make the request on the client side, but when trying to return something from the server , it closes. This is the code that I have written, could someone tell me if there is an obvious problem?
This is my ptype
#ifndef __PTYPE_OLD_DO_DAILYREWARD_H__
#define __PTYPE_OLD_DO_DAILYREWARD_H__
#include "ptype_base.h"
enum{
MSG_DAILYREWARD_ERROR,
MSG_DAILYREWARD_LIST_REQ,
MSG_DAILYREWARD_LIST_RES,
};
#pragma pack(push, 1)
namespace RequestClient{
struct doDailyRewardList : public pTypeBase{
};
}
namespace ResponseClient{
struct ReceiveList : public pTypeBase{
std:
tring lastDate;};
#ifndef _CLIENT_
inline void DailyRewardErrorMsg(CNetMsg::SP& msg, MSG_DAILYREWARD_ERROR_TYPE err){
msg->Init(MSG_DAILYREWARD);
RefMsg(msg) << (unsigned char)MSG_DAILYREWARD_ERROR
<< (unsigned char)err;
}
inline void makeDailyRewardReturnList(CNetMsg::SP& msg, std:
tring lastDate){ResponseClient::ReceiveList *packet = reinterpret_cast<ResponseClient::ReceiveList*>(msg->m_buf);
packet->type = MSG_DAILYREWARD;
packet->subType = MSG_DAILYREWARD_LIST_RES;
packet->lastDate = lastDate;
msg->setSize(sizeof(ResponseClient::ReceiveList));
}
#endif
}
#pragma pack(pop)
#endif
And this would be the function I'm working on
void do_DailyRewardList(CPC* ch, CNetMsg::SP& msg){
CDBCmd cmd;
cmd.Init(&gserver->m_dbchar);
std:
tring sql = boost:
tr(boost::format("SELECT * FROM t_daily_reward_system WHERE a_char_index=%d") % ch->m_index);cmd.SetQuery(sql);
if(cmd.Open() == true && cmd.MoveNext() == true){
std:
tring last_date = ("");cmd.GetRec("a_last_date", last_date); // Format: Datetime
//LOG_INFO("DAILY REWARD SYSTEM Char Index : %d, Last Date : %s", ch->m_index, last_date);
CNetMsg::SP rmsg(new CNetMsg);
ResponseClient::makeDailyRewardReturnList(rmsg, last_date);
SEND_Q(rmsg, ch->m_desc);
return;
}else{
LOG_ERROR("DAILY REWARD SYSTEM : se fue a la putah");
}
}

