Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Gunz The Second Duel Asm Functions ! ,, ollydbg

Status
Not open for further replies.
Initiate Mage
Joined
Jan 1, 2010
Messages
1
Reaction score
0
Code:
TEST (SectorChat)
{ (
GUTHelper helper;      // 유닛 테스트를 도와주는 유틸 함수가 모아져 있는 클래스입니다. GUTHelper helper; / / unit tests to help condense is a class of utility functions.
MockMap* pMap = helper.DefaultMockMap();  // 가상의 맵을 만듭니다. MockMap * pMap = helper.DefaultMockMap (); / / creates a virtual map.


GEntityPlayer* pPlayer1 = helper.NewEntityPlayer(pMap, vec3(1000,1000,0));  // 플레이어1을 맵에 생성시킵니다. GEntityPlayer * pPlayer1 = helper.NewEntityPlayer (pMap, vec3 (1000,1000,0)); / / player 1 causes the generated map.
MockLink* pLink1 = helper.NewLink(pPlayer1);    // 플레이어1 객체와 클라이언트 연결 객체를 연결시킵니다. MockLink * pLink1 = helper.NewLink (pPlayer1); / / player 1 causes the connection object and the client connection object.

GEntityPlayer* pPlayer2 = helper.NewEntityPlayer(pMap, vec3(1000,1000,0)); GEntityPlayer * pPlayer2 = helper.NewEntityPlayer (pMap, vec3 (1000,1000,0));
MockLink* pLink2 = helper.NewLink(pPlayer2); MockLink * pLink2 = helper.NewLink (pPlayer2);


// 플레이어1 클라이언트로부터 패킷을 받는 부분입니다. / / Player 1 receives packets from the client is a part. 실제로 이 OnRecv함수 안에서 받은 패킷에 대한 모든 처리를 하게 됩니다. In fact, for all OnRecv function in the processing of the received packet will be.

// 그래서 이 곳에서 플레이어로부터 채팅 메세지를 받아서 주위 플레이어들에게 똑같은 메세지를 전달해 주게 됩니다. / / So this place takes the player from the chat messages to players around to give the same message is delivered.
pLink1->OnRecv(MC_MSG_SECTOR_REQ, 1, NEW_STR("Hi! Hello World~")); pLink1-> OnRecv (MC_MSG_SECTOR_REQ, 1, NEW_STR ( "Hi! Hello World ~"));


CHECK(pLink2->GetPacketCount() == 1);    // 플레이어2 클라이언트에게 패킷이 하나 날라갔는지 체크합니다. CHECK (pLink2-> GetPacketCount () == 1); / / Player 2 1 Gone to the client whether the packet is checked. 저희는 패킷 한 단위를 커맨드라고 부릅니다. We command a single unit called a packet. :) :)
CHECK(pLink2->GetPacket(0).GetID() == MC_MSG_SECTOR);  // 플레이어2에게 보낸 첫번째 패킷이 채팅 메세지 패킷인지 체크합니다. CHECK (pLink2-> GetPacket (0). GetID () == MC_MSG_SECTOR); / / Player 2 sent a chat message packet is the first packet is checked.

const char* szMsg = pLink2->GetParam<const char*>(0, 1); const char * szMsg = pLink2-> GetParam <const char*> (0, 1);
CHECK(!strcmp(szMsg, "Hi! Hello World~"));  // 실제로 플레이어1이 보낸 메세지와 같은 메세지가 날라갔는지 확인합니다. CHECK (! Strcmp (szMsg, "Hi! Hello World ~")); / / In fact, player 1 has sent you a message, such as Gone verify.

pMap->Destroy(); pMap-> Destroy ();
helper.ClearLinks(); helper.ClearLinks ();
} )


○ 캐스팅 시간이 없는 스킬을 쓸 때 스킬 상태를 체크하는 테스트 코드입니다. ○ When writing skills do not have time to cast the skill to check the status of the test code.
TEST(TestSkillPhaseCheck_WhenCastingTimeIsZero) TEST (TestSkillPhaseCheck_WhenCastingTimeIsZero)
{ (
GUTHelper helper; GUTHelper helper;

GSkillInfo skill_info; GSkillInfo skill_info;
helper.SetMagicMissileSkillInfo(&skill_info, 1); helper.SetMagicMissileSkillInfo (& skill_info, 1);
skill_info.m_fCastingTime = 0.0f; skill_info.m_fCastingTime = 0.0f;

float fElapsedTime = 0.0f; float fElapsedTime = 0.0f;
MockEntityNPC npc; MockEntityNPC npc;
npc.Create(GUnitTestUtil::NewUID()); npc.Create (GUnitTestUtil:: NewUID ());

GMagicSkill magic_talent(&npc, &skill_info); GMagicSkill magic_talent (& npc, & skill_info);
magic_skill.Start(); magic_skill.Start ();
magic_skill.Update(0.1f); magic_skill.Update (0.1f);

CHECK_EQUAL(magic_skill.GetPhase(), SKILL_PHASE_RUNNING); CHECK_EQUAL (magic_skill.GetPhase (), SKILL_PHASE_RUNNING);
} )

○ 이건 파티에 가입했는지 확인하는 테스트 코드입니다. ○ Make sure to sign up for this party is the test code. 좀 더 복잡하네요. More Complicated. :) :)

// 파티 관련 테스트에서 공통으로 사용하는 Fixture입니다. / / Party-related testing is commonly used in the Fixture.

// 파티 관련 테스트를 시작할 때 자동으로 Fixture의 생성자를 불러 테스트에 필요한 초기화 등을 해주고, 테스트가 끝나면 소멸자를 불러 테스트에 필요한 자원 해제 등을 하게됩니다. / / Party-related Test Fixture automatically when you start to call the constructor of the test and give necessary initialization, tests are done to call the destructor, and will release the resources needed for testing.

