/*************************************************************************** * \brief main * \return void ***************************************************************************/ void main (void) { int timerHandlerArray[ST_COUNT]; initInterrupt(); ST_Init(); timerHandlerArray[0] = ST_Create(INTERVAL, fkt0); timerHandlerArray[1] = ST_Create(ONESHOT, fkt1); timerHandlerArray[0] = ST_Start(timerHandlerArray[0], 10000); // 10s while(1) { if(stateRegister.restart) { printf("Restart Taste geduerckt\n"); stateRegister.restart = 0; } if(stateRegister.shoot & 0x02) { printf("Schuss-Taste gedrueckt"); if(!(stateRegister.shoot & 0x04)) { printf(" - Schuss abgesetzt"); stateRegister.shoot |= 0x04; //WeaponDelay aktiviert timerHandlerArray[1] = ST_Start(timerHandlerArray[1], 500); // 0.5s } printf("\n"); stateRegister.shoot &= 0x05; //Bit von Schuss-Taste lschen } if(stateRegister.move) { printf("An Drehschalter gedreht: "); if(stateRegister.move & SI_MOVE_LEFT) printf("Nach links\n"); else if(stateRegister.move & SI_MOVE_RIGHT) printf("Nach rechts\n"); else printf("Fehler\n"); stateRegister.move = 0; } } }
void P_Start(void) { TimeMark1 = 0; /* Init the static timers */ TimeMark2 = 0; TimeMark4 = 0; players.AutomapFlags &= AF_GODMODE; /* No automapping specials (but allow godmode) */ AM_Start(); /* Start the automap system */ ST_Start(); /* Init the status bar this level */ G_DoLoadLevel(); /* Load a level into memory */ Randomize(); /* Reset the random number generator */ S_StartSong(Song_e1m1-1+gamemap,TRUE); }
void NetDemo::readSnapshotData(byte *buf, size_t length) { byte cid = consoleplayer_id; byte did = displayplayer_id; P_ClearAllNetIds(); // Remove all players players.clear(); // Remove all actors TThinkerIterator<AActor> iterator; AActor *mo; while ( (mo = iterator.Next() ) ) mo->Destroy(); gameaction = ga_nothing; FLZOMemFile memfile; length = 0; memfile.Open(buf); // open for reading FArchive arc(memfile); // Read the server cvars byte vars[4096], *vars_p; vars_p = vars; size_t len = arc.ReadCount (); arc.Read(vars, len); cvar_t::C_ReadCVars(&vars_p); std::string mapname; bool intermission; arc >> mapname; arc >> intermission; G_SerializeSnapshots(arc); P_SerializeRNGState(arc); P_SerializeACSDefereds(arc); // Read the status of flags in CTF for (int i = 0; i < NUMFLAGS; i++) arc >> CTFdata[i]; // Read team points for (int i = 0; i < NUMTEAMS; i++) arc >> TEAMpoints[i]; arc >> level.time; for (int i = 0; i < NUM_WORLDVARS; i++) arc >> ACS_WorldVars[i]; for (int i = 0; i < NUM_GLOBALVARS; i++) arc >> ACS_GlobalVars[i]; netgame = multiplayer = true; // load a base level savegamerestore = true; // Use the player actors in the savegame serverside = false; G_InitNew(mapname.c_str()); displayplayer_id = consoleplayer_id = 1; savegamerestore = false; // read consistancy marker byte check; arc >> check; arc.Close(); if (check != 0x1d) error("Bad snapshot"); consoleplayer_id = cid; // try to restore display player player_t *disp = &idplayer(did); if (validplayer(*disp) && disp->ingame() && !disp->spectator) displayplayer_id = did; else displayplayer_id = cid; // restore player colors for (size_t i = 0; i < players.size(); i++) R_BuildPlayerTranslation(players[i].id, players[i].userinfo.color); // Link the CTF flag actors to CTFdata[i].actor TThinkerIterator<AActor> flagiterator; while ( (mo = flagiterator.Next() ) ) { if (mo->type == MT_BDWN || mo->type == MT_BCAR) CTFdata[it_blueflag].actor = mo->ptr(); if (mo->type == MT_RDWN || mo->type == MT_RCAR) CTFdata[it_redflag].actor = mo->ptr(); } // Make sure the status bar is displayed correctly ST_Start(); }
// // P_SpawnPlayer // Called when a player is spawned on the level. // Most of the player structure stays unchanged // between levels. // void P_SpawnPlayer (player_t &player, mapthing2_t *mthing) { // denis - clients should not control spawning if(!serverside) return; // [RH] Things 4001-? are also multiplayer starts. Just like 1-4. // To make things simpler, figure out which player is being // spawned here. player_t *p = &player; // not playing? if(!p->ingame()) return; if (p->playerstate == PST_REBORN || p->playerstate == PST_ENTER) { G_PlayerReborn (*p); // [AM] If we're "reborn" as a spectator, don't touch the keepinventory // flag, but otherwise turn it off. if (!p->spectator) p->keepinventory = false; } AActor *mobj = new AActor (mthing->x << FRACBITS, mthing->y << FRACBITS, ONFLOORZ, MT_PLAYER); // set color translations for player sprites // [RH] Different now: MF_TRANSLATION is not used. mobj->translation = translationtables + 256*p->id; mobj->angle = ANG45 * (mthing->angle/45); mobj->pitch = mobj->roll = 0; mobj->player = p; mobj->health = p->health; // [RH] Set player sprite based on skin if(p->userinfo.skin >= numskins) p->userinfo.skin = 0; mobj->sprite = skins[p->userinfo.skin].sprite; p->fov = 90.0f; p->mo = p->camera = mobj->ptr(); p->playerstate = PST_LIVE; p->refire = 0; p->damagecount = 0; p->bonuscount = 0; p->extralight = 0; p->fixedcolormap = 0; p->viewheight = VIEWHEIGHT; p->xviewshift = 0; p->attacker = AActor::AActorPtr(); consoleplayer().camera = displayplayer().mo; // Set up some special spectator stuff if (p->spectator) { mobj->translucency = 0; p->mo->flags |= MF_SPECTATOR; p->mo->flags2 |= MF2_FLY; p->mo->flags &= ~MF_SOLID; } // [RH] Allow chasecam for demo watching if ((demoplayback || demonew) && chasedemo) p->cheats = CF_CHASECAM; // setup gun psprite P_SetupPsprites (p); // give all cards in death match mode if (sv_gametype != GM_COOP) { for (int i = 0; i < NUMCARDS; i++) p->cards[i] = true; } if (consoleplayer().camera == p->mo) { // wake up the status bar ST_Start (); } // [RH] If someone is in the way, kill them P_TeleportMove (mobj, mobj->x, mobj->y, mobj->z, true); // [BC] Do script stuff if (serverside) { if (level.behavior != NULL) { if (p->playerstate == PST_ENTER) { level.behavior->StartTypedScripts (SCRIPT_Enter, p->mo); } else if (p->playerstate == PST_REBORN) { level.behavior->StartTypedScripts (SCRIPT_Respawn, p->mo); } } } }