void CUnit::ForcedMove(const float3& newPos) { // hack to make mines not block ground const bool blocking = !unitDef->canKamikaze || (unitDef->type != "Building"); if (blocking) { UnBlock(); } CBuilding* building = dynamic_cast<CBuilding*>(this); if (building && unitDef->useBuildingGroundDecal) { groundDecals->RemoveBuilding(building, NULL); } pos = newPos; midPos = pos + (frontdir * relMidPos.z) + (updir * relMidPos.y) + (rightdir * relMidPos.x); if (building && unitDef->useBuildingGroundDecal) { groundDecals->AddBuilding(building); } if (blocking) { Block(); } qf->MovedUnit(this); loshandler->MoveUnit(this, false); if (hasRadarCapacity) { radarhandler->MoveUnit(this); } }
/* Destructor */ CSolidObject::~CSolidObject(void) { UnBlock(); // readmap->CleanBlockingMap(this); //Debug if(mobility) delete mobility; }
void CUnit::FinishedBuilding(void) { beingBuilt = false; buildProgress = 1.0f; if (soloBuilder) { DeleteDeathDependence(soloBuilder); soloBuilder = NULL; } if (!(immobile && (mass == 100000))) { mass = unitDef->mass; //set this now so that the unit is harder to move during build } ChangeLos(realLosRadius,realAirLosRadius); if (unitDef->startCloaked) { wantCloak = true; isCloaked = true; } if (unitDef->windGenerator>0) { if (wind.curStrength > unitDef->windGenerator) { cob->Call(COBFN_SetSpeed, (int)(unitDef->windGenerator * 3000.0f)); } else { cob->Call(COBFN_SetSpeed, (int)(wind.curStrength * 3000.0f)); } cob->Call(COBFN_SetDirection, (int)GetHeadingFromVector(-wind.curDir.x, -wind.curDir.z)); } if (unitDef->activateWhenBuilt) { Activate(); } gs->Team(team)->metalStorage += unitDef->metalStorage; gs->Team(team)->energyStorage += unitDef->energyStorage; //Sets the frontdir in sync with heading. frontdir = GetVectorFromHeading(heading) + float3(0,frontdir.y,0); if (unitDef->isAirBase) { airBaseHandler->RegisterAirBase(this); } luaCallIns.UnitFinished(this); globalAI->UnitFinished(this); if (unitDef->isFeature) { UnBlock(); CFeature* f = featureHandler->CreateWreckage(pos, wreckName, heading, buildFacing, 0, team, false, ""); if (f) { f->blockHeightChanges = true; } KillUnit(false, true, 0); } }
void CFeature::UpdateQuadFieldPosition(const float3& moveVec) { quadField->RemoveFeature(this); UnBlock(); Move(moveVec, true); Block(); quadField->AddFeature(this); }
/* Adds this object to the GroundBlockingMap. */ void CSolidObject::Block() { if(isMarkedOnBlockingMap) UnBlock(); if(blocking && (physicalState == OnGround || physicalState == Floating || physicalState == Hovering || physicalState == Submarine)){ //Using yardmap if available. if(yardMap) { readmap->AddGroundBlockingObject(this, yardMap); } else { readmap->AddGroundBlockingObject(this); } isMarkedOnBlockingMap = true; } }
CFeature::~CFeature() { UnBlock(); quadField->RemoveFeature(this); if (myFire != NULL) { myFire->StopFire(); myFire = NULL; } if (def->geoThermal) { CGeoThermSmokeProjectile::GeoThermDestroyed(this); } }
CFeature::~CFeature(void) { if(blocking){ UnBlock(); } qf->RemoveFeature(this); if(def->drawType==DRAWTYPE_TREE) treeDrawer->DeleteTree(pos); if(myFire){ myFire->StopFire(); myFire=0; } }
void CFeature::ForcedMove(const float3& newPos, bool snapToGround) { if (blocking) { UnBlock(); } // remove from managers qf->RemoveFeature(this); if (def->drawType >= DRAWTYPE_TREE) { treeDrawer->DeleteTree(pos); } pos = newPos; featureDrawer->UpdateDrawPos(this); // setup finalHeight if (snapToGround) { if (def->floating) { finalHeight = ground->GetHeight(pos.x, pos.z); } else { finalHeight = ground->GetHeight2(pos.x, pos.z); } } else { finalHeight = newPos.y; } // setup midPos if (def->drawType == DRAWTYPE_MODEL) { midPos = pos + model->relMidPos; } else if (def->drawType >= DRAWTYPE_TREE) { midPos = pos + (UpVector * TREE_RADIUS); } else { midPos = pos; } // setup the visual transformation matrix CalculateTransform(); // insert into managers qf->AddFeature(this); if (def->drawType >= DRAWTYPE_TREE) { treeDrawer->AddTree(def->drawType - 1, pos, 1.0f); } if (blocking) { Block(); } }
CFeature::~CFeature() { UnBlock(); quadField->RemoveFeature(this); if (featureHandler != NULL) { featureHandler->SetFeatureUpdateable(this, false); } if (myFire != NULL) { myFire->StopFire(); myFire = NULL; } if (def->geoThermal) { CGeoThermSmokeProjectile::GeoThermDestroyed(this); } }
/* * adds this object to the GroundBlockingMap * if and only if its collidable property is * set (blocking), else does nothing (except * call UnBlock()) */ void CSolidObject::Block() { UnBlock(); if (!blocking) { return; } if (physicalState == Flying) { return; } // use the object's current yardmap if available if (curYardMap != 0) { groundBlockingObjectMap->AddGroundBlockingObject(this, curYardMap, 255); } else { groundBlockingObjectMap->AddGroundBlockingObject(this); } // isMarkedOnBlockingMap is now true }
void CFeature::ForcedMove(const float3& newPos) { // remove from managers quadField->RemoveFeature(this); const float3 oldPos = pos; UnBlock(); Move(newPos - pos, true); Block(); eventHandler.FeatureMoved(this, oldPos); // setup the visual transformation matrix CalculateTransform(); // insert into managers quadField->AddFeature(this); }
/* * adds this object to the GroundBlockingMap * if and only if its collidable property is * set (blocking), else does nothing (except * call UnBlock()) */ void CSolidObject::Block() { UnBlock(); if (!blocking) { return; } if (physicalState == Ghost || physicalState == Flying) { return; } // use the object's yardmap if available if (yardMap) { groundBlockingObjectMap->AddGroundBlockingObject(this, yardMap); } else { groundBlockingObjectMap->AddGroundBlockingObject(this); } // isMarkedOnBlockingMap is now true }
void CFeature::ForcedMove(const float3& newPos) { // remove from managers quadField->RemoveFeature(this); const float3 oldPos = pos; UnBlock(); Move(newPos - pos, true); Block(); // ForcedMove calls might cause the pstate to go stale // (features are only Update()'d when in the FH queue) UpdateTransformAndPhysState(); eventHandler.FeatureMoved(this, oldPos); // insert into managers quadField->AddFeature(this); }
CFeature::~CFeature() { if (blocking) { UnBlock(); } qf->RemoveFeature(this); if (def->drawType >= DRAWTYPE_TREE && treeDrawer) { treeDrawer->DeleteTree(pos); } if (myFire) { myFire->StopFire(); myFire = 0; } if (def->geoThermal) { CGeoThermSmokeProjectile::GeoThermDestroyed(this); } }
void CFeature::ForcedMove(const float3& newPos, bool snapToGround) { if (blocking) { UnBlock(); } // remove from managers qf->RemoveFeature(this); if (def->drawType >= DRAWTYPE_TREE) { treeDrawer->DeleteTree(pos); } Move3D(newPos - pos, true); eventHandler.FeatureMoved(this); // setup finalHeight (pos == newPos now) if (snapToGround) { if (def->floating) { finalHeight = ground->GetHeightAboveWater(pos.x, pos.z); } else { finalHeight = ground->GetHeightReal(pos.x, pos.z); } } else { finalHeight = pos.y; } // setup the visual transformation matrix CalculateTransform(); // insert into managers qf->AddFeature(this); if (def->drawType >= DRAWTYPE_TREE) { treeDrawer->AddTree(def->drawType - 1, pos, 1.0f); } if (blocking) { Block(); } }
void StdSchedulerThread::Stop() { // Not running? if (!fThread) return; // Set flag fRunThreadRun = false; // Unblock UnBlock(); #ifdef HAVE_WINTHREAD // Wait for thread to terminate itself HANDLE hThread = reinterpret_cast<HANDLE>(iThread); if (WaitForSingleObject(hThread, 10000) == WAIT_TIMEOUT) // ... or kill it in case it refuses to do so TerminateThread(hThread, -1); #elif HAVE_PTHREAD // wait for thread to terminate itself // (without security - let's trust these unwashed hackers for once) pthread_join(Thread, NULL); #endif fThread = false; // ok return; }
CFeature::~CFeature(void) { if (blocking) { UnBlock(); } qf->RemoveFeature(this); if (def->drawType == DRAWTYPE_TREE) treeDrawer->DeleteTree(pos); if (myFire) { myFire->StopFire(); myFire = 0; } if (def->geoThermal) { CGeoThermSmokeProjectile::GeoThermDestroyed(this); } delete collisionVolume; collisionVolume = NULL; }
bool CFeature::UpdatePosition() { bool finishedUpdate = true; if (!createdFromUnit.empty()) { // we are a wreck of a dead unit if (!reachedFinalPos) { bool haveForwardSpeed = false; bool haveVerticalSpeed = false; bool inBounds = false; if (deathSpeed.SqLength2D() > 0.01f) { UnBlock(); qf->RemoveFeature(this); // update our forward speed (and quadfield // position) if it's still greater than 0 pos += deathSpeed; midPos += deathSpeed; // NOTE: apply more drag if we were a tank or bot? // (would require passing extra data to Initialize()) deathSpeed *= 0.95f; haveForwardSpeed = true; qf->AddFeature(this); Block(); } // def->floating is unreliable (true for land unit wrecks), // just assume wrecks always sink even if their "owner" was // a floating object (as is the case for ships anyway) float realGroundHeight = ground->GetHeight2(pos.x, pos.z); bool reachedGround = (pos.y <= realGroundHeight); if (!reachedGround) { if (pos.y > 0.0f) { // quadratic acceleration if not in water deathSpeed.y += mapInfo->map.gravity; } else { // constant downward speed otherwise deathSpeed.y = mapInfo->map.gravity; } pos.y += deathSpeed.y; midPos.y += deathSpeed.y; haveVerticalSpeed = true; } else { // last Update() may have sunk us into // ground if pos.y was only marginally // larger than ground height, correct pos.y = realGroundHeight; midPos.y = pos.y + model->relMidPos.y; } inBounds = pos.CheckInBounds(); reachedFinalPos = (!haveForwardSpeed && !haveVerticalSpeed); // reachedFinalPos = ((!haveForwardSpeed && !haveVerticalSpeed) || !inBounds); if (!inBounds) { // ensure that no more forward-speed updates are done // (prevents wrecks floating in mid-air at edge of map // due to gravity no longer being applied either) deathSpeed = ZeroVector; } featureHandler->UpdateDrawQuad(this, pos); CalculateTransform(); } if (!reachedFinalPos) finishedUpdate = false; } if (pos.y > finalHeight) { //! feature is falling if (def->drawType >= DRAWTYPE_TREE) treeDrawer->DeleteTree(pos); if (pos.y > 0.0f) { speed.y += mapInfo->map.gravity; //! gravity is negative } else { //! fall slower in water speed.y += mapInfo->map.gravity * 0.5; } pos.y += speed.y; midPos.y += speed.y; transMatrix[13] += speed.y; if (def->drawType >= DRAWTYPE_TREE) treeDrawer->AddTree(def->drawType - 1, pos, 1.0f); } else if (pos.y < finalHeight) { //! if ground is restored, make sure feature does not get buried if (def->drawType >= DRAWTYPE_TREE) treeDrawer->DeleteTree(pos); float diff = finalHeight - pos.y; pos.y = finalHeight; midPos.y += diff; transMatrix[13] += diff; speed.y = 0.0f; if (def->drawType >= DRAWTYPE_TREE) treeDrawer->AddTree(def->drawType - 1, pos, 1.0f); } if (pos.y != finalHeight) finishedUpdate = false; isUnderWater = ((pos.y + height) < 0.0f); return finishedUpdate; }
bool CFeature::UpdatePosition() { if (udef != NULL) { // we are a wreck of a dead unit if (!reachedFinalPos) { // def->floating is unreliable (true for land unit wrecks), // so just assume wrecks always sink even if their "owner" // was a floating object (as is the case for ships anyway) const float realGroundHeight = ground->GetHeightReal(pos.x, pos.z); const bool reachedWater = ( pos.y <= 0.1f); const bool reachedGround = ((pos.y - realGroundHeight) <= 0.1f); deathSpeed *= 0.999999f; deathSpeed *= (1.0f - (int(reachedWater ) * 0.05f)); deathSpeed *= (1.0f - (int(reachedGround) * 0.10f)); if (deathSpeed.SqLength2D() > 0.01f) { UnBlock(); qf->RemoveFeature(this); // update our forward speed (and quadfield // position) if it is still greater than 0 Move3D(deathSpeed, true); qf->AddFeature(this); Block(); } else { deathSpeed.x = 0.0f; deathSpeed.z = 0.0f; } if (!reachedGround) { if (!reachedWater) { // quadratic acceleration if not in water deathSpeed.y += mapInfo->map.gravity; } else { // constant downward speed otherwise deathSpeed.y = mapInfo->map.gravity; } Move1D(deathSpeed.y, 1, true); } else { deathSpeed.y = 0.0f; // last Update() may have sunk us into // ground if pos.y was only marginally // larger than ground height, correct Move1D(realGroundHeight, 1, false); } reachedFinalPos = (deathSpeed == ZeroVector); if (!pos.IsInBounds()) { pos.ClampInBounds(); // ensure that no more forward-speed updates are done // (prevents wrecks floating in mid-air at edge of map // due to gravity no longer being applied either) deathSpeed = ZeroVector; } eventHandler.FeatureMoved(this); CalculateTransform(); } } else { if (pos.y > finalHeight) { // feature is falling (note: gravity is negative) if (def->drawType >= DRAWTYPE_TREE) { treeDrawer->DeleteTree(pos); } if (pos.y > 0.0f) { speed.y += mapInfo->map.gravity; } else { speed.y = mapInfo->map.gravity; } Move1D(speed.y, 1, true); if (def->drawType >= DRAWTYPE_TREE) { treeDrawer->AddTree(def->drawType - 1, pos, 1.0f); } transMatrix[13] += speed.y; } else if (pos.y < finalHeight) { // if ground is restored, make sure feature does not get buried if (def->drawType >= DRAWTYPE_TREE) { treeDrawer->DeleteTree(pos); } const float dy = finalHeight - pos.y; speed.y = 0.0f; transMatrix[13] += dy; Move1D(dy, 1, true); if (def->drawType >= DRAWTYPE_TREE) { treeDrawer->AddTree(def->drawType - 1, pos, 1.0f); } } reachedFinalPos = (pos.y == finalHeight); } isUnderWater = ((pos.y + height) < 0.0f); return reachedFinalPos; }
void BlockedQR( double *A, int h, int w, double *Q){ /* Block size */ int b= 16; /* Calculate Number of blocks */ int wn_bloc = (w+b-1)/b; // Number of Blocks in width (round up) int hn_bloc = (h+b -1)/b; // Number of Blocks in height (round up) /* Determine which num. of blocks is smaller */ int n = wn_bloc; if( wn_bloc > hn_bloc ) n = hn_bloc; /* Set Q = m by m identity matrix */ for(int i = 0; i<h; i++){ for(int j=0; j<h; j++){ Q[i + j*h] = 0; if(i == j) Q[i +j*h] = 1; } } /* Enter Loop */ for(int k =0; k< n; k++){ /* Update Blocks below the Diagonal (will also update diagonal) */ for( int i=k+1; i<hn_bloc ; i++){ double *tempA = malloc(2*b*b*sizeof(double)); double *tempR = malloc(2*b*b*sizeof(double)); double *tempQ = malloc(2*b*2*b*sizeof(double)); double *tempQt = malloc(2*b*2*b*sizeof(double)); Block(tempA, A, h , w, b, k, i, k); WY( tempA, 2*b, b, tempQ, tempQt, tempR); UnBlock(A, tempR, h, w, b,k, i, k); free(tempA); free(tempR); /* Update Q */ double *tempQh1 = malloc( b* 2*h* sizeof(double)); double *tempQh2 = malloc( b* 2*h* sizeof(double)); BlockQ(Q, tempQh1, h, h, b, k, i ); dgemm_simple(tempQh1, h, 2*b, tempQ, 2*b, 2*b, tempQh2); UnBlockQ( tempQh2, Q, h, h, b, k, i); free(tempQ); free(tempQh1); free(tempQh2); /* Update Blocks along i and k rows */ #pragma omp parallel for shared(A, k, h, w, b, i) for( int j=k+1; j<wn_bloc ; j++){ double *tempA = malloc(2*b*b*sizeof(double)); double *tempR = malloc(2*b*b*sizeof(double)); Block(tempA, A , h, w, b, k, i, j); dgemm_simple(tempQt, 2*b, 2*b, tempA, 2*b, b, tempR); UnBlock(A, tempR, h, w, b,k, i, j); free(tempA); free(tempR); } free(tempQt); } if( (k == hn_bloc - 1) && (n == hn_bloc) ){ /* Update Diagonal Block by itself if we are on the last column and there will be no zero rows. */ double *tempA = malloc( b*b*sizeof(double)); double *tempR = malloc( b * b* sizeof(double)); double *tempQ = malloc( b* b*sizeof(double)); double *tempQt = malloc( b* b* sizeof(double)); BlockMatrix(A, tempA, h, w, b, k, k); WY( tempA, b, b, tempQ, tempQt, tempR); UnBlockMatrix(A, tempR, h, w, b, k,k); free(tempA); free(tempR); /* Update Corresponding Diagonal Block in in Q */ double *tempQh1 = malloc( b* h* sizeof(double)); double *tempQh2 = malloc( b* h* sizeof(double)); BlockQ1(Q, tempQh1, h, h, b, k ); dgemm_simple(tempQh1, h, b, tempQ, b, b, tempQh2); UnBlockQ1(tempQh2 , Q, h, h, b, k); free(tempQ); free(tempQh1); free(tempQh2); /* Update Blocks along row with Digonal Block - Do in Parallel */ #pragma omp parallel for shared(A, k, h, w, b, tempQt) for( int j=k+1; j<wn_bloc ; j++){ double *tempA = malloc( b*b*sizeof(double)); double *tempR = malloc( b*b*sizeof(double)); BlockMatrix(A, tempA, h, w, b, k, j); dgemm_simple(tempQt, b, b, tempA, b, b, tempR); UnBlockMatrix(A, tempR, h,w,b, k, j); free(tempA); free(tempR); } free(tempQt); } } }
bool CFeature::UpdatePosition() { const float3 oldPos = pos; if (udef != NULL) { // we are a wreck of a dead unit, possibly with residual impulse // in this case we do not care about <finalHeight> and are always // affected by gravity // note that def->floating is unreliable (eg. it can be true for // ground-unit wrecks), so just assume wrecks always sink in water // even if their "owner" was a floating object (as is the case for // ships anyway) if (IsMoving()) { const float realGroundHeight = ground->GetHeightReal(pos.x, pos.z); const bool reachedWater = ( pos.y <= 0.1f); const bool reachedGround = ((pos.y - realGroundHeight) <= 0.1f); // NOTE: // all these calls use the base-class because FeatureHandler::Update // iterates over updateFeatures and our ::SetVelocity will insert us // into that CWorldObject::SetVelocity(speed + GetDragAccelerationVec(float4(mapInfo->atmosphere.fluidDensity, mapInfo->water.fluidDensity, 1.0f, 0.1f))); if (speed.SqLength2D() > 0.01f) { UnBlock(); quadField->RemoveFeature(this); // update our forward speed (and quadfield // position) if it is still greater than 0 Move(speed, true); quadField->AddFeature(this); Block(); } else { CWorldObject::SetVelocity(speed * UpVector); } if (!reachedGround) { if (!reachedWater) { // quadratic acceleration if not in water CWorldObject::SetVelocity(speed + (UpVector * mapInfo->map.gravity)); } else { // constant downward speed otherwise CWorldObject::SetVelocity((speed * XZVector) + (UpVector * mapInfo->map.gravity)); } Move(UpVector * speed.y, true); } else { CWorldObject::SetVelocity(speed * XZVector); // last Update() may have sunk us into // ground if pos.y was only marginally // larger than ground height, correct Move(UpVector * (realGroundHeight - pos.y), true); } if (!pos.IsInBounds()) { pos.ClampInBounds(); // ensure that no more forward-speed updates are done // (prevents wrecks floating in mid-air at edge of map // due to gravity no longer being applied either) CWorldObject::SetVelocity(ZeroVector); } eventHandler.FeatureMoved(this, oldPos); CalculateTransform(); } } else { // any feature that is not a dead unit (ie. rocks, trees, ...) // these never move in the xz-plane no matter how much impulse // is applied, only gravity affects them (FIXME: arbitrary..?) if (pos.y > finalHeight) { if (pos.y > 0.0f) { CWorldObject::SetVelocity(speed + (UpVector * mapInfo->map.gravity)); } else { CWorldObject::SetVelocity((speed * XZVector) + (UpVector * mapInfo->map.gravity)); } // stop falling when we reach our finalHeight // (which can be arbitrary, even below ground) Move(UpVector * std::min(pos.y - finalHeight, speed.y), true); eventHandler.FeatureMoved(this, oldPos); } else if (pos.y < finalHeight) { // stop vertical movement and teleport up CWorldObject::SetVelocity(speed * XZVector); Move(UpVector * (finalHeight - pos.y), true); eventHandler.FeatureMoved(this, oldPos); } transMatrix[13] = pos.y; } UpdatePhysicalStateBit(CSolidObject::PSTATE_BIT_MOVING, ((SetSpeed(speed) != 0.0f) || (std::fabs(pos.y - finalHeight) >= 0.01f))); UpdatePhysicalState(0.1f); return (IsMoving()); }
LRESULT CInviteChatDlg::OnNetEvent(WPARAM w,LPARAM l) { NLT_Container *pItem = (NLT_Container *)w; ASSERT(pItem!=NULL); UnBlock(); switch(pItem->EventType) { case NLT_EDetails: { IUser *pUser = NULL; HRESULT hr = AutoUnMarchaling(pItem,(LPUNKNOWN*)&pUser); if(SUCCEEDED(hr)) { theNet2.LockTranslator(); theNet2.RemoveFromTranslator(Handle); try { CUser InfoUser(pUser); m_User = InfoUser; CString strNickText; strNickText.Format(GetString(IDS_INVITE_CHAT_NICK_NAME),m_User.GetShowName()); m_Nick.SetWindowText(strNickText); UpdateData(FALSE); } catch(...) { ASSERT(FALSE); } theNet2.UnlockTranslator(); pUser->Release(); } } break; case NLT_EChatCreate: { IChat *pChat = NULL; HRESULT hr = AutoUnMarchaling(pItem,(LPUNKNOWN*)&pChat); if(hr==S_OK) { // Step 1. Add new Chat to ChatsCollections [8/9/2002] pMessenger->AddNewChat(pChat,SC_INACTIVE); // Step 2. Connect to Chat [9/7/2002] CChat Chat(pChat); pMessenger->SetChatStatus(Chat.GetId(),SC_ACTIVE,CMainDlg::HCI_OPEN_CHAT_WINDOW); // Step 2. Free Interface [8/9/2002] pChat->Release(); } // Step 3. Close the Window KillWindow(); } break; case NLT_ECommandOK: theNet2.LockTranslator(); theNet2.RemoveFromTranslator(Handle); theNet2.UnlockTranslator(); KillWindow(); break; case NLT_ECommandError: theNet2.LockTranslator(); theNet2.RemoveFromTranslator(Handle); theNet2.UnlockTranslator(); if(pItem->Long1==etSERVER) { switch(pItem->Long2) { case ERR_UNABLE_CREATE_CONN: _SHOW_IBN_ERROR_DLG_OK(IDS_SERVICENOTAVAILABLE); break; } } MessageBox(GetString(IDS_INVITECHAT_ERROR),GetString(IDS_ERROR_TITLE),MB_OK|MB_ICONSTOP); break; } delete pItem; return 0; }
void CUnit::KillUnit(bool selfDestruct,bool reclaimed,CUnit *attacker) { if(isDead) return; if(dynamic_cast<CAirMoveType*>(moveType) && !beingBuilt) { if(!selfDestruct && !reclaimed && gs->randFloat()>recentDamage*0.7/maxHealth+0.2) { ((CAirMoveType*)moveType)->SetState(CAirMoveType::AIRCRAFT_CRASHING); health=maxHealth*0.5; return; } } isDead=true; globalAI->UnitDestroyed(this,attacker); blockHeightChanges=false; if(unitDef->isCommander) gs->Team(team)->CommanderDied(this); if(!reclaimed && !beingBuilt) { string exp; if(selfDestruct) exp=unitDef->selfDExplosion; else exp=unitDef->deathExplosion; if(!exp.empty()) { WeaponDef* wd=weaponDefHandler->GetWeapon(exp); if(wd) { helper->Explosion(midPos,wd->damages,wd->areaOfEffect,wd->edgeEffectivness,wd->explosionSpeed,this,true,wd->damages[0]>500?1:2,false,wd->explosionGenerator,0); // Play explosion sound CWeaponDefHandler::LoadSound(wd->soundhit); if (wd->soundhit.id) { sound->PlaySound(wd->soundhit.id, pos, wd->soundhit.volume); } //info->AddLine("Should play %s (%d)", wd->soundhit.name.c_str(), wd->soundhit.id); } } if(selfDestruct) recentDamage+=maxHealth*2; vector<int> args; args.push_back((int)(recentDamage/maxHealth*100)); args.push_back(0); cob->Call(COBFN_Killed, args, &CUnitKilledCB, this, NULL); UnBlock(); delayedWreckLevel=args[1]; // featureHandler->CreateWreckage(pos,wreckName, heading, args[1],-1,true); } else { deathScriptFinished=true; } if(beingBuilt || dynamic_cast<CAirMoveType*>(moveType) || reclaimed) uh->DeleteUnit(this); else { speed=ZeroVector; deathCountdown=5; stunned=true; paralyzeDamage=1000000; if(health<0) health=0; } }
LRESULT CAddUserRequest::OnNetEvent(WPARAM w,LPARAM l) { NLT_Container *pItem = (NLT_Container *)w; ASSERT(pItem!=NULL); UnBlock(); switch(pItem->EventType) { case NLT_EDetails: { IUser *pUser = NULL; HRESULT hr = AutoUnMarchaling(pItem,(LPUNKNOWN*)&pUser); if(SUCCEEDED(hr)) { theNet2.LockTranslator(); theNet2.RemoveFromTranslator(Handle); try { CUser InfoUser(pUser); m_User = InfoUser; m_Nick.SetText(m_User.GetShowName()); UpdateData(FALSE); } catch(...) { ASSERT(FALSE); } theNet2.UnlockTranslator(); pUser->Release(); } } break; case NLT_ECommandOK: theNet2.LockTranslator(); theNet2.RemoveFromTranslator(Handle); theNet2.UnlockTranslator(); if(m_bAddUserCommand&&!pMessenger->CheckUserInContactList(m_User)) { //GetDlgItem(IDOK)->ShowWindow(SW_HIDE); //GetDlgItem(ID_DANY)->ShowWindow(SW_HIDE); m_Accept.ShowWindow(SW_HIDE); m_Deny.ShowWindow(SW_HIDE); m_AddToContact.ShowWindow(SW_SHOWNORMAL); //GetDlgItem(ID_AUTHORIZATION_REQUEST)->ShowWindow(SW_SHOWNORMAL); } else KillWindow(); break; case NLT_ECommandError: theNet2.LockTranslator(); theNet2.RemoveFromTranslator(Handle); theNet2.UnlockTranslator(); if(pItem->Long1==etSERVER) { switch(pItem->Long2) { case ERR_UNABLE_CREATE_CONN: _SHOW_IBN_ERROR_DLG_OK(IDS_SERVICENOTAVAILABLE); break; } } MessageBox(GetString(IDS_ADD_USER_ERROR),GetString(IDS_ERROR_TITLE),MB_OK|MB_ICONSTOP); break; } delete pItem; return 0; }