struct Fixture struct Fixture
{ (
Fixture() Fixture ()
{ (

         // 테스트용 파티 로직을 담당하는 시스템, 파티 인스턴스를 관리하는 매니저를 할당 받습니다. / / Test logic that is responsible for the party system, parties will be assigned a manager to manage the instance.
m_pPartySystem = m_PartySystemWrapper.Get(); m_pPartySystem = m_PartySystemWrapper.Get ();
m_pPartyManager = m_PartyManagerWrapper.Get(); m_pPartyManager = m_PartyManagerWrapper.Get ();


party.SetUID(MUID(1000, 0)); party.SetUID (MUID (1000, 0));
uidPlayer1.Value = 101; uidPlayer1.Value = 101;
uidPlayer2.Value = 102; uidPlayer2.Value = 102;
uidPlayer3.Value = 103; uidPlayer3.Value = 103;
pPlayerObject1 = CreateTestPlayerObject(uidPlayer1); pPlayerObject1 = CreateTestPlayerObject (uidPlayer1);
pPlayerObject2 = CreateTestPlayerObject(uidPlayer2); pPlayerObject2 = CreateTestPlayerObject (uidPlayer2);
pPlayerObject3 = CreateTestPlayerObject(uidPlayer3); pPlayerObject3 = CreateTestPlayerObject (uidPlayer3);
pPlayer1 = pPlayerObject1->GetMockEntity(); pPlayer1 = pPlayerObject1-> GetMockEntity ();
pPlayer2 = pPlayerObject2->GetMockEntity(); pPlayer2 = pPlayerObject2-> GetMockEntity ();
pPlayer3 = pPlayerObject3->GetMockEntity(); pPlayer3 = pPlayerObject3-> GetMockEntity ();

gmgr.pPlayerObjectManager->AddPlayer(pPlayerObject1); gmgr.pPlayerObjectManager-> AddPlayer (pPlayerObject1);
gmgr.pPlayerObjectManager->AddPlayer(pPlayerObject2); gmgr.pPlayerObjectManager-> AddPlayer (pPlayerObject2);
gmgr.pPlayerObjectManager->AddPlayer(pPlayerObject3); gmgr.pPlayerObjectManager-> AddPlayer (pPlayerObject3);

nOldPartyMemberCounter = GConst::PARTY_LIMIT_MEMBER_COUNTER; nOldPartyMemberCounter = GConst:: PARTY_LIMIT_MEMBER_COUNTER;

m_pPartyManager->Clear(); m_pPartyManager-> Clear ();
} )

~Fixture() ~ Fixture ()
{ (
gmgr.pPlayerObjectManager->DeletePlayer(pPlayerObject3->GetUID()); gmgr.pPlayerObjectManager-> DeletePlayer (pPlayerObject3-> GetUID ());
gmgr.pPlayerObjectManager->DeletePlayer(pPlayerObject2->GetUID()); gmgr.pPlayerObjectManager-> DeletePlayer (pPlayerObject2-> GetUID ());
gmgr.pPlayerObjectManager->DeletePlayer(pPlayerObject1->GetUID()); gmgr.pPlayerObjectManager-> DeletePlayer (pPlayerObject1-> GetUID ());
GConst::PARTY_LIMIT_MEMBER_COUNTER = nOldPartyMemberCounter; GConst:: PARTY_LIMIT_MEMBER_COUNTER = nOldPartyMemberCounter;
} )

MockPlayerObject* CreateTestPlayerObject(MUID& uid) MockPlayerObject * CreateTestPlayerObject (MUID & uid)
{ (
MockPlayerObject* p = new MockPlayerObject(uid); MockPlayerObject * p = new MockPlayerObject (uid);
p->Create(); p-> Create ();
return p; return p;
} )

void SetPlayerName__Player1_And_Player2_IsSame() void SetPlayerName__Player1_And_Player2_IsSame ()
{ (
const char* pszPlayer1Name = "pPlayer1"; const char * pszPlayer1Name = "pPlayer1";
const char* pszPlayer3Name = "OtherPlayer3"; const char * pszPlayer3Name = "OtherPlayer3";
strcpy_s(pPlayer1->GetPlayerInfo()->szName, pszPlayer1Name); strcpy_s (pPlayer1-> GetPlayerInfo () -> szName, pszPlayer1Name);
strcpy_s(pPlayer2->GetPlayerInfo()->szName, pszPlayer1Name);    // Reconnected Player #1 strcpy_s (pPlayer2-> GetPlayerInfo () -> szName, pszPlayer1Name); / / Reconnected Player # 1
strcpy_s(pPlayer3->GetPlayerInfo()->szName, pszPlayer3Name); strcpy_s (pPlayer3-> GetPlayerInfo () -> szName, pszPlayer3Name);
} )

GUTHelper        m_Helper; GUTHelper m_Helper;
GParty party;  // 파티 인스턴스를 미리 할당해 놓습니다. GParty party; / / assign pre-release party for instance.
GTestSysWrapper2<GPartySystem, TestPartySystem>        m_PartySystemWrapper;  // 전역적으로 사용하는 시스템 객체를 테스트용 객체로 바꿉니다. GTestSysWrapper2 <GPartySystem, TestPartySystem> m_PartySystemWrapper; / / using the global system as a test object replaces the object.
GTestMgrWrapper2<GPartyManager, TestPartyManager>    m_PartyManagerWrapper; // 전역적으로 사용하는 매니저 객체를 테스트용 객체로 바꿉니다. GTestMgrWrapper2 <GPartyManager, TestPartyManager> m_PartyManagerWrapper; / / Global object to the test object is used to replace the manager.
TestPartySystem*    m_pPartySystem; TestPartySystem * m_pPartySystem;
TestPartyManager*    m_pPartyManager; TestPartyManager * m_pPartyManager;

MockEntityPlayer* pPlayer1; MockEntityPlayer * pPlayer1;
MockEntityPlayer* pPlayer2; MockEntityPlayer * pPlayer2;
MockEntityPlayer* pPlayer3; MockEntityPlayer * pPlayer3;
MockPlayerObject* pPlayerObject1; MockPlayerObject * pPlayerObject1;
MockPlayerObject* pPlayerObject2; MockPlayerObject * pPlayerObject2;
MockPlayerObject* pPlayerObject3; MockPlayerObject * pPlayerObject3;
MUID    uidPlayer1;  // MUID는 유니크 아이디입니다. MUID uidPlayer1; / / MUID a unique ID. int64 int64
MUID    uidPlayer2; MUID uidPlayer2;
MUID    uidPlayer3; MUID uidPlayer3;
int        nOldPartyMemberCounter; int nOldPartyMemberCounter;
}; );

