Ejemplo n.º 1
0
BOOL KPlayerBaseProcess::OnSyncNpc( LPCBYTE pData, UINT uDataLen )
{
	KS2C_SYNC_NPC* pReceived = (KS2C_SYNC_NPC*)pData;
	// CheckSize
	QCONFIRM_RET_FALSE(_offsetof(KS2C_SYNC_NPC, sVarSync.aMapVarSet) + sizeof(KMAP_VAR_VALUE) *
		(pReceived->sVarSync.wMapVarNum) == uDataLen);

	KNpc* pOldNpc = g_cNpcMgr.GetById(pReceived->dwId); // tmp fix

	KNpc* pNpc = g_cOrpgWorld.AddNpc(pReceived->dwTemplateId, pReceived->dwId);
	QCONFIRM_RET_FALSE(pNpc);

	pNpc->m_cNpcClient.LoadSyncVarOther(pReceived->sVarSync);

	// get client scene
	IKScene* pScene = g_cOrpgWorld.GetScene(g_cOrpgWorld.m_dwClientSceneId);
	QCONFIRM_RET_FALSE(pScene);

	pScene->AddNpc(pNpc, pReceived->nX, pReceived->nY, pReceived->nZ);
	pNpc->SetMoveState((KE_MOVE_STATE)pReceived->nMoveState);
	pNpc->m_nVelocityXY = pReceived->nVelocityXY;
	pNpc->m_nDestX = pReceived->nDestX;
	pNpc->m_nDestY = pReceived->nDestY;
	pNpc->m_nDestZ = pReceived->nDestZ;
	pNpc->m_nFaceDirection = pReceived->nDirectionXY; // 暂时用速度方向代替

	if (!pOldNpc)
		pNpc->FireEvent(emKOBJEVENTTYPE_CHARACTER_ENTER_SCENE, pNpc->GetId(), TRUE, 0);
	return TRUE;
}
Ejemplo n.º 2
0
// init level-info subsystem
void LoadLevelsList(void)
{
  CPrintF(TRANSV("Reading levels directory...\n"));

  // list the levels directory with subdirs
  CDynamicStackArray<CTFileName> afnmDir;
  MakeDirList(afnmDir, CTString("Levels\\"), CTString("*.wld"), DLI_RECURSIVE|DLI_SEARCHCD);

  // for each file in the directory
  for (INDEX i=0; i<afnmDir.Count(); i++) {
    CTFileName fnm = afnmDir[i];

    CPrintF(TRANSV("  file '%s' : "), (const char *)fnm);
    // try to load its info, and if valid
    CLevelInfo li;
    if (GetLevelInfo(li, fnm)) {
      CPrintF(TRANSV("'%s' spawn=0x%08x\n"), (const char *) li.li_strName, li.li_ulSpawnFlags);

      // create new info for that file
      CLevelInfo *pliNew = new CLevelInfo;
      *pliNew = li;
      // add it to list of all levels
      _lhAllLevels.AddTail(pliNew->li_lnNode);
    } else {
      CPrintF(TRANSV("invalid level\n"));
    }
  }

  // sort the list
  _lhAllLevels.Sort(qsort_CompareLevels, _offsetof(CLevelInfo, li_lnNode));
}
Ejemplo n.º 3
0
BOOL KPlayerBaseProcess::OnSyncPlayer( LPCBYTE pData, UINT uDataLen )
{
	KS2C_SYNC_PLAYER* pReceived = (KS2C_SYNC_PLAYER*)pData;
	// CheckSize
	QCONFIRM_RET_FALSE(_offsetof(KS2C_SYNC_PLAYER, sVarSync.aMapVarSet) + sizeof(KMAP_VAR_VALUE) *
		(pReceived->sVarSync.wMapVarNum) == uDataLen);

	// TODO: improve
	KPlayer* pPlayer = g_cPlayerMgr.GetById(pReceived->dwPlayerId);
	if (pPlayer)
	{
		pPlayer->m_cPlayerClient.LoadSyncVarOther(pReceived->sVarSync);
		pPlayer->SetPosition(pReceived->nX, pReceived->nY, pReceived->nZ);
		pPlayer->SetMoveState((KE_MOVE_STATE)pReceived->nMoveState);
		pPlayer->m_nVelocityXY = pReceived->nVelocityXY;
		pPlayer->m_nDestX = pReceived->nDestX;
		pPlayer->m_nDestY = pReceived->nDestY;
		pPlayer->m_nDestZ = pReceived->nDestZ;
		pPlayer->m_nFaceDirection = pReceived->nDirectionXY; // 暂时用速度方向代替
		pPlayer->SetKinName(pReceived->szKinName);
		pPlayer->SetKinId(pReceived->dwKinId);
		pPlayer->SetKinFigure(pReceived->dwKinFigure);

		QLogPrintf(LOG_LEVEL_WARNING, "[PlayerBaseProcess] %s :player_id=%d,already exists", __FUNCTION__, pReceived->dwPlayerId);
		return FALSE;
	}
	else
	{
		pPlayer = g_cOrpgWorld.AddPlayer(pReceived->szName, pReceived->dwPlayerId);
		QCONFIRM_RET_FALSE(pPlayer);

		pPlayer->m_cPlayerClient.LoadSyncVarOther(pReceived->sVarSync);

		// get client scene
		IKScene* pScene = g_pSceneMgr->FirstScene();
		QCONFIRM_RET_FALSE(pScene);

		pScene->AddPlayer(pPlayer, pReceived->nX, pReceived->nY, pReceived->nZ);
		pPlayer->SetMoveState((KE_MOVE_STATE)pReceived->nMoveState);
		pPlayer->m_nVelocityXY = pReceived->nVelocityXY;
		pPlayer->m_nDestX = pReceived->nDestX;
		pPlayer->m_nDestY = pReceived->nDestY;
		pPlayer->m_nDestZ = pReceived->nDestZ;
		pPlayer->m_nFaceDirection = pReceived->nDirectionXY; // 暂时用速度方向代替
		pPlayer->SetKinName(pReceived->szKinName);
		pPlayer->SetKinId(pReceived->dwKinId);
		pPlayer->SetKinFigure(pReceived->dwKinFigure);
		pPlayer->FireEvent(emKOBJEVENTTYPE_CHARACTER_ENTER_SCENE, pPlayer->GetId(), FALSE, 0);
		return TRUE;
	}

	return TRUE;
}
Ejemplo n.º 4
0
BOOL KPlayerBaseProcess::PtcPlayerData( LPCBYTE pData, UINT uDataLen )
{
	KS2C_PLAYERDATA* pSData = (KS2C_PLAYERDATA* )pData;
	// CheckSize
	QCONFIRM_RET_FALSE(_offsetof(KS2C_PLAYERDATA, sVarSync.aMapVarSet) + sizeof(KMAP_VAR_VALUE) *
		(pSData->sVarSync.wMapVarNum) == uDataLen);

	Q_Printl("Received Player Data. Client Player Rolename: " << pSData->szPlayerName <<
		" Id:" << pSData->dwPlayerId);

	g_cOrpgWorld.m_dwClientPlayerId = pSData->dwPlayerId;
	g_cOrpgWorld.m_dwLogicFrames = pSData->dwLogicFrames;
	g_cOrpgWorld.m_nServerId = pSData->nServerId;

    InitStartTimeEvaluation(&g_cOrpgWorld.m_StartTimeEvaluation);
    g_cOrpgWorld.m_nStartLoop = g_cOrpgWorld.m_dwLogicFrames;
    g_cOrpgWorld.m_nGSGameLoop = g_cOrpgWorld.m_dwLogicFrames;
    g_cOrpgWorld.m_dwStartTime = timeGetTime();
	g_cOrpgWorld.m_dwServerTime = pSData->dwServerTime;

	KPlayer* pPlayer = g_cOrpgWorld.AddPlayer(pSData->szPlayerName, pSData->dwPlayerId);
	QCONFIRM_RET_FALSE(pPlayer);
	g_cScriptManager.SetMe((QLunaBase*)pPlayer->GetScriptInterface());

	pPlayer->SetKinId(0);
	pPlayer->SetKinName("");
	pPlayer->SetKinFigure(0);
	pPlayer->m_cPlayerClient.LoadSyncVarSelf(pSData->sVarSync);

	g_cOrpgWorld.m_cEventCreator.FireEvent(emKOBJEVENTTYPE_PLAYER_LOGIN, g_cOrpgWorld.m_dwClientPlayerId, 0, 0);		// by houxuan, 玩家登陆事件

	// 通知服务端已完成加载
	DoSyncEnd();

	return TRUE;
}
Ejemplo n.º 5
0
  ((size_t)((char *)&((st *)0)->m - (char *)0))

