每天对着不同的计划,多多少少有一种无形的压力。特别是对技术不好的我来说,过程中遇到的问题实在不少,时常纠结良久。时间慢慢流逝,最后虽然感觉有些不足,但是也不至于差强人意。商业版的PF核心已经升级到1.0.5版本,增添和完善了许多功能。核心主要完善了网络模块、脚本模块、文件模块、引 ...
每天对着不同的计划,多多少少有一种无形的压力。特别是对技术不好的我来说,过程中遇到的问题实在不少,时常纠结良久。时间慢慢流逝,最后虽然感觉有些不足,但是也不至于差强人意。商业版的PF核心已经升级到1.0.5版本,增添和完善了许多功能。核心主要完善了网络模块、脚本模块、文件模块、引擎模块、缓存模块等等,并制作了基本的场景插件和AI插件。未来的PF将支持更多的功能,将安装和使用更加的自动化,执行一个脚本就能完成许多不必要的步骤。所以未来的脚本工具是一个必须完成的功能,在此我们将迎来一个个热爱开源项目的同仁和期待你们的加入。
计划表
每日都在计划表中纠结,一步步辛酸,一步步艰难的前行。
CODE
部分商业核心代码,暂时不予开源。
#include "pf/base/get='_blank'>string.h"#include "pf/base/log.h"#include "pf/base/time_manager.h"#include "pf/net/packet/factorymanager.h"#include "pf/sys/thread.h"#include "common/define/enum.h"#include "common/define/macros.h"#include "common/define/net/packet/id/clientlogin.h"#include "common/define/net/packet/id/billinglogin.h"#include "common/define/net/packet/id/logincenter.h"#include "common/net/packet/client_tologin/ask_login.h"#include "common/net/packet/login_toclient/ask_login.h"#include "common/net/packet/login_tocenter/role_kick.h"#include "common/net/packet/login_tobilling/auth.h"#include "common/net/packet/billing_tologin/auth.h"#include "common/net/packet/login_toclient/turn_status.h"#include "connection/login.h"#include "engine/system.h"#include "connection/queue/turn.h"#include "logic/login/controllers/account.h"using namespace logic::login;using namespace common::define::net::packet;AccountController::AccountController() { core_ = NULL;}AccountController::~AccountController() { //do nothing}bool AccountController::setuplayout() { return true;}int32_t AccountController::request(uint8_t type, void *data) { __ENTER_FUNCTION int32_t result = -1; switch (type) { case kLogicRequestNet: { logic_requestnet_t *netdata = static_cast<logic_requestnet_t *>(data); result = net_handle(netdata); break; } case kLogicRequestUICommand: break; case kLogicRequestDB: break; default: break; } return result; __LEAVE_FUNCTION return -1;}void AccountController::set_core(logic::Interface *core) { core_ = core;}logic::Interface *AccountController::get_core() { return core_;}int32_t AccountController::ask_login(logic_requestnet_t *netdata) { __ENTER_FUNCTION using namespace pf_base::string; using namespace common::net::packet; char account[ACCOUNT_LENGTH_MAX] = {0}; connection::Login *connection = dynamic_cast<connection::Login *>(netdata->connection); client_tologin::AskLogin *packet = dynamic_cast<client_tologin::AskLogin *>(netdata->packet); safecopy(account, packet->get_account(), sizeof(account)); if (0 == strlen(account) || !checkstr(account, sizeof(account))) { login_toclient::AskLogin msg; msg.set_result(kLoginResultAuthFail); connection->sendpacket(&msg); SLOW_LOG(LOGIC_MODULENAME, "[logic.login] (AccountController::ask_login) account is empty." " account: %s, version: %d", packet->get_account(), _MAIN_VERSION); return kPacketExecuteStatusContinue; } connection->setaccount(packet->get_account()); connection->setstatus(kConnectionStatusLoginWaitingAuth); connection->set_billingtime(TIME_MANAGER_POINTER->get_saved_time()); login_tobilling::Auth *msg = dynamic_cast<login_tobilling::Auth *>( .NET_PACKET_FACTORYMANAGER_POINTER ->createpacket(id::login_tobilling::kAuth)); Assert(msg); msg->set_account(packet->get_account()); msg->set_password(packet->get_password()); msg->set_connectionid(connection->getid()); msg->set_token(packet->get_token()); msg->set_ip(connection->getsocket()->host_); CONNECTION_MANAGER_SERVER_POINTER ->syncpacket(msg, kConnectServerTypeBilling); return kPacketExecuteStatusContinue; __LEAVE_FUNCTION return -1;}int32_t AccountController::auth(logic_requestnet_t *netdata) { __ENTER_FUNCTION uint64_t current_threadid = pf_sys::get_current_thread_id(); int32_t result = kPacketExecuteStatusContinue; if (current_threadid == CONNECTION_MANAGER_INCOMING_POINTER->threadid_) { result = auth_toincomming(netdata); } else if (current_threadid == CONNECTION_MANAGER_LOGIN_POINTER->threadid_) { result = auth_tologin(netdata); } return result; __LEAVE_FUNCTION return kPacketExecuteStatusError;}int32_t AccountController::auth_toincomming(logic_requestnet_t *netdata) { __ENTER_FUNCTION using namespace common::net::packet; billing_tologin::Auth *packet = dynamic_cast<billing_tologin::Auth *>(netdata->packet); connection::Login *connection = dynamic_cast<connection::Login *>(netdata->connection); if (strcmp(connection->getaccount(), packet->get_account()) != 0) { SLOW_ERRORLOG(LOGIC_MODULENAME, "[logic.login] (AccountController::auth_toincomming)" " account error." " account: %s, packet account: %s", connection->getaccount(), packet->get_account()); return kPacketExecuteStatusContinue; } uint32_t time = connection->get_billingtime(); enum { kBillingTimeMax = 600000, }; if (TIME_MANAGER_POINTER->get_saved_time() > time + kBillingTimeMax) { SLOW_DEBUGLOG(LOGIC_MODULENAME, "[logic.login] (AccountController::auth) time out."); return kPacketExecuteStatusContinue; } if (kConnectionStatusLoginWaitingAuth == connection->getstatus()) { if (kLoginResultSuccess == packet->get_result() && GLOBAL_VALUES["app_status"] != kAppStatusStop) { connection->setstatus(kConnectionStatusLoginAuthed); CONNECTION_MANAGER_INCOMING_POINTER->erase(connection); CONNECTION_MANAGER_LOGIN_POINTER //发送到登陆管理器线程 ->sendpacket(packet, connection->getid()); connection->setstatus(kConnectionStatusLoginProcessTurn); } else { if (kLoginResultOtherOnline == packet->get_result()) { //这个暂时用不到 login_tocenter::RoleKick *msg = dynamic_cast<login_tocenter::RoleKick *>( NET_PACKET_FACTORYMANAGER_POINTER ->createpacket(id::login_tocenter::kRoleKick)); Assert(msg); msg->set_account(packet->get_account()); CONNECTION_MANAGER_SERVER_POINTER ->syncpacket(msg, kConnectServerTypeCenter); } login_toclient::AskLogin msg; msg.set_result(packet->get_result()); if (GLOBAL_VALUES["app_status"] == kAppStatusStop) { msg.set_result(kLoginResultStopService); } CONNECTION_MANAGER_LOGIN_POINTER->sendpacket(&msg, connection->getid()); } } return kPacketExecuteStatusContinue; __LEAVE_FUNCTION return kPacketExecuteStatusError;} int32_t AccountController::auth_tologin(logic_requestnet_t *netdata) { __ENTER_FUNCTION using namespace common::net::packet; billing_tologin::Auth *packet = dynamic_cast<billing_tologin::Auth *>(netdata->packet); connection::Login *connection = dynamic_cast<connection::Login *>(netdata->connection); if (strcmp(connection->getaccount(), packet->get_account()) != 0) { SLOW_ERRORLOG(LOGIC_MODULENAME, "[logic.login] (AccountController::auth_tologin)" " account error." " account: %s, packet account: %s", connection->getaccount(), packet->get_account()); return kPacketExecuteStatusContinue; } CONNECTION_MANAGER_LOGIN_POINTER->add(connection); login_toclient::AskLogin msg; msg.set_result(kLoginResultSuccess); CONNECTION_MANAGER_LOGIN_POINTER->sendpacket(&msg, connection->getid()); uint16_t queuepos = 0; CONNECTION_QUEUE_TURN_POINTER->erase(connection->getaccount(), connection->getid()); if (CONNECTION_QUEUE_TURN_POINTER->addin( connection->getid(), connection->getaccount(), queuepos)) { connection->set_queueposition(queuepos); connection->set_last_sendmessage_turntime( TIME_MANAGER_POINTER->get_tickcount()); login_toclient::TurnStatus msg; msg.set_status(kLoginTurnStatusInTurn); msg.set_number( CONNECTION_QUEUE_TURN_POINTER->calculate_turnnumber(queuepos)); connection->sendpacket(&msg); } else { SLOW_WARNINGLOG(LOGIC_MODULENAME, "[logic.login] (AccountController::auth_tologin)" " the turn is full. account: %s", connection->getaccount()); CONNECTION_MANAGER_LOGIN_POINTER->remove(connection); return kPacketExecuteStatusError; } return kPacketExecuteStatusContinue; __LEAVE_FUNCTION return kPacketExecuteStatusError;}int32_t AccountController::net_handle(logic_requestnet_t *netdata) { __ENTER_FUNCTION if (is_null(netdata) || is_null(netdata->connection) || is_null(netdata->packet)) return kPacketExecuteStatusError; int32_t result = kPacketExecuteStatusContinue; uint16_t packetid = netdata->packet->getid(); switch (packetid) { case id::client_tologin::kAskLogin: result = ask_login(netdata); break; case id::billing_tologin::kAuth: result = auth(netdata); break; default: break; } return result; __LEAVE_FUNCTION return -1;}
原标题:plain framework 商业版 开发总结1 updated
关键词:
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:
admin#shaoqun.com
(#换成@)。