// 파티 가입을 테스트하는 코드입니다. / / The code is tested to join the party.

TEST_FIXTURE(Fixture, JoinParty) TEST_FIXTURE (Fixture, JoinParty)
{ (

// 플레이어 1을 파티장으로 파티를 만듭니다. / / Player 1 creates a party to the party. 실제로 성공했는지 테스트합니다. In fact, the test was successful.
CHECK_EQUAL(m_pPartySystem->CreateParty(pPlayer1), CR_SUCCESS); CHECK_EQUAL (m_pPartySystem-> CreateParty (pPlayer1), CR_SUCCESS);


// 플레이어2를 가입시키는 것을 테스트합니다. / / Player 2 to join that test.
CHECK_EQUAL(m_pPartySystem->Join(pPlayer1, pPlayer2), CR_SUCCESS); CHECK_EQUAL (m_pPartySystem-> Join (pPlayer1, pPlayer2), CR_SUCCESS);


// 자기 자신은 가입시키지 못하는 것을 테스트합니다. / / Do not own up to the test.
CHECK_EQUAL(m_pPartySystem->Join(pPlayer1, pPlayer1), CR_FAIL_PARTY_NOT_INVITE_SELF);    // 자기 자신을 초대할 수 없다. CHECK_EQUAL (m_pPartySystem-> Join (pPlayer1, pPlayer1), CR_FAIL_PARTY_NOT_INVITE_SELF); / / You can not invite yourself.


CHECK_EQUAL(m_pPartySystem->Join(pPlayer1, pPlayer2), CR_FAIL_PARTY_TARGET_ALEADY_HAS_PARTY);    // 이미 초대한 파티원을 또 초대할 수 없다. CHECK_EQUAL (m_pPartySystem-> Join (pPlayer1, pPlayer2), CR_FAIL_PARTY_TARGET_ALEADY_HAS_PARTY); / / already invited to the party members can not invite them.
CHECK_EQUAL(pPlayer2->HasParty(), true); CHECK_EQUAL (pPlayer2-> HasParty (), true);
} )


○ 이건 간단한 수학 함수를 테스트하는 코드입니다. ○ It is a simple mathematical function to test the code.

TEST(TestMathFunctionTruncateToInt) TEST (TestMathFunctionTruncateToInt)
{ (
CHECK_EQUAL(GMath::TruncateToInt(0.0), 0); CHECK_EQUAL (GMath:: TruncateToInt (0.0), 0);
CHECK_EQUAL(GMath::TruncateToInt(5.6), 5); CHECK_EQUAL (GMath:: TruncateToInt (5.6), 5);
CHECK_EQUAL(GMath::TruncateToInt(13.2), 13); CHECK_EQUAL (GMath:: TruncateToInt (13.2), 13);
CHECK_EQUAL(GMath::TruncateToInt(13.2), 13); CHECK_EQUAL (GMath:: TruncateToInt (13.2), 13);
CHECK_EQUAL(GMath::TruncateToInt(-5.6), -6); CHECK_EQUAL (GMath:: TruncateToInt (-5.6), -6);
CHECK_EQUAL(GMath::TruncateToInt(-2.1), -3); CHECK_EQUAL (GMath:: TruncateToInt (-2.1), -3);
CHECK_EQUAL(GMath::TruncateToInt(-2.0), -2); CHECK_EQUAL (GMath:: TruncateToInt (-2.0), -2);
CHECK_EQUAL(GMath::TruncateToInt(-2585858.0), -2585858); CHECK_EQUAL (GMath:: TruncateToInt (-2585858.0), -2585858);
CHECK_EQUAL(GMath::TruncateToInt(-2533858.12312), -2533859); CHECK_EQUAL (GMath:: TruncateToInt (-2533858.12312), -2533859);
} )

// 경험치 테스트입니다. / / Experience is a test.

TEST(TestCalcLevelFromExp) TEST (TestCalcLevelFromExp)
{ (
CHECK_EQUAL(GCalculator::CalcLevelFromExp(4550, 1), 1); CHECK_EQUAL (GCalculator:: CalcLevelFromExp (4550, 1), 1);
CHECK_EQUAL(GCalculator::CalcLevelFromExp(7510, 1), 2); CHECK_EQUAL (GCalculator:: CalcLevelFromExp (7510, 1), 2);
CHECK_EQUAL(GCalculator::CalcLevelFromExp(10500, 1), 3); CHECK_EQUAL (GCalculator:: CalcLevelFromExp (10500, 1), 3);

GLevelTable lt; GLevelTable lt;
int64 exp = lt.GetRequiredTotalXP(18) - 1; int64 exp = lt.GetRequiredTotalXP (18) - 1;
CHECK_EQUAL(GCalculator::CalcLevelFromExp(exp, 1), 18); CHECK_EQUAL (GCalculator:: CalcLevelFromExp (exp, 1), 18);
CHECK_EQUAL(GCalculator::CalcLevelFromExp(exp, 32), 32); CHECK_EQUAL (GCalculator:: CalcLevelFromExp (exp, 32), 32);
} )


○ 이건 클라이언트에서 처음 맵에 접속했을 때 주위 NPC들의 애니메이션 상태를 체크하는 테스트 코드입니다. ○ This is when the client first connected around the NPC's map animation tests to check the status code.


