static void SP_worldspawn (const localEntityParse_t *entData) { const int dayLightmap = CL_GetConfigStringInteger(CS_LIGHTMAP); int i; /* maximum level */ cl.mapMaxLevel = entData->maxLevel; if (GAME_IsMultiplayer()) { if (cl_teamnum->integer > entData->maxMultiplayerTeams || cl_teamnum->integer <= TEAM_CIVILIAN) { Com_Printf("The selected team is not usable. " "The map doesn't support %i teams but only %i teams\n", cl_teamnum->integer, entData->maxMultiplayerTeams); Cvar_SetValue("cl_teamnum", TEAM_DEFAULT); Com_Printf("Set teamnum to %i\n", cl_teamnum->integer); } } /** @todo - make sun position/color vary based on local time at location? */ if (dayLightmap) VectorCopy(entData->ambientDayColor, sun.ambientColor); else VectorCopy(entData->ambientNightColor, sun.ambientColor); /* clamp it */ for (i = 0; i < 3; i++) if (sun.ambientColor[i] < MIN_AMBIENT_COMPONENT) sun.ambientColor[i] = MIN_AMBIENT_COMPONENT; /* scale it into a reasonable range, the clamp above ensures this will work */ while (VectorSum(sun.ambientColor) < MIN_AMBIENT_SUM) VectorScale(sun.ambientColor, 1.25, sun.ambientColor); /* set up "global" (ie. directional) light sources */ Vector4Set(sun.loc, 0, 0, -1, 0.0); sun.constantAttenuation = 1.0; sun.linearAttenuation = 0.0; sun.quadraticAttenuation = 0.0; sun.enabled = qtrue; if (dayLightmap) { /* sunlight color */ Vector4Set(sun.diffuseColor, 0.8, 0.8, 0.8, 1); Vector4Set(sun.specularColor, 1.0, 1.0, 0.9, 1); } else { /* moonlight color */ Vector4Set(sun.diffuseColor, 0.2, 0.2, 0.3, 1); Vector4Set(sun.specularColor, 0.5, 0.5, 0.7, 1); } /** @todo Parse fog from worldspawn config */ refdef.weather = WEATHER_NONE; refdef.fogColor[3] = 1.0; VectorSet(refdef.fogColor, 0.75, 0.75, 0.75); }
/** * @brief Fix actorskin idx according to game mode */ static int CL_FixActorSkinIDX (int idx) { const actorSkin_t* skin = CL_GetActorSkinByIDS(idx); /** @todo we should check somewhere there is at least 1 skin */ if (skin == nullptr) { idx = 0; } else { if (GAME_IsSingleplayer() && !skin->singleplayer) idx = 0; else if (GAME_IsMultiplayer() && !skin->multiplayer) idx = 0; } return idx; }
/** * @brief Generates the skills and inventory for a character and for a 2x2 unit * @param[in] chr The employee to create character data for. * @param[in] teamDefName Which team to use for creation. */ void CL_GenerateCharacter (character_t* chr, const char* teamDefName) { chr->init(); /* link inventory */ cls.i.destroyInventory(&chr->inv); /* get ucn */ chr->ucn = cls.nextUniqueCharacterNumber++; chr->reservedTus.shotSettings.set(ACTOR_HAND_NOT_SET, -1, nullptr); Com_GetCharacterValues(teamDefName, chr); /* Create attributes. */ CHRSH_CharGenAbilitySkills(chr, GAME_IsMultiplayer()); }
/** * @brief Generates the skills and inventory for a character and for a 2x2 unit * @param[in] chr The employee to create character data for. * @param[in] teamDefName Which team to use for creation. */ void CL_GenerateCharacter (character_t *chr, const char *teamDefName) { OBJZERO(*chr); /* link inventory */ cls.i.DestroyInventory(&cls.i, &chr->i); /* get ucn */ chr->ucn = cls.nextUniqueCharacterNumber++; CL_ActorSetShotSettings(chr, ACTOR_HAND_NOT_SET, -1, NULL); Com_GetCharacterValues(teamDefName, chr); /* Create attributes. */ CHRSH_CharGenAbilitySkills(chr, GAME_IsMultiplayer()); }
/** * @sa CL_Frame */ static void CL_SendCommand (void) { /* get new key events */ IN_SendKeyEvents(); /* process console commands */ Cbuf_Execute(); /* send intentions now */ CL_SendChangedUserinfos(); /* fix any cheating cvars */ Cvar_FixCheatVars(); switch (cls.state) { case ca_disconnected: /* if the local server is running and we aren't connected then connect */ if (Com_ServerState()) { cls.servername[0] = '\0'; cls.serverport[0] = '\0'; CL_SetClientState(ca_connecting); return; } break; case ca_connecting: if (CL_Milliseconds() - cls.connectTime > cl_connecttimeout->integer) { if (GAME_IsMultiplayer()) Com_Error(ERR_DROP, "Server is not reachable"); } break; case ca_connected: if (cls.waitingForStart) { if (CL_Milliseconds() - cls.waitingForStart > cl_connecttimeout->integer) { Com_Error(ERR_DROP, "Server aborted connection - the server didn't response in %is. You can try to increase the cvar cl_connecttimeout", cl_connecttimeout->integer / 1000); } else { SCR_DrawLoading(100); } } break; default: break; } }
/** @note Defaults should match those of ufo2map, or lighting will be inconsistent between world and models */ static void SP_worldspawn (const localEntityParse_t* entData) { /* maximum level */ cl.mapMaxLevel = entData->maxLevel; if (GAME_IsMultiplayer()) { if (cl_teamnum->integer > entData->maxMultiplayerTeams || cl_teamnum->integer <= TEAM_CIVILIAN) { Com_Printf("The selected team is not usable. " "The map doesn't support %i teams but only %i teams\n", cl_teamnum->integer, entData->maxMultiplayerTeams); Cvar_SetValue("cl_teamnum", TEAM_DEFAULT); Com_Printf("Set teamnum to %i\n", cl_teamnum->integer); } } /** @todo - make sun position/color vary based on local time at location? */ const int dayLightmap = CL_GetConfigStringInteger(CS_LIGHTMAP); /** @note Some vectors have exra elements to comply with mathlib and/or OpenGL conventions, but handled as shorter ones */ vec3_t sunAngles; vec4_t sunColor; vec_t sunIntensity; if (dayLightmap) { /* set defaults for daylight */ Vector4Set(refdef.ambientColor, 0.26, 0.26, 0.26, 1.0); sunIntensity = 280; VectorSet(sunAngles, -75, 100, 0); Vector4Set(sunColor, 0.90, 0.75, 0.65, 1.0); /* override defaults with data from worldspawn entity, if any */ if (VectorNotEmpty(entData->ambientDayColor)) VectorCopy(entData->ambientDayColor, refdef.ambientColor); if (entData->dayLight) sunIntensity = entData->dayLight; if (Vector2NotEmpty(entData->daySunAngles)) Vector2Copy(entData->daySunAngles, sunAngles); if (VectorNotEmpty(entData->daySunColor)) VectorCopy(entData->daySunColor, sunColor); Vector4Set(refdef.sunSpecularColor, 1.0, 1.0, 0.9, 1); } else { /* set defaults for night light */ Vector4Set(refdef.ambientColor, 0.16, 0.16, 0.17, 1.0); sunIntensity = 15; VectorSet(sunAngles, -80, 220, 0); Vector4Set(sunColor, 0.25, 0.25, 0.35, 1.0); /* override defaults with data from worldspawn entity, if any */ if (VectorNotEmpty(entData->ambientNightColor)) VectorCopy(entData->ambientNightColor, refdef.ambientColor); if (entData->nightLight) sunIntensity = entData->nightLight; if (Vector2NotEmpty(entData->nightSunAngles)) Vector2Copy(entData->nightSunAngles, sunAngles); if (VectorNotEmpty(entData->nightSunColor)) VectorCopy(entData->nightSunColor, sunColor); Vector4Set(refdef.sunSpecularColor, 0.5, 0.5, 0.7, 1); } ColorNormalize(sunColor, sunColor); VectorScale(sunColor, sunIntensity/255.0, sunColor); Vector4Copy(sunColor, refdef.sunDiffuseColor); /* clamp ambient for models */ Vector4Copy(refdef.ambientColor, refdef.modelAmbientColor); for (int i = 0; i < 3; i++) if (refdef.modelAmbientColor[i] < MIN_AMBIENT_COMPONENT) refdef.modelAmbientColor[i] = MIN_AMBIENT_COMPONENT; /* scale it into a reasonable range, the clamp above ensures this will work */ while (VectorSum(refdef.modelAmbientColor) < MIN_AMBIENT_SUM) VectorScale(refdef.modelAmbientColor, 1.25, refdef.modelAmbientColor); AngleVectors(sunAngles, refdef.sunVector, nullptr, nullptr); refdef.sunVector[3] = 0.0; /* to use as directional light source in OpenGL */ /** @todo Parse fog from worldspawn config */ refdef.weather = WEATHER_NONE; refdef.fogColor[3] = 1.0; VectorSet(refdef.fogColor, 0.75, 0.75, 0.75); }