void InitBags(UInt initial_size, Bag * stack_bottom, UInt stack_align) { UInt i; /* loop variable */ /* install the marking functions */ for (i = 0; i < NUM_TYPES; i++) { TabMarkTypeBags[i] = -1; } #ifndef DISABLE_GC #ifdef HPCGAP if (!getenv("GC_MARKERS")) { /* The Boehm GC does not have an API to set the number of * markers for the parallel mark and sweep implementation, * so we use the documented environment variable GC_MARKERS * instead. However, we do not override it if it's already * set. */ static char marker_env_str[32]; unsigned num_markers = 2; if (!SyNumGCThreads) SyNumGCThreads = SyNumProcessors; if (SyNumGCThreads) { if (SyNumGCThreads <= MAX_GC_THREADS) num_markers = (unsigned)SyNumProcessors; else num_markers = MAX_GC_THREADS; } sprintf(marker_env_str, "GC_MARKERS=%u", num_markers); putenv(marker_env_str); } #endif GC_set_all_interior_pointers(0); GC_init(); GC_set_free_space_divisor(1); TLAllocatorInit(); GC_register_displacement(0); GC_register_displacement(sizeof(BagHeader)); initial_size *= 1024; if (GC_get_heap_size() < initial_size) GC_expand_hp(initial_size - GC_get_heap_size()); if (SyStorKill) GC_set_max_heap_size(SyStorKill * 1024); #ifdef HPCGAP AddGCRoots(); CreateMainRegion(); #else void * p = ActiveGAPState(); GC_add_roots(p, (char *)p + sizeof(GAPState)); #endif for (i = 0; i <= MAX_GC_PREFIX_DESC; i++) { BuildPrefixGCDescriptor(i); /* This is necessary to initialize some internal structures * in the garbage collector: */ GC_generic_malloc(sizeof(BagHeader) + i * sizeof(Bag), GCMKind[i]); } #endif /* DISABLE_GC */ }
//调用自定义极其父类构造 CDriveGameClient::CDriveGameClient(Timer* pTimer, unsigned uID) : CGameClient(pTimer), m_pDrivePlayer(NULL), m_pDriveRegion(NULL) { SetDriveMainPlayer(CreateMainPlayer()); SetDriveMainRegion(CreateMainRegion()); SetMemServeruID(uID); }
//初始化主场景 void CDriveGameClient::InitGameRegionData(CMessage *pMsg) { // 地图名字 char strRegionName[256]; pMsg->GetStr(strRegionName,256); long lTaxRate = pMsg->GetLong(); //得到税率 REGION_TYPE eWarRegionType = (REGION_TYPE)pMsg->GetByte();//得到战斗场景类型 BYTE eSpaceType=pMsg->GetByte();//是否是水下场景 bool bChangeEquip = pMsg->GetByte()==0?false:true; CGUID RegionID; pMsg->GetGUID(RegionID); long lRegionID = pMsg->GetLong(); long lResourceID = pMsg->GetLong(); float fExpScale = pMsg->GetFloat(); // 初始化地图 if( m_pDriveRegion ) { m_pDriveRegion->RemoveObject(m_pDrivePlayer); SAFE_DELETE(m_pDriveRegion); } m_pDriveRegion = CreateMainRegion(); //------------------------------------------------------------------ SetDriveMainRegion(m_pDriveRegion); //必须设置主场景管理指针! //--------------------------------------------------------------------- m_pDriveRegion->SetExID(RegionID); m_pDriveRegion->SetResourceID(lResourceID); m_pDriveRegion->Load(); //m_pDriveRegion->Init(); m_pDriveRegion->SetName( strRegionName ); // 加入玩家并设置坐标 m_pDrivePlayer->SetFather( m_pDriveRegion ); m_pDrivePlayer->SetPosXY( m_pDrivePlayer->GetTileX()+0.5f, m_pDrivePlayer->GetTileY()+0.5f ); m_pDrivePlayer->SetDir( (CShape::eDIR)m_pDrivePlayer->GetDir() ); m_pDrivePlayer->SetRegionID( lRegionID ); m_pDrivePlayer->GetRegionGUID( RegionID ); m_pDrivePlayer->SetDestXY(m_pDrivePlayer->GetPosX(), m_pDrivePlayer->GetPosY()); extern bool g_bForceUpdate; g_bForceUpdate = true; m_pDrivePlayer->SetAction(CShape::ACT_STAND); m_pDrivePlayer->SetFather( m_pDriveRegion ); //m_pDrivePlayer->RefeashState(); m_pDriveRegion->AddObject( m_pDrivePlayer ); //m_pDriveRegion()->ScrollCenter( m_pDrivePlayer->GetPosX() , m_pDrivePlayer->GetPosY()); //m_pDriveRegion()->SyncUpdate(); //SetGameState( GS_BLACK ); // 清空走路计数 //重置自动状态 //GetGameControl()->SetSendedMoveMsgCount(0); //GetGameControl()->SetMPActionMode(CGameControl::MPAM_No); //GetGameControl()->ContinueMoveToOtherRegion(); //设置宠物 // m_pDrivePlayer->PetEnterRegion(); //设置税率 if(m_pDriveRegion) { m_pDriveRegion->SetTaxRate(lTaxRate); m_pDriveRegion->SetWarRegionType(eWarRegionType); m_pDriveRegion->SetExpScale(fExpScale); //m_pDriveRegion->SetWaterRegion(bWaterRegion); //当主角进入场景 //m_pDriveRegion->OnMainPlayerEnter(); } //打开宠物血条 并加入场景shape链表 // long lPetCount = m_pDrivePlayer->GetActivePetCount(); // if ( lPetCount > 0) // { // for (int i = 0; i < lPetCount; i++) // { // // CPet *pPet = m_pDrivePlayer->GetActivePet(i+1); // // if (pPet) // // m_pDriveRegion->AddObject((CBaseObject*)pPet); // } // } }