TEST_FIXTURE(SimpleTestFixture, NPCAnimationCheckWhenEntry) TEST_FIXTURE (SimpleTestFixture, NPCAnimationCheckWhenEntry)
{ (
int nNPCID = 1; int nNPCID = 1;
vec3 vPos = vec3(1000.0f, 1000.0f, 0.0f); vec3 vPos = vec3 (1000.0f, 1000.0f, 0.0f);
MUID uidNPC = global.system->GenerateLocalUID(); MUID uidNPC = global.system-> GenerateLocalUID ();

// 서버로부터 받은 NPC 정보입니다. / / Server is the information received from the NPC.
TD_UPDATE_CACHE_NPC td_update_cache_npc; TD_UPDATE_CACHE_NPC td_update_cache_npc;
td_update_cache_npc.uid = uidNPC; td_update_cache_npc.uid = uidNPC;

td_update_cache_npc.nStatusFlag = 0; td_update_cache_npc.nStatusFlag = 0;
td_update_cache_npc.nNPCID = nNPCID; td_update_cache_npc.nNPCID = nNPCID;
td_update_cache_npc.vPos = vPos; td_update_cache_npc.vPos = vPos;

// 여기서 서버로부터 NPC 정보를 받게 됩니다. / / Where the server will receive information from the NPC.
m_Helper.InNPCs(&td_update_cache_npc, 1, &m_NPCAniDataSet); m_Helper.InNPCs (& td_update_cache_npc, 1, & m_NPCAniDataSet);


// 인스턴스 매니저에 실제로 NPC인스턴스가 생겼는지 테스트합니다. / / Instance, the manager actually looks like an instance to test the NPC.
XNonPlayer* pNPC = gg.omgr->FindNPC(uidNPC); XNonPlayer * pNPC = gg.omgr-> FindNPC (uidNPC);
CHECK(pNPC != NULL); CHECK (pNPC! = NULL);

if (pNPC == NULL) return; if (pNPC == NULL) return;


// nStatusFlag에 아무값이 없으므로 가만히 서있는 idle 애니메이션인지 테스트합니다. / / NStatusFlag no value because the animation is still standing idle test.
CHECK_EQUAL(pNPC->GetCurrMotion(), string(MOTION_NAME_NPC_IDLE)); CHECK_EQUAL (pNPC-> GetCurrMotion (), string (MOTION_NAME_NPC_IDLE));

gg.game->Update(0.1f); gg.game-> Update (0.1f);


// 틱이 지난 후에도 계속 idle 애니메이션인지 테스트합니다. / / Tikyi still idle after the animation is the last test.
CHECK_EQUAL(pNPC->GetCurrMotion(), string(MOTION_NAME_NPC_IDLE)); CHECK_EQUAL (pNPC-> GetCurrMotion (), string (MOTION_NAME_NPC_IDLE));

// 달리는 상태 ------------ / / Running Status ------------
uidNPC = global.system->GenerateLocalUID(); uidNPC = global.system-> GenerateLocalUID ();

td_update_cache_npc.uid = uidNPC; td_update_cache_npc.uid = uidNPC;
td_update_cache_npc.nStatusFlag = UNS_RUN;        // 달리는 상태 td_update_cache_npc.nStatusFlag = UNS_RUN; / / Running Status
td_update_cache_npc.fSpeed = 100.0f; td_update_cache_npc.fSpeed = 100.0f;
td_update_cache_npc.vTarPos = vec3(0.0f, 0.0f, 0.0f); td_update_cache_npc.vTarPos = vec3 (0.0f, 0.0f, 0.0f);

m_Helper.InNPCs(&td_update_cache_npc, 1, &m_NPCAniDataSet); m_Helper.InNPCs (& td_update_cache_npc, 1, & m_NPCAniDataSet);
gg.game->Update(0.1f); gg.game-> Update (0.1f);

pNPC = gg.omgr->FindNPC(uidNPC); pNPC = gg.omgr-> FindNPC (uidNPC);
CHECK(pNPC != NULL); CHECK (pNPC! = NULL);
if (pNPC == NULL) return; if (pNPC == NULL) return;

// 달리는 중이므로 run 모션 테스트 / / Motion test run because it is being run
CHECK_EQUAL(pNPC->GetCurrMotion(), string(MOTION_NAME_NPC_RUN)); CHECK_EQUAL (pNPC-> GetCurrMotion (), string (MOTION_NAME_NPC_RUN));

// 걷는 상태 ------------ / / Walk Status ------------
uidNPC = global.system->GenerateLocalUID(); uidNPC = global.system-> GenerateLocalUID ();

td_update_cache_npc.uid = uidNPC; td_update_cache_npc.uid = uidNPC;
td_update_cache_npc.nStatusFlag = UNS_WALK;        // 걷는 상태 td_update_cache_npc.nStatusFlag = UNS_WALK; / / walking conditions
td_update_cache_npc.fSpeed = 100.0f; td_update_cache_npc.fSpeed = 100.0f;
td_update_cache_npc.vTarPos = vec3(0.0f, 0.0f, 0.0f); td_update_cache_npc.vTarPos = vec3 (0.0f, 0.0f, 0.0f);

m_Helper.InNPCs(&td_update_cache_npc, 1, &m_NPCAniDataSet); m_Helper.InNPCs (& td_update_cache_npc, 1, & m_NPCAniDataSet);
gg.game->Update(0.1f); gg.game-> Update (0.1f);

pNPC = gg.omgr->FindNPC(uidNPC); pNPC = gg.omgr-> FindNPC (uidNPC);
CHECK(pNPC != NULL); CHECK (pNPC! = NULL);
if (pNPC == NULL) return; if (pNPC == NULL) return;


// 걷는 중이므로 walk 모션 / / Walk Because walking motion
CHECK_EQUAL(pNPC->GetCurrMotion(), string(MOTION_NAME_NPC_WALK)); CHECK_EQUAL (pNPC-> GetCurrMotion (), string (MOTION_NAME_NPC_WALK));
} )

Thanks me if i help !

