static void DumpLocals( dbg_local *local ) /********************************************/ { dbg_local *next; type_length offset; cv_out out[1]; dbg_type tipe; name *t; for( ; local != NULL; local = next ) { next = local->link; switch( local->kind ) { case DBG_SYM_VAR: tipe = FEDbgType( local->sym ); t = LocSymBP( local->loc ); if( t != NULL ) { offset = NewBase( t ); NewBuff( out, CVSyms ); FrameVar( out, FEName( local->sym ), tipe, offset ); buffEnd( out ); } else { CVGenStatic( local->sym, local->loc, false ); } break; case DBG_SYM_TYPE: break; case DBG_SYM_TYPEDEF: tipe = FEDbgType( local->sym ); CVTypedef( FEName( local->sym ), tipe ); break; } DBLocFini( local->loc ); CGFree( local ); } }
int main() { Base* pBase; // In C++, the vtables are built by the compiler and laid out in the executable already. In C, // we need to allocate and build them at runtime. InitVTables(); pBase = NewBase(); // pBase = new Base(); ((Func1)pBase->vtable[VFUNC_FUNC1])(); // pBase->Func1(); ((Func2)pBase->vtable[VFUNC_FUNC2])(11); // pBase->Func2(11); DeleteBase(pBase); // delete pBase; printf("\n"); pBase = (Base*)NewChildOne(); // pBase = new ChildOne(); ((Func1)pBase->vtable[VFUNC_FUNC1])(); // pBase->Func1(); ((Func2)pBase->vtable[VFUNC_FUNC2])(12); // pBase->Func2(12); DeleteBase(pBase); // delete pBase; printf("\n"); pBase = (Base*)NewChildTwo(); // pBase = new ChildTwo(); ((Func1)pBase->vtable[VFUNC_FUNC1])(); // pBase->Func1(); ((Func2)pBase->vtable[VFUNC_FUNC2])(13); // pBase->Func2(13); DeleteBase(pBase); // delete pBase; DeleteVTables(); }
//TODO: maybe this should be some sort of call back extern void _CGAPI DFDwarfLocal( pointer client, pointer locid, pointer sym ) { /*** add to location expr where local sym is *********************************/ name *tmp; type_length offset; tmp = DeAlias( AllocUserTemp( sym, XX ) ); offset = NewBase( tmp ); DWLocOp( client, locid, DW_LOC_fbreg, offset ); }
void CVOutLocal( cv_out *out, name *t, int disp, dbg_type tipe ) /*** Put a local back sym out *************************************/ { type_length offset; void *ptr1; offset = NewBase( t ); ptr1 = out->beg; out->beg = out->ptr; FrameVar( out, "__bck", tipe, offset+disp ); out->beg = ptr1; CVEndType( out ); buffEnd( out ); }
static byte DoDisp( name *op, hw_reg_set regs ) /*************************************************/ { name *base; int val; byte dmod; name *temp_base; val = op->i.constant; /* use integer value*/ base = op->i.base; if( !HasTrueBase( op ) ) { dmod = Displacement( val, regs ); } else if( base->n.class == N_TEMP ) { temp_base = DeAlias( base ); if( temp_base->t.location == NO_LOCATION ) { _Zoiks( ZOIKS_034 ); } val += NewBase( temp_base ) + base->v.offset - temp_base->v.offset; dmod = Displacement( val, regs ); } else {
static void DumpParms( dbg_local *parm, dbg_local **locals ) { dbg_local *alt; cv_out out[1]; dbg_local *next; for( ; parm != NULL; parm = next ) { /* find and unlink from locals */ next = parm->link; alt = UnLinkLoc( locals, parm->sym ); if( alt != NULL ){ dbg_type tipe; type_length offset; name *t; if( alt->kind == DBG_SYM_VAR ){ tipe = FEDbgType( alt->sym ); t = LocSymBP( alt->loc ); if( t != NULL ){ offset = NewBase( t ); NewBuff( out, CVSyms ); FrameVar( out, FEName( alt->sym ), tipe, offset ); buffEnd( out ); }else{ CVGenStatic( alt->sym, alt->loc, false ); } } DBLocFini( alt->loc ); CGFree( alt ); } DBLocFini( parm->loc ); CGFree( parm ); } //#if _TARGET & _TARG_AXP #if 0 // seems like it screws CVPACK on intel NewBuff( out, CVSyms ); StartSym( out, SG_ENDARG ); EndSym( out ); buffEnd( out ); #endif }
void CGameControllerCSBB::Tick() { IGameController::Tick(); if(GameServer()->m_World.m_ResetRequested || GameServer()->m_World.m_Paused) return; m_RoundTick++; // no actual players (bots kicked if human_players == 0) if (CountPlayers() < 1 || m_NewGame) { GameServer()->m_CanRespawn = true; if (m_Round != 0 || m_GameState != CSBB_NEWBASE) Restart(); m_RoundTick = 0; } else { if (CountPlayers() == 1) { Restart(); AutoBalance(); return; } AutoBalance(); if (m_GameState == CSBB_NEWBASE) { CaptureBase(); if (GameServer()->m_pArrow) { GameServer()->m_pArrow->m_Hide = false; GameServer()->m_pArrow->m_Target = m_apBombArea[m_Base]->m_Pos; } } if (m_GameState == CSBB_DEFENDING) { if (GameServer()->m_pArrow) { GameServer()->m_pArrow->m_Hide = false; GameServer()->m_pArrow->m_Target = m_apBombArea[m_Base]->m_Pos; } RoundWinLose(); } if (m_GameState == CSBB_ENDING) { if (m_RoundTick >= g_Config.m_SvPreroundTime*Server()->TickSpeed()) { if (m_aTeamscore[TEAM_RED] >= g_Config.m_SvNumRounds || m_aTeamscore[TEAM_BLUE] >= g_Config.m_SvNumRounds) { EndRound(); m_NewGame = true; return; } NewBase(); //AutoBalance(); if (GameServer()->m_pArrow) GameServer()->m_pArrow->m_Hide = true; } } } GameServer()->UpdateAI(); // warm welcome for (int c = 0; c < MAX_CLIENTS; c++) { CPlayer *pPlayer = GameServer()->m_apPlayers[c]; if(!pPlayer) continue; if (!pPlayer->m_Welcomed && !pPlayer->m_IsBot) { GameServer()->SendBroadcast("Welcome to Counter-Strike: Base Bombing", pPlayer->GetCID(), true); pPlayer->m_Welcomed = true; } } // the bomb (red flag) CBomb *B = m_pBomb; if (!B) return; /* // always update bomb position if(B->m_pCarryingCharacter) { B->m_Pos = B->m_pCarryingCharacter->m_Pos; } else { if (B->m_Status == BOMB_CARRYING || B->m_Status == BOMB_IDLE) { B->m_Vel.y += GameServer()->m_World.m_Core.m_Tuning.m_Gravity; GameServer()->Collision()->MoveBox(&B->m_Pos, &B->m_Vel, vec2(B->ms_PhysSize, B->ms_PhysSize), 0.5f); B->m_Status = BOMB_IDLE; } } */ if (m_Timeout || m_BombDefused || m_GameState != CSBB_DEFENDING) return; if (B->m_Status == BOMB_PLANTED) { B->m_Timer++; // bomb ticking sound int Time = Server()->TickSpeed(); if (Server()->TickSpeed() / 30 + GetTimeLeft()*8 < Time) Time = Server()->TickSpeed() / 20 + GetTimeLeft()*4; if (++m_BombSoundTimer >= Time) { m_BombSoundTimer = 0; GameServer()->CreateSound(B->m_Pos, SOUND_CHAT_SERVER); GameServer()->CreateSound(B->m_Pos, SOUND_CHAT_SERVER); } // bomb defusing //CCharacter *apCloseCCharacters[MAX_CLIENTS]; //int Num = GameServer()->m_World.FindEntities(B->m_Pos, CFlag::ms_PhysSize * 2, (CEntity**)apCloseCCharacters, MAX_CLIENTS, CGameWorld::ENTTYPE_CHARACTER); bool DefusingBomb = false; for (int i = 0; i < MAX_CLIENTS; i++) { CPlayer *pPlayer = GameServer()->m_apPlayers[i]; if(!pPlayer) continue; CCharacter *pCharacter = pPlayer->GetCharacter(); if (!pCharacter) continue; if(!pCharacter->IsAlive() || pPlayer->GetTeam() != m_DefendingTeam) continue; // check distance if (abs(pCharacter->m_Pos.x - B->m_Pos.x) < 150 && abs(pCharacter->m_Pos.y - B->m_Pos.y) < 150 && pCharacter->IsGrounded()) { DefusingBomb = true; m_aDefusing[i] = true; pPlayer->m_InterestPoints += 7; if (m_BombDefuseTimer == 0) { GameServer()->SendBroadcast("Defusing bomb", pPlayer->GetCID()); //GameServer()->CreateSoundGlobal(SOUND_CTF_DROP, pPlayer->GetCID()); } } else { if (m_aDefusing[i]) { m_aDefusing[i] = false; GameServer()->SendBroadcast("", pPlayer->GetCID()); } } } if (DefusingBomb) { // bomb defusing sound if (++m_BombActionTimer >= Server()->TickSpeed()/4) { m_BombActionTimer = 0; GameServer()->CreateSound(B->m_Pos, SOUND_BODY_LAND); } if (++m_BombDefuseTimer >= g_Config.m_SvBombDefuseTime*Server()->TickSpeed()) { B->m_Hide = true; m_BombDefused = true; if (m_DefendingTeam == TEAM_RED) GameServer()->SendBroadcast("Bomb defused - Terrorists score!", -1, true); if (m_DefendingTeam == TEAM_BLUE) GameServer()->SendBroadcast("Bomb defused - Counter-terrorists score!", -1, true); GameServer()->CreateSoundGlobal(SOUND_CTF_GRAB_PL, -1); m_RoundTimeLimit = 0; // gamecontroller m_ResetTime = true; // gamecontroller } } else { m_BombDefuseTimer = 0; } return; } else { for (int c = 0; c < MAX_CLIENTS; c++) { bool BombPlantable = false; CPlayer *pPlayer = GameServer()->m_apPlayers[c]; if(!pPlayer) continue; if(pPlayer->GetTeam() == m_DefendingTeam) continue; CCharacter *pCharacter = pPlayer->GetCharacter(); if (!pCharacter) continue; if(!pCharacter->IsAlive() || pPlayer->GetTeam() == m_DefendingTeam) continue; if (m_Base >= 0) { if (m_apBombArea[m_Base] && !m_apBombArea[m_Base]->m_Hide) { // check distance if (abs(m_apBombArea[m_Base]->m_Pos.x - pCharacter->m_Pos.x) < 200 && abs(m_apBombArea[m_Base]->m_Pos.y - pCharacter->m_Pos.y) < 200 && pCharacter->IsGrounded()) { BombPlantable = true; //GameServer()->SendBroadcast("Inside range", pPlayer->GetCID()); if (pCharacter->m_BombStatus != BOMB_PLANTING) { pCharacter->m_BombStatus = BOMB_PLANTING; m_aPlanting[c] = 0; GameServer()->SendBroadcast("Planting bomb", pPlayer->GetCID()); } else if (pCharacter->m_BombStatus == BOMB_PLANTING) { // bomb planting sound if (++m_aBombActionTimer[c] >= Server()->TickSpeed()/4) { m_aBombActionTimer[c] = 0; GameServer()->CreateSound(B->m_Pos, SOUND_BODY_LAND); } pPlayer->m_InterestPoints += 6; if (++m_aPlanting[c] >= g_Config.m_SvBombPlantTime*Server()->TickSpeed()) { pPlayer->m_InterestPoints += 120; B->m_pCarryingCharacter = NULL; B->m_Status = BOMB_PLANTED; pCharacter->m_BombStatus = BOMB_PLANTED; m_aPlanting[c] = 0; B->m_Timer = 0; GameServer()->SendBroadcast("Bomb planted!", -1, true); GameServer()->CreateSoundGlobal(SOUND_CTF_GRAB_PL, -1); B->m_Hide = false; B->m_Pos = pCharacter->m_Pos; B->m_Owner = c; m_RoundTimeLimit = g_Config.m_SvBombTime; // gamecontroller m_ResetTime = true; // gamecontroller return; } } } } } if (!BombPlantable) { pCharacter->m_BombStatus = BOMB_CARRYING; if (m_aPlanting[c] > 0) GameServer()->SendBroadcast("", c); m_aPlanting[c] = 0; } } } // don't add anything relevant here! possible return; above! }
void CGameControllerCSBB::CaptureBase() { if (m_Base < 0 || m_Base >= m_BombAreaCount) { NewBase(); return; } if (!m_apBombArea[m_Base]) { NewBase(); return; } bool Red = false; bool Blue = false; // check for players within base range for (int i = 0; i < MAX_CLIENTS; i++) { CPlayer *pPlayer = GameServer()->m_apPlayers[i]; if(!pPlayer) continue; CCharacter *pCharacter = pPlayer->GetCharacter(); if (!pCharacter) continue; if (!pCharacter->IsAlive()) continue; if (distance(m_apBombArea[m_Base]->m_Pos, pCharacter->m_Pos) < g_Config.m_SvBaseCaptureDistance && pCharacter->m_Pos.y < m_apBombArea[m_Base]->m_Pos.y+48) { if (pPlayer->GetTeam() == TEAM_RED) Red = true; if (pPlayer->GetTeam() == TEAM_BLUE) Blue = true; } } if (Red && Blue) { m_RedCaptureTime = 0; m_BlueCaptureTime = 0; } if (!Red) { m_RedCaptureTime = 0; if (Blue) { // blue team capturing the base m_BlueCaptureTime++; } } if (!Blue) { m_BlueCaptureTime = 0; if (Red) { // red team capturing the base m_RedCaptureTime++; } } // broadcast to players capturing the base for (int i = 0; i < MAX_CLIENTS; i++) { CPlayer *pPlayer = GameServer()->m_apPlayers[i]; if(!pPlayer) continue; CCharacter *pCharacter = pPlayer->GetCharacter(); if (!pCharacter) continue; if (!pCharacter->IsAlive() || pPlayer->m_IsBot) continue; if (((pPlayer->GetTeam() == TEAM_RED && Red && !Blue) || (pPlayer->GetTeam() == TEAM_BLUE && Blue && !Red)) && (distance(m_apBombArea[m_Base]->m_Pos, pCharacter->m_Pos) < g_Config.m_SvBaseCaptureDistance && pCharacter->m_Pos.y < m_apBombArea[m_Base]->m_Pos.y+48)) { pPlayer->m_BroadcastingCaptureStatus = true; GameServer()->SendBroadcast("Capturing the base", pPlayer->GetCID()); } else if (pPlayer->m_BroadcastingCaptureStatus) { pPlayer->m_BroadcastingCaptureStatus = false; GameServer()->SendBroadcast("", pPlayer->GetCID()); } } bool BaseCaptured = false; if (m_RedCaptureTime > g_Config.m_SvBaseCaptureTime*Server()->TickSpeed()) { GameServer()->SendBroadcast("Terrorists captured the base!", -1, true); BaseCaptured = true; m_DefendingTeam = TEAM_RED; for (int i = 0; i < MAX_BOMBAREAS; i++) { if (m_apBombArea[i]) m_apBombArea[i]->m_Team = TEAM_RED; } if (m_pBomb) m_pBomb->m_Team = TEAM_BLUE; } else if (m_BlueCaptureTime > g_Config.m_SvBaseCaptureTime*Server()->TickSpeed()) { GameServer()->SendBroadcast("Counter-terrorists captured the base!", -1, true); BaseCaptured = true; m_DefendingTeam = TEAM_BLUE; for (int i = 0; i < MAX_BOMBAREAS; i++) { if (m_apBombArea[i]) m_apBombArea[i]->m_Team = TEAM_BLUE; } if (m_pBomb) m_pBomb->m_Team = TEAM_RED; } if (BaseCaptured) { m_BlueCaptureTime = 0; m_RedCaptureTime = 0; m_GameState = CSBB_DEFENDING; m_RoundTick = 0; m_RoundTimeLimit = g_Config.m_SvRoundTime; m_ResetTime = true; GameServer()->CreateSoundGlobal(SOUND_CTF_CAPTURE, -1); GiveBombToPlayer(); } }
extern type_length TmpLoc( name *base, name *op ) /***********************************************/ { return( NewBase( base ) + op->v.offset - base->v.offset ); }