/*
 * OS signature in ROM plus debug-related information.
 */
ROMCONST chdebug_t ch_debug = {
  "main",
  (uint8_t)0,
  (uint8_t)sizeof (chdebug_t),
  (uint16_t)((CH_KERNEL_MAJOR << 11) |
             (CH_KERNEL_MINOR << 6) |
             (CH_KERNEL_PATCH) << 0),
  (uint8_t)sizeof (void *),
  (uint8_t)sizeof (systime_t),
  (uint8_t)sizeof (Thread),
  (uint8_t)_offsetof(Thread, p_prio),
  (uint8_t)_offsetof(Thread, p_ctx),
  (uint8_t)_offsetof(Thread, p_newer),
  (uint8_t)_offsetof(Thread, p_older),
  (uint8_t)_offsetof(Thread, p_name),
#if CH_DBG_ENABLE_STACK_CHECK
  (uint8_t)_offsetof(Thread, p_stklimit),
#else
  (uint8_t)0,
#endif
  (uint8_t)_offsetof(Thread, p_state),
  (uint8_t)_offsetof(Thread, p_flags),
#if CH_USE_DYNAMIC
  (uint8_t)_offsetof(Thread, p_refs),
#else
  (uint8_t)0,
Ejemplo n.º 6
0
/*===========================================================================*/

/*
 * OS signature in ROM plus debug-related information.
 */
ROMCONST chdebug_t ch_debug = {
  {'m', 'a', 'i', 'n'},
  (uint8_t)0,
  (uint8_t)sizeof (chdebug_t),
  (uint16_t)(((unsigned)CH_KERNEL_MAJOR << 11U) |
             ((unsigned)CH_KERNEL_MINOR << 6U) |
             ((unsigned)CH_KERNEL_PATCH << 0U)),
  (uint8_t)sizeof (void *),
  (uint8_t)sizeof (systime_t),
  (uint8_t)sizeof (thread_t),
  (uint8_t)_offsetof(thread_t, prio),
  (uint8_t)_offsetof(thread_t, ctx),
  (uint8_t)_offsetof(thread_t, newer),
  (uint8_t)_offsetof(thread_t, older),
  (uint8_t)_offsetof(thread_t, name),
#if CH_DBG_ENABLE_STACK_CHECK == TRUE
  (uint8_t)_offsetof(thread_t, stklimit),
#else
  (uint8_t)0,
#endif
  (uint8_t)_offsetof(thread_t, state),
  (uint8_t)_offsetof(thread_t, flags),
#if CH_CFG_USE_DYNAMIC == TRUE
  (uint8_t)_offsetof(thread_t, refs),
#else
  (uint8_t)0,