DragonballHunt.rar

  • valteir
    了解作者
  • Visual C++
    开发工具
  • 1KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 10 积分
    下载积分
  • 0
    下载次数
  • 2021-04-19 06:41
    上传日期
draon ball online server test dragon ball hunt
DragonballHunt.rar
  • DragonballHunt.cpp
    6.2KB
内容介绍
#include "stdafx.h" #include "DragonballHunt.h" #include "GameServer.h" #include "NtlPacketGU.h" #include "NtlAdmin.h" #include "NtlPacketGT.h" #include "NtlStringW.h" #include "Monster.h" CDragonballHunt::CDragonballHunt() { m_dwNextUpdateTick = GetTickCount(); Init(); } CDragonballHunt::~CDragonballHunt() { Destroy(); } void CDragonballHunt::Init() { m_bOnOff = false; m_timeStart = INVALID_DBOTIME; m_timeEnd = INVALID_DBOTIME; m_dwDragonballDropCount = 0; } void CDragonballHunt::Destroy() { } void CDragonballHunt::Create() { } void CDragonballHunt::TickProcess(DWORD dwTick) { if (dwTick < m_dwNextUpdateTick) return; CGameServer* app = (CGameServer*)g_pApp; DBOTIME curTime = app->GetTime(); if (m_bOnOff == false) { tm timeStruct = {}; localtime_s(&timeStruct, &curTime); switch (timeStruct.tm_wday) { case 0: //sunday { if (timeStruct.tm_hour >= 8 && timeStruct.tm_hour <= 11) { m_bOnOff = true; m_timeStart = curTime; tm timeEndStruct = timeStruct; timeEndStruct.tm_sec = 0; timeEndStruct.tm_min = 0; timeEndStruct.tm_hour = 12; m_timeEnd = mktime(&timeEndStruct); StartEvent(false); } } break; case 1: //monday { if (timeStruct.tm_hour >= 12 && timeStruct.tm_hour <= 15) { m_bOnOff = true; m_timeStart = curTime; tm timeEndStruct = timeStruct; timeEndStruct.tm_sec = 0; timeEndStruct.tm_min = 0; timeEndStruct.tm_hour = 16; m_timeEnd = mktime(&timeEndStruct); StartEvent(false); } } break; case 2: //tuesday { if (timeStruct.tm_hour >= 16 && timeStruct.tm_hour <= 19) { m_bOnOff = true; m_timeStart = curTime; tm timeEndStruct = timeStruct; timeEndStruct.tm_sec = 0; timeEndStruct.tm_min = 0; timeEndStruct.tm_hour = 20; m_timeEnd = mktime(&timeEndStruct); StartEvent(false); } } break; case 3: //wednesday { if (timeStruct.tm_hour >= 20 && timeStruct.tm_hour <= 23) { m_bOnOff = true; m_timeStart = curTime; tm timeEndStruct = timeStruct; timeEndStruct.tm_sec = 59; timeEndStruct.tm_min = 59; timeEndStruct.tm_hour = 23; m_timeEnd = mktime(&timeEndStruct); StartEvent(false); } } break; case 5: //friday { if (timeStruct.tm_hour >= 0 && timeStruct.tm_hour <= 3) { m_bOnOff = true; m_timeStart = curTime; tm timeEndStruct = timeStruct; timeEndStruct.tm_sec = 0; timeEndStruct.tm_min = 0; timeEndStruct.tm_hour = 4; m_timeEnd = mktime(&timeEndStruct); StartEvent(false); } } break; case 6: //saturday { if (timeStruct.tm_hour >= 4 && timeStruct.tm_hour <= 7) { m_bOnOff = true; m_timeStart = curTime; tm timeEndStruct = timeStruct; timeEndStruct.tm_sec = 0; timeEndStruct.tm_min = 0; timeEndStruct.tm_hour = 8; m_timeEnd = mktime(&timeEndStruct); StartEvent(false); } } break; default: break; } } else { if (curTime >= m_timeEnd) { EndEvent(); } } m_dwNextUpdateTick = dwTick + 300000; //update again in 5 minutes } void CDragonballHunt::StartEvent(bool bStartByCommand/* = true*/) { if (bStartByCommand) { if (m_bOnOff) return; CGameServer* app = (CGameServer*)g_pApp; m_bOnOff = true; m_timeStart = app->GetTime(); m_timeEnd = m_timeStart + 7200; } ERR_LOG(LOG_GENERAL, "<Dragonball Hunt Event> Start %I64u, End %I64u, Duration in seconds %I64u", m_timeStart, m_timeEnd, m_timeEnd - m_timeStart); CNtlPacket packet(sizeof(sGU_DRAGONBALL_SCHEDULE_INFO)); sGU_DRAGONBALL_SCHEDULE_INFO * res = (sGU_DRAGONBALL_SCHEDULE_INFO *)packet.GetPacketData(); res->wOpCode = GU_DRAGONBALL_SCHEDULE_INFO; res->bIsAlive = true; res->byEventType = SCHEDULE_EVENT_TYPE_EVENT_DRAGONBALL; res->nStartTime = m_timeStart; res->nEndTime = m_timeEnd; g_pObjectManager->SendPacketToAll(&packet); WCHAR* wMsg = L"Dragonball Hunt Event Started!"; CGameServer* app = (CGameServer*)g_pApp; CNtlPacket packetMsg(sizeof(sGT_SYSTEM_DISPLAY_TEXT)); sGT_SYSTEM_DISPLAY_TEXT * resMsg = (sGT_SYSTEM_DISPLAY_TEXT*)packetMsg.GetPacketData(); resMsg->wOpCode = GT_SYSTEM_DISPLAY_TEXT; resMsg->serverChannelId = app->GetGsChannel(); resMsg->byDisplayType = SERVER_TEXT_EMERGENCY; NTL_SAFE_WCSCPY(resMsg->wszMessage, wMsg); packetMsg.SetPacketLen(sizeof(sGT_SYSTEM_DISPLAY_TEXT)); app->SendTo(app->GetChatServerSession(), &packetMsg); } void CDragonballHunt::EndEvent() { if (m_bOnOff == false) return; ERR_LOG(LOG_GENERAL, "<Dragonball Hunt Event> End. Total Dragonballs dropped: %u", m_dwDragonballDropCount); CNtlStringW msg; msg.Format(L"Dragonball Hunt Event End! Dragonballs dropped: %u", m_dwDragonballDropCount); Init(); std::set<HOBJECT>::iterator it; while (m_setMonsters.size() > 0) { it = m_setMonsters.begin(); CMonster* pMob = g_pObjectManager->GetMob(*it); if (pMob) { pMob->ResetDragonball(); } m_setMonsters.erase(it); } CNtlPacket packet(sizeof(sGU_DRAGONBALL_SCHEDULE_INFO)); sGU_DRAGONBALL_SCHEDULE_INFO * res = (sGU_DRAGONBALL_SCHEDULE_INFO *)packet.GetPacketData(); res->wOpCode = GU_DRAGONBALL_SCHEDULE_INFO; res->bIsAlive = false; res->byEventType = SCHEDULE_EVENT_TYPE_EVENT_DRAGONBALL; g_pObjectManager->SendPacketToAll(&packet); CGameServer* app = (CGameServer*)g_pApp; CNtlPacket packetMsg(sizeof(sGT_SYSTEM_DISPLAY_TEXT)); sGT_SYSTEM_DISPLAY_TEXT * resMsg = (sGT_SYSTEM_DISPLAY_TEXT*)packetMsg.GetPacketData(); resMsg->wOpCode = GT_SYSTEM_DISPLAY_TEXT; resMsg->serverChannelId = app->GetGsChannel(); resMsg->byDisplayType = SERVER_TEXT_EMERGENCY; NTL_SAFE_WCSCPY(resMsg->wszMessage, msg.c_str()); packetMsg.SetPacketLen(sizeof(sGT_SYSTEM_DISPLAY_TEXT)); app->SendTo(app->GetChatServerSession(), &packetMsg); } void CDragonballHunt::LoadEvent(CGameObject * pChar) { if (m_bOnOff == false) return; CNtlPacket packet(sizeof(sGU_DRAGONBALL_SCHEDULE_INFO)); sGU_DRAGONBALL_SCHEDULE_INFO * res = (sGU_DRAGONBALL_SCHEDULE_INFO *)packet.GetPacketData(); res->wOpCode = GU_DRAGONBALL_SCHEDULE_INFO; res->bIsAlive = m_bOnOff; res->byEventType = SCHEDULE_EVENT_TYPE_EVENT_DRAGONBALL; res->nStartTime = m_timeStart; res->nEndTime = m_timeEnd; pChar->SendPacket(&packet); }
评论
    相关推荐
    • tp1_cpp
      tp1_cpp // Ecrit par Julien le 22-02:Salut Voici les fichiers .cpp等。 Dans le cas des compositions,作者为n'utilise pas de pointeur。 在目标饮食和非饮食饮食课程中回顾C.est pourquoi。 客观性的建筑...
    • cpp checker
      g++ -o cppcheck -std=c++0x -include lib/cxx11emu.h -lpcre -DHAVE_RULES -Ilib -Iexternals/tinyxml cli/*.cpp lib/*.cpp externals/tinyxml/*.cpp mingw ===== The "LDFLAGS=-lshlwapi" is needed when ...
    • Cpp17CompleteGuide
      ./content/cpp_evoluation_paper其中包含的是c++之父关于c ++演化过程的论文: Thriving in a Crowded and Changing World: C++ 2006–2020 额外说明 本repo并不只对C++17: The Complete Guide 。
    • 算法cpp
      算法cpp
    • Cpp算法
      Cpp算法
    • cpp-demo
      cpp-demo 项目结构 build:存储编译结果,不被源代码管理 src:源代码位置,没有子模块则必须存在 包括:公共头文件,对于不区分公共/私人头文件项目可以不存在,对于有子模块项目可以省略 测试:测试目录 示例:...
    • cpp-algorithm
      算法库(C ++) 设置 1.克隆此存储库 ...$ cp main.template.cpp main.cpp # build main.cpp $ make a.out # execute binary $ ./a.out # bundle `main.cpp` and including libraries for submission (e.g At
    • Autocompiler_CPP
      是一个bash脚本,可以自动编译并运行c ++程序.cpp文件 2021年4月8日v1.0 #名称:autocompile.sh #语法:自动编译[-f文件名]或[-f /目录/文件名] #Description:autocompile是一种功能,它可以自动编译c ++(....
    • CPP11特性概述.zip
      无奈地撒大声地快速机动翻了对方两个到顾客半死不活发动机就
    • cpp1-10.zip
      cpp详细介绍值得参考哦!!!!!!!!!!!!