Proofs
_________________
/***** OWNED ****\
------------------


 
Last edited:
Skilled Illusionist
Joined
Jul 19, 2008
Messages
306
Reaction score
11
Code:
TEST (SectorChat)
{ (
GUTHelper helper;      // 유닛 테스트를 도와주는 유틸 함수가 모아져 있는 클래스입니다. GUTHelper helper; / / unit tests to help condense is a class of utility functions.
MockMap* pMap = helper.DefaultMockMap();  // 가상의 맵을 만듭니다. MockMap * pMap = helper.DefaultMockMap (); / / creates a virtual map.


GEntityPlayer* pPlayer1 = helper.NewEntityPlayer(pMap, vec3(1000,1000,0));  // 플레이어1을 맵에 생성시킵니다. GEntityPlayer * pPlayer1 = helper.NewEntityPlayer (pMap, vec3 (1000,1000,0)); / / player 1 causes the generated map.
MockLink* pLink1 = helper.NewLink(pPlayer1);    // 플레이어1 객체와 클라이언트 연결 객체를 연결시킵니다. MockLink * pLink1 = helper.NewLink (pPlayer1); / / player 1 causes the connection object and the client connection object.

GEntityPlayer* pPlayer2 = helper.NewEntityPlayer(pMap, vec3(1000,1000,0)); GEntityPlayer * pPlayer2 = helper.NewEntityPlayer (pMap, vec3 (1000,1000,0));
MockLink* pLink2 = helper.NewLink(pPlayer2); MockLink * pLink2 = helper.NewLink (pPlayer2);


// 플레이어1 클라이언트로부터 패킷을 받는 부분입니다. / / Player 1 receives packets from the client is a part. 실제로 이 OnRecv함수 안에서 받은 패킷에 대한 모든 처리를 하게 됩니다. In fact, for all OnRecv function in the processing of the received packet will be.

// 그래서 이 곳에서 플레이어로부터 채팅 메세지를 받아서 주위 플레이어들에게 똑같은 메세지를 전달해 주게 됩니다. / / So this place takes the player from the chat messages to players around to give the same message is delivered.
pLink1->OnRecv(MC_MSG_SECTOR_REQ, 1, NEW_STR("Hi! Hello World~")); pLink1-> OnRecv (MC_MSG_SECTOR_REQ, 1, NEW_STR ( "Hi! Hello World ~"));


CHECK(pLink2->GetPacketCount() == 1);    // 플레이어2 클라이언트에게 패킷이 하나 날라갔는지 체크합니다. CHECK (pLink2-> GetPacketCount () == 1); / / Player 2 1 Gone to the client whether the packet is checked. 저희는 패킷 한 단위를 커맨드라고 부릅니다. We command a single unit called a packet. :) :)
CHECK(pLink2->GetPacket(0).GetID() == MC_MSG_SECTOR);  // 플레이어2에게 보낸 첫번째 패킷이 채팅 메세지 패킷인지 체크합니다. CHECK (pLink2-> GetPacket (0). GetID () == MC_MSG_SECTOR); / / Player 2 sent a chat message packet is the first packet is checked.

const char* szMsg = pLink2->GetParam<const char*>(0, 1); const char * szMsg = pLink2-> GetParam <const char*> (0, 1);
CHECK(!strcmp(szMsg, "Hi! Hello World~"));  // 실제로 플레이어1이 보낸 메세지와 같은 메세지가 날라갔는지 확인합니다. CHECK (! Strcmp (szMsg, "Hi! Hello World ~")); / / In fact, player 1 has sent you a message, such as Gone verify.

pMap->Destroy(); pMap-> Destroy ();
helper.ClearLinks(); helper.ClearLinks ();
} )


○ 캐스팅 시간이 없는 스킬을 쓸 때 스킬 상태를 체크하는 테스트 코드입니다. ○ When writing skills do not have time to cast the skill to check the status of the test code.
TEST(TestSkillPhaseCheck_WhenCastingTimeIsZero) TEST (TestSkillPhaseCheck_WhenCastingTimeIsZero)
{ (
GUTHelper helper; GUTHelper helper;

GSkillInfo skill_info; GSkillInfo skill_info;
helper.SetMagicMissileSkillInfo(&skill_info, 1); helper.SetMagicMissileSkillInfo (& skill_info, 1);
skill_info.m_fCastingTime = 0.0f; skill_info.m_fCastingTime = 0.0f;

float fElapsedTime = 0.0f; float fElapsedTime = 0.0f;
MockEntityNPC npc; MockEntityNPC npc;
npc.Create(GUnitTestUtil::NewUID()); npc.Create (GUnitTestUtil:: NewUID ());

GMagicSkill magic_talent(&npc, &skill_info); GMagicSkill magic_talent (& npc, & skill_info);
magic_skill.Start(); magic_skill.Start ();
magic_skill.Update(0.1f); magic_skill.Update (0.1f);

CHECK_EQUAL(magic_skill.GetPhase(), SKILL_PHASE_RUNNING); CHECK_EQUAL (magic_skill.GetPhase (), SKILL_PHASE_RUNNING);
} )

○ 이건 파티에 가입했는지 확인하는 테스트 코드입니다. ○ Make sure to sign up for this party is the test code. 좀 더 복잡하네요. More Complicated. :) :)

// 파티 관련 테스트에서 공통으로 사용하는 Fixture입니다. / / Party-related testing is commonly used in the Fixture.

// 파티 관련 테스트를 시작할 때 자동으로 Fixture의 생성자를 불러 테스트에 필요한 초기화 등을 해주고, 테스트가 끝나면 소멸자를 불러 테스트에 필요한 자원 해제 등을 하게됩니다. / / Party-related Test Fixture automatically when you start to call the constructor of the test and give necessary initialization, tests are done to call the destructor, and will release the resources needed for testing.

struct Fixture struct Fixture
{ (
Fixture() Fixture ()
{ (

         // 테스트용 파티 로직을 담당하는 시스템, 파티 인스턴스를 관리하는 매니저를 할당 받습니다. / / Test logic that is responsible for the party system, parties will be assigned a manager to manage the instance.
m_pPartySystem = m_PartySystemWrapper.Get(); m_pPartySystem = m_PartySystemWrapper.Get ();
m_pPartyManager = m_PartyManagerWrapper.Get(); m_pPartyManager = m_PartyManagerWrapper.Get ();


party.SetUID(MUID(1000, 0)); party.SetUID (MUID (1000, 0));
uidPlayer1.Value = 101; uidPlayer1.Value = 101;
uidPlayer2.Value = 102; uidPlayer2.Value = 102;
uidPlayer3.Value = 103; uidPlayer3.Value = 103;
pPlayerObject1 = CreateTestPlayerObject(uidPlayer1); pPlayerObject1 = CreateTestPlayerObject (uidPlayer1);
pPlayerObject2 = CreateTestPlayerObject(uidPlayer2); pPlayerObject2 = CreateTestPlayerObject (uidPlayer2);
pPlayerObject3 = CreateTestPlayerObject(uidPlayer3); pPlayerObject3 = CreateTestPlayerObject (uidPlayer3);
pPlayer1 = pPlayerObject1->GetMockEntity(); pPlayer1 = pPlayerObject1-> GetMockEntity ();
pPlayer2 = pPlayerObject2->GetMockEntity(); pPlayer2 = pPlayerObject2-> GetMockEntity ();
pPlayer3 = pPlayerObject3->GetMockEntity(); pPlayer3 = pPlayerObject3-> GetMockEntity ();

gmgr.pPlayerObjectManager->AddPlayer(pPlayerObject1); gmgr.pPlayerObjectManager-> AddPlayer (pPlayerObject1);
gmgr.pPlayerObjectManager->AddPlayer(pPlayerObject2); gmgr.pPlayerObjectManager-> AddPlayer (pPlayerObject2);
gmgr.pPlayerObjectManager->AddPlayer(pPlayerObject3); gmgr.pPlayerObjectManager-> AddPlayer (pPlayerObject3);

nOldPartyMemberCounter = GConst::PARTY_LIMIT_MEMBER_COUNTER; nOldPartyMemberCounter = GConst:: PARTY_LIMIT_MEMBER_COUNTER;

m_pPartyManager->Clear(); m_pPartyManager-> Clear ();
} )

~Fixture() ~ Fixture ()
{ (
gmgr.pPlayerObjectManager->DeletePlayer(pPlayerObject3->GetUID()); gmgr.pPlayerObjectManager-> DeletePlayer (pPlayerObject3-> GetUID ());
gmgr.pPlayerObjectManager->DeletePlayer(pPlayerObject2->GetUID()); gmgr.pPlayerObjectManager-> DeletePlayer (pPlayerObject2-> GetUID ());
gmgr.pPlayerObjectManager->DeletePlayer(pPlayerObject1->GetUID()); gmgr.pPlayerObjectManager-> DeletePlayer (pPlayerObject1-> GetUID ());
GConst::PARTY_LIMIT_MEMBER_COUNTER = nOldPartyMemberCounter; GConst:: PARTY_LIMIT_MEMBER_COUNTER = nOldPartyMemberCounter;
} )

MockPlayerObject* CreateTestPlayerObject(MUID& uid) MockPlayerObject * CreateTestPlayerObject (MUID & uid)
{ (
MockPlayerObject* p = new MockPlayerObject(uid); MockPlayerObject * p = new MockPlayerObject (uid);
p->Create(); p-> Create ();
return p; return p;
} )

void SetPlayerName__Player1_And_Player2_IsSame() void SetPlayerName__Player1_And_Player2_IsSame ()
{ (
const char* pszPlayer1Name = "pPlayer1"; const char * pszPlayer1Name = "pPlayer1";
const char* pszPlayer3Name = "OtherPlayer3"; const char * pszPlayer3Name = "OtherPlayer3";
strcpy_s(pPlayer1->GetPlayerInfo()->szName, pszPlayer1Name); strcpy_s (pPlayer1-> GetPlayerInfo () -> szName, pszPlayer1Name);
strcpy_s(pPlayer2->GetPlayerInfo()->szName, pszPlayer1Name);    // Reconnected Player #1 strcpy_s (pPlayer2-> GetPlayerInfo () -> szName, pszPlayer1Name); / / Reconnected Player # 1
strcpy_s(pPlayer3->GetPlayerInfo()->szName, pszPlayer3Name); strcpy_s (pPlayer3-> GetPlayerInfo () -> szName, pszPlayer3Name);
} )

GUTHelper        m_Helper; GUTHelper m_Helper;
GParty party;  // 파티 인스턴스를 미리 할당해 놓습니다. GParty party; / / assign pre-release party for instance.
GTestSysWrapper2<GPartySystem, TestPartySystem>        m_PartySystemWrapper;  // 전역적으로 사용하는 시스템 객체를 테스트용 객체로 바꿉니다. GTestSysWrapper2 <GPartySystem, TestPartySystem> m_PartySystemWrapper; / / using the global system as a test object replaces the object.
GTestMgrWrapper2<GPartyManager, TestPartyManager>    m_PartyManagerWrapper; // 전역적으로 사용하는 매니저 객체를 테스트용 객체로 바꿉니다. GTestMgrWrapper2 <GPartyManager, TestPartyManager> m_PartyManagerWrapper; / / Global object to the test object is used to replace the manager.
TestPartySystem*    m_pPartySystem; TestPartySystem * m_pPartySystem;
TestPartyManager*    m_pPartyManager; TestPartyManager * m_pPartyManager;

MockEntityPlayer* pPlayer1; MockEntityPlayer * pPlayer1;
MockEntityPlayer* pPlayer2; MockEntityPlayer * pPlayer2;
MockEntityPlayer* pPlayer3; MockEntityPlayer * pPlayer3;
MockPlayerObject* pPlayerObject1; MockPlayerObject * pPlayerObject1;
MockPlayerObject* pPlayerObject2; MockPlayerObject * pPlayerObject2;
MockPlayerObject* pPlayerObject3; MockPlayerObject * pPlayerObject3;
MUID    uidPlayer1;  // MUID는 유니크 아이디입니다. MUID uidPlayer1; / / MUID a unique ID. int64 int64
MUID    uidPlayer2; MUID uidPlayer2;
MUID    uidPlayer3; MUID uidPlayer3;
int        nOldPartyMemberCounter; int nOldPartyMemberCounter;
}; );

// 파티 가입을 테스트하는 코드입니다. / / The code is tested to join the party.

TEST_FIXTURE(Fixture, JoinParty) TEST_FIXTURE (Fixture, JoinParty)
{ (

// 플레이어 1을 파티장으로 파티를 만듭니다. / / Player 1 creates a party to the party. 실제로 성공했는지 테스트합니다. In fact, the test was successful.
CHECK_EQUAL(m_pPartySystem->CreateParty(pPlayer1), CR_SUCCESS); CHECK_EQUAL (m_pPartySystem-> CreateParty (pPlayer1), CR_SUCCESS);


// 플레이어2를 가입시키는 것을 테스트합니다. / / Player 2 to join that test.
CHECK_EQUAL(m_pPartySystem->Join(pPlayer1, pPlayer2), CR_SUCCESS); CHECK_EQUAL (m_pPartySystem-> Join (pPlayer1, pPlayer2), CR_SUCCESS);


// 자기 자신은 가입시키지 못하는 것을 테스트합니다. / / Do not own up to the test.
CHECK_EQUAL(m_pPartySystem->Join(pPlayer1, pPlayer1), CR_FAIL_PARTY_NOT_INVITE_SELF);    // 자기 자신을 초대할 수 없다. CHECK_EQUAL (m_pPartySystem-> Join (pPlayer1, pPlayer1), CR_FAIL_PARTY_NOT_INVITE_SELF); / / You can not invite yourself.


CHECK_EQUAL(m_pPartySystem->Join(pPlayer1, pPlayer2), CR_FAIL_PARTY_TARGET_ALEADY_HAS_PARTY);    // 이미 초대한 파티원을 또 초대할 수 없다. CHECK_EQUAL (m_pPartySystem-> Join (pPlayer1, pPlayer2), CR_FAIL_PARTY_TARGET_ALEADY_HAS_PARTY); / / already invited to the party members can not invite them.
CHECK_EQUAL(pPlayer2->HasParty(), true); CHECK_EQUAL (pPlayer2-> HasParty (), true);
} )


○ 이건 간단한 수학 함수를 테스트하는 코드입니다. ○ It is a simple mathematical function to test the code.

TEST(TestMathFunctionTruncateToInt) TEST (TestMathFunctionTruncateToInt)
{ (
CHECK_EQUAL(GMath::TruncateToInt(0.0), 0); CHECK_EQUAL (GMath:: TruncateToInt (0.0), 0);
CHECK_EQUAL(GMath::TruncateToInt(5.6), 5); CHECK_EQUAL (GMath:: TruncateToInt (5.6), 5);
CHECK_EQUAL(GMath::TruncateToInt(13.2), 13); CHECK_EQUAL (GMath:: TruncateToInt (13.2), 13);
CHECK_EQUAL(GMath::TruncateToInt(13.2), 13); CHECK_EQUAL (GMath:: TruncateToInt (13.2), 13);
CHECK_EQUAL(GMath::TruncateToInt(-5.6), -6); CHECK_EQUAL (GMath:: TruncateToInt (-5.6), -6);
CHECK_EQUAL(GMath::TruncateToInt(-2.1), -3); CHECK_EQUAL (GMath:: TruncateToInt (-2.1), -3);
CHECK_EQUAL(GMath::TruncateToInt(-2.0), -2); CHECK_EQUAL (GMath:: TruncateToInt (-2.0), -2);
CHECK_EQUAL(GMath::TruncateToInt(-2585858.0), -2585858); CHECK_EQUAL (GMath:: TruncateToInt (-2585858.0), -2585858);
CHECK_EQUAL(GMath::TruncateToInt(-2533858.12312), -2533859); CHECK_EQUAL (GMath:: TruncateToInt (-2533858.12312), -2533859);
} )

// 경험치 테스트입니다. / / Experience is a test.

TEST(TestCalcLevelFromExp) TEST (TestCalcLevelFromExp)
{ (
CHECK_EQUAL(GCalculator::CalcLevelFromExp(4550, 1), 1); CHECK_EQUAL (GCalculator:: CalcLevelFromExp (4550, 1), 1);
CHECK_EQUAL(GCalculator::CalcLevelFromExp(7510, 1), 2); CHECK_EQUAL (GCalculator:: CalcLevelFromExp (7510, 1), 2);
CHECK_EQUAL(GCalculator::CalcLevelFromExp(10500, 1), 3); CHECK_EQUAL (GCalculator:: CalcLevelFromExp (10500, 1), 3);

GLevelTable lt; GLevelTable lt;
int64 exp = lt.GetRequiredTotalXP(18) - 1; int64 exp = lt.GetRequiredTotalXP (18) - 1;
CHECK_EQUAL(GCalculator::CalcLevelFromExp(exp, 1), 18); CHECK_EQUAL (GCalculator:: CalcLevelFromExp (exp, 1), 18);
CHECK_EQUAL(GCalculator::CalcLevelFromExp(exp, 32), 32); CHECK_EQUAL (GCalculator:: CalcLevelFromExp (exp, 32), 32);
} )


○ 이건 클라이언트에서 처음 맵에 접속했을 때 주위 NPC들의 애니메이션 상태를 체크하는 테스트 코드입니다. ○ This is when the client first connected around the NPC's map animation tests to check the status code.


TEST_FIXTURE(SimpleTestFixture, NPCAnimationCheckWhenEntry) TEST_FIXTURE (SimpleTestFixture, NPCAnimationCheckWhenEntry)
{ (
int nNPCID = 1; int nNPCID = 1;
vec3 vPos = vec3(1000.0f, 1000.0f, 0.0f); vec3 vPos = vec3 (1000.0f, 1000.0f, 0.0f);
MUID uidNPC = global.system->GenerateLocalUID(); MUID uidNPC = global.system-> GenerateLocalUID ();

// 서버로부터 받은 NPC 정보입니다. / / Server is the information received from the NPC.
TD_UPDATE_CACHE_NPC td_update_cache_npc; TD_UPDATE_CACHE_NPC td_update_cache_npc;
td_update_cache_npc.uid = uidNPC; td_update_cache_npc.uid = uidNPC;

td_update_cache_npc.nStatusFlag = 0; td_update_cache_npc.nStatusFlag = 0;
td_update_cache_npc.nNPCID = nNPCID; td_update_cache_npc.nNPCID = nNPCID;
td_update_cache_npc.vPos = vPos; td_update_cache_npc.vPos = vPos;

// 여기서 서버로부터 NPC 정보를 받게 됩니다. / / Where the server will receive information from the NPC.
m_Helper.InNPCs(&td_update_cache_npc, 1, &m_NPCAniDataSet); m_Helper.InNPCs (& td_update_cache_npc, 1, & m_NPCAniDataSet);


// 인스턴스 매니저에 실제로 NPC인스턴스가 생겼는지 테스트합니다. / / Instance, the manager actually looks like an instance to test the NPC.
XNonPlayer* pNPC = gg.omgr->FindNPC(uidNPC); XNonPlayer * pNPC = gg.omgr-> FindNPC (uidNPC);
CHECK(pNPC != NULL); CHECK (pNPC! = NULL);

if (pNPC == NULL) return; if (pNPC == NULL) return;


// nStatusFlag에 아무값이 없으므로 가만히 서있는 idle 애니메이션인지 테스트합니다. / / NStatusFlag no value because the animation is still standing idle test.
CHECK_EQUAL(pNPC->GetCurrMotion(), string(MOTION_NAME_NPC_IDLE)); CHECK_EQUAL (pNPC-> GetCurrMotion (), string (MOTION_NAME_NPC_IDLE));

gg.game->Update(0.1f); gg.game-> Update (0.1f);


// 틱이 지난 후에도 계속 idle 애니메이션인지 테스트합니다. / / Tikyi still idle after the animation is the last test.
CHECK_EQUAL(pNPC->GetCurrMotion(), string(MOTION_NAME_NPC_IDLE)); CHECK_EQUAL (pNPC-> GetCurrMotion (), string (MOTION_NAME_NPC_IDLE));

// 달리는 상태 ------------ / / Running Status ------------
uidNPC = global.system->GenerateLocalUID(); uidNPC = global.system-> GenerateLocalUID ();

td_update_cache_npc.uid = uidNPC; td_update_cache_npc.uid = uidNPC;
td_update_cache_npc.nStatusFlag = UNS_RUN;        // 달리는 상태 td_update_cache_npc.nStatusFlag = UNS_RUN; / / Running Status
td_update_cache_npc.fSpeed = 100.0f; td_update_cache_npc.fSpeed = 100.0f;
td_update_cache_npc.vTarPos = vec3(0.0f, 0.0f, 0.0f); td_update_cache_npc.vTarPos = vec3 (0.0f, 0.0f, 0.0f);

m_Helper.InNPCs(&td_update_cache_npc, 1, &m_NPCAniDataSet); m_Helper.InNPCs (& td_update_cache_npc, 1, & m_NPCAniDataSet);
gg.game->Update(0.1f); gg.game-> Update (0.1f);

pNPC = gg.omgr->FindNPC(uidNPC); pNPC = gg.omgr-> FindNPC (uidNPC);
CHECK(pNPC != NULL); CHECK (pNPC! = NULL);
if (pNPC == NULL) return; if (pNPC == NULL) return;

// 달리는 중이므로 run 모션 테스트 / / Motion test run because it is being run
CHECK_EQUAL(pNPC->GetCurrMotion(), string(MOTION_NAME_NPC_RUN)); CHECK_EQUAL (pNPC-> GetCurrMotion (), string (MOTION_NAME_NPC_RUN));

// 걷는 상태 ------------ / / Walk Status ------------
uidNPC = global.system->GenerateLocalUID(); uidNPC = global.system-> GenerateLocalUID ();

td_update_cache_npc.uid = uidNPC; td_update_cache_npc.uid = uidNPC;
td_update_cache_npc.nStatusFlag = UNS_WALK;        // 걷는 상태 td_update_cache_npc.nStatusFlag = UNS_WALK; / / walking conditions
td_update_cache_npc.fSpeed = 100.0f; td_update_cache_npc.fSpeed = 100.0f;
td_update_cache_npc.vTarPos = vec3(0.0f, 0.0f, 0.0f); td_update_cache_npc.vTarPos = vec3 (0.0f, 0.0f, 0.0f);

m_Helper.InNPCs(&td_update_cache_npc, 1, &m_NPCAniDataSet); m_Helper.InNPCs (& td_update_cache_npc, 1, & m_NPCAniDataSet);
gg.game->Update(0.1f); gg.game-> Update (0.1f);

pNPC = gg.omgr->FindNPC(uidNPC); pNPC = gg.omgr-> FindNPC (uidNPC);
CHECK(pNPC != NULL); CHECK (pNPC! = NULL);
if (pNPC == NULL) return; if (pNPC == NULL) return;


// 걷는 중이므로 walk 모션 / / Walk Because walking motion
CHECK_EQUAL(pNPC->GetCurrMotion(), string(MOTION_NAME_NPC_WALK)); CHECK_EQUAL (pNPC-> GetCurrMotion (), string (MOTION_NAME_NPC_WALK));
} )

Thanks me if i help !

Proofs
_________________
/***** OWNED ****\
------------------



Stupid !!


i just can say Owned , :rolleyes:
 
Upvote 0
Praise the Sun!
Loyal Member
Joined
Dec 4, 2007
Messages
2,502
Reaction score
986
Even MAIET wouldn't duck up C++ code that much.
 
Upvote 0
Newbie Spellweaver
Joined
Jun 16, 2009
Messages
53
Reaction score
34
They're using UnitTest++ :)

I like how they're using agile development practices. Makes me warm and fuzzy inside. I assume this was taken from their blog? Thanks for the leech.

EDIT: Nvm, it looks like a proprietary unit testing framework that's modeled after UT++... I don't know why they didn't just use it - it's open source.
 
Last edited:
Upvote 0
Status
Not open for further replies.
Back
Top