int FColorCVar::ToInt2 (UCVarValue value, ECVarType type) { int ret; if (type == CVAR_String) { FString string; // Only allow named colors after the screen exists (i.e. after // we've got some lumps loaded, so X11R6RGB can be read). Since // the only time this might be called before that is when loading // zdoom.ini, this shouldn't be a problem. if (screen && !(string = V_GetColorStringByName (value.String)).IsEmpty() ) { ret = V_GetColorFromString (NULL, string); } else { ret = V_GetColorFromString (NULL, value.String); } } else { ret = ToInt (value, type); } return ret; }
void D_SetupUserInfo(void) { UserInfo* coninfo = &consoleplayer().userinfo; std::string netname = cl_name.str(); if (netname.length() > MAXPLAYERNAME) netname.erase(MAXPLAYERNAME); coninfo->netname = netname; coninfo->team = D_TeamByName (cl_team.cstring()); // [Toke - Teams] coninfo->color = V_GetColorFromString (NULL, cl_color.cstring()); coninfo->gender = D_GenderByName (cl_gender.cstring()); coninfo->aimdist = (fixed_t)(cl_autoaim * 16384.0); coninfo->unlag = (cl_unlag != 0); coninfo->update_rate = cl_updaterate; coninfo->predict_weapons = (cl_predictweapons != 0); // sanitize the weapon switching choice if (cl_switchweapon < 0 || cl_switchweapon > 2) cl_switchweapon.ForceSet(float(WPSW_ALWAYS)); coninfo->switchweapon = (weaponswitch_t)cl_switchweapon.asInt(); // Copies the updated cl_weaponpref* cvars to coninfo->weapon_prefs[] D_PrepareWeaponPreferenceUserInfo(); }
void D_SetupUserInfo(void) { userinfo_t *coninfo = &consoleplayer().userinfo; // Save the previous weapon preferences weapontype_t backup_weapon_prefs[NUMWEAPONS]; memcpy(backup_weapon_prefs, coninfo->weapon_prefs, sizeof(backup_weapon_prefs)); memset (&consoleplayer().userinfo, 0, sizeof(userinfo_t)); strncpy (coninfo->netname, cl_name.cstring(), MAXPLAYERNAME); coninfo->team = D_TeamByName (cl_team.cstring()); // [Toke - Teams] coninfo->color = V_GetColorFromString (NULL, cl_color.cstring()); coninfo->skin = R_FindSkin (cl_skin.cstring()); coninfo->gender = D_GenderByName (cl_gender.cstring()); coninfo->aimdist = (fixed_t)(cl_autoaim * 16384.0); coninfo->unlag = cl_unlag; coninfo->update_rate = cl_updaterate; coninfo->switchweapon = (weaponswitch_t)cl_switchweapon.asInt(); // Copies the updated cl_weaponpref* cvars to coninfo->weapon_prefs[] CL_PrepareWeaponPreferenceUserInfo(); // Find which weapon preference slot was changed for (size_t i = 0; i < NUMWEAPONS; i++) { if (backup_weapon_prefs[i] != coninfo->weapon_prefs[i]) { // slot i was changed weapontype_t oldweapon = backup_weapon_prefs[i]; weapontype_t newweapon = coninfo->weapon_prefs[i]; // swap the weapon in slot i with whatever slot already has newweapon for (size_t j = 0; j < NUMWEAPONS; j++) { if (coninfo->weapon_prefs[j] == newweapon && j != i) { coninfo->weapon_prefs[j] = oldweapon; CL_SetWeaponPreferenceCvar(j, oldweapon); break; } } break; } } }
void DCanvas::Dim () const { if (ui_dimamount < 0) ui_dimamount.Set (0.0f); else if (ui_dimamount > 1) ui_dimamount.Set (1.0f); if (ui_dimamount == 0) return; if (is8bit()) { unsigned int *bg2rgb; unsigned int fg; int gap; byte *spot; int x, y; { unsigned int *fg2rgb; fixed_t amount; amount = (fixed_t)(ui_dimamount * 64); fg2rgb = Col2RGB8[amount]; bg2rgb = Col2RGB8[64-amount]; fg = fg2rgb[V_GetColorFromString (DefaultPalette->basecolors, ui_dimcolor.cstring())]; } spot = buffer; gap = pitch - width; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { unsigned int bg = bg2rgb[*spot]; bg = (fg+bg) | 0x1f07c1f; *spot++ = RGB32k[0][0][bg&(bg>>15)]; } spot += gap; } } else {
// // D_DoomMain // void D_DoomMain (void) { unsigned p; extern std::string defdemoname; gamestate = GS_STARTUP; M_FindResponseFile(); // [ML] 23/1/07 - Add Response file support back in if (lzo_init () != LZO_E_OK) // [RH] Initialize the minilzo package. I_FatalError ("Could not initialize LZO routines"); C_ExecCmdLineParams (false, true); // [Nes] test for +logfile command Printf (PRINT_HIGH, "Heapsize: %u megabytes\n", got_heapsize); M_LoadDefaults (); // load before initing other systems C_ExecCmdLineParams (true, false); // [RH] do all +set commands on the command line const char* iwad = Args.CheckValue("-iwad"); if (!iwad) iwad = ""; std::vector<std::string> newwadfiles, newpatchfiles; newwadfiles.push_back(iwad); D_AddWadCommandLineFiles(newwadfiles); D_AddDehCommandLineFiles(newpatchfiles); D_LoadResourceFiles(newwadfiles, newpatchfiles); I_Init(); V_Init(); atterm(V_Close); #ifdef _WIN32 const char *sdlv = getenv("SDL_VIDEODRIVER"); Printf (PRINT_HIGH, "Using %s video driver.\n",sdlv); #endif C_InitConsole(screen->width, screen->height, true); atterm(C_ShutdownConsole); // SDL needs video mode set up first before input code can be used I_InitInput(); D_Init(); atterm(D_Shutdown); // Base systems have been inited; enable cvar callbacks cvar_t::EnableCallbacks(); // [RH] User-configurable startup strings. Because BOOM does. if (GStrings(STARTUP1)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP1)); if (GStrings(STARTUP2)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP2)); if (GStrings(STARTUP3)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP3)); if (GStrings(STARTUP4)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP4)); if (GStrings(STARTUP5)[0]) Printf (PRINT_HIGH, "%s\n", GStrings(STARTUP5)); // Nomonsters sv_nomonsters = Args.CheckParm("-nomonsters"); // Respawn sv_monstersrespawn = Args.CheckParm("-respawn"); // Fast sv_fastmonsters = Args.CheckParm("-fast"); // developer mode devparm = Args.CheckParm ("-devparm"); // Record a vanilla demo p = Args.CheckParm ("-record"); if (p) { autorecord = true; autostart = true; demorecordfile = Args.GetArg (p+1); } // get skill / episode / map from parms strcpy (startmap, (gameinfo.flags & GI_MAPxx) ? "MAP01" : "E1M1"); // Check for -playdemo, play a single demo then quit. p = Args.CheckParm ("-playdemo"); // Hack to check for +playdemo command, since if you just add it normally // it won't run because it's attempting to run a demo and still set up the // first map as normal. if (!p) p = Args.CheckParm ("+playdemo"); if (p && p < Args.NumArgs()-1) { Printf (PRINT_HIGH, "Playdemo parameter found on command line.\n"); singledemo = true; defdemoname = Args.GetArg (p+1); } // [SL] check for -timedemo (was removed at some point) p = Args.CheckParm("-timedemo"); if (p && p < Args.NumArgs() - 1) { singledemo = true; G_TimeDemo(Args.GetArg(p + 1)); } const char *val = Args.CheckValue ("-skill"); if (val) { sv_skill.Set (val[0]-'0'); } p = Args.CheckParm ("-warp"); if (p && p < Args.NumArgs() - (1+(gameinfo.flags & GI_MAPxx ? 0 : 1))) { int ep, map; if (gameinfo.flags & GI_MAPxx) { ep = 1; map = atoi (Args.GetArg(p+1)); } else { ep = Args.GetArg(p+1)[0]-'0'; map = Args.GetArg(p+2)[0]-'0'; } strncpy (startmap, CalcMapName (ep, map), 8); autostart = true; } // [RH] Hack to handle +map p = Args.CheckParm ("+map"); if (p && p < Args.NumArgs()-1) { strncpy (startmap, Args.GetArg (p+1), 8); ((char *)Args.GetArg (p))[0] = '-'; autostart = true; } if (devparm) Printf (PRINT_HIGH, "%s", GStrings(D_DEVSTR)); // D_DEVSTR // [RH] Now that all text strings are set up, // insert them into the level and cluster data. G_SetLevelStrings(); // [RH] Parse through all loaded mapinfo lumps G_ParseMapInfo(); // [ML] Parse musinfo lump G_ParseMusInfo(); // [RH] Parse any SNDINFO lumps S_ParseSndInfo(); // NOTE(jsd): Set up local player color EXTERN_CVAR(cl_color); R_BuildPlayerTranslation (0, V_GetColorFromString (NULL, cl_color.cstring())); I_FinishClockCalibration (); Printf (PRINT_HIGH, "D_CheckNetGame: Checking network game status.\n"); D_CheckNetGame (); // [RH] Initialize items. Still only used for the give command. :-( InitItems (); // [RH] Lock any cvars that should be locked now that we're // about to begin the game. cvar_t::EnableNoSet (); // [RH] Now that all game subsystems have been initialized, // do all commands on the command line other than +set C_ExecCmdLineParams (false, false); Printf_Bold("\n\35\36\36\36\36 Odamex Client Initialized \36\36\36\36\37\n"); if(gamestate != GS_CONNECTING) Printf(PRINT_HIGH, "Type connect <address> or use the Odamex Launcher to connect to a game.\n"); Printf(PRINT_HIGH, "\n"); setmodeneeded = false; // [Fly] we don't need to set a video mode here! //gamestate = GS_FULLCONSOLE; // [SL] allow the user to pass the name of a netdemo as the first argument. // This allows easy launching of netdemos from Windows Explorer or other GUIs. // [Xyltol] if (Args.GetArg(1)) { std::string demoarg = Args.GetArg(1); if (demoarg.find(".odd") != std::string::npos) CL_NetDemoPlay(demoarg); } p = Args.CheckParm("-netplay"); if (p) { if (Args.GetArg(p + 1)) { std::string filename = Args.GetArg(p + 1); CL_NetDemoPlay(filename); } else { Printf(PRINT_HIGH, "No netdemo filename specified.\n"); } } // denis - bring back the demos if ( gameaction != ga_loadgame ) { if (autostart || netgame || singledemo) { if (singledemo) G_DoPlayDemo(); else { if(autostart) { // single player warp (like in g_level) serverside = true; sv_allowexit = "1"; sv_freelook = "1"; sv_allowjump = "1"; sv_allowredscreen = "1"; sv_gametype = GM_COOP; players.clear(); players.push_back(player_t()); players.back().playerstate = PST_REBORN; consoleplayer_id = displayplayer_id = players.back().id = 1; } G_InitNew (startmap); if (autorecord) if (G_RecordDemo(demorecordfile.c_str())) G_BeginRecording(); } } else { if (gamestate != GS_CONNECTING) gamestate = GS_HIDECONSOLE; C_HideConsole(); if (gamemode == commercial_bfg) // DOOM 2 BFG Edtion AddCommandString("menu_main"); D_StartTitle (); // start up intro loop } } // denis - this will run a demo and quit p = Args.CheckParm ("+demotest"); if (p && p < Args.NumArgs()-1) { demotest = 1; defdemoname = Args.GetArg (p+1); G_DoPlayDemo(); while(demoplayback) { DObject::BeginFrame (); G_Ticker(); DObject::EndFrame (); gametic++; } } else { demotest = 0; D_DoomLoop (); // never returns } }
for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { unsigned int bg = bg2rgb[*spot]; bg = (fg+bg) | 0x1f07c1f; *spot++ = RGB32k[0][0][bg&(bg>>15)]; } spot += gap; } } else { int x, y; int *line; int fill = V_GetColorFromString (NULL, ui_dimcolor.cstring()); line = (int *)(screen->buffer); if (ui_dimamount == 1.0) { fill = (fill >> 2) & 0x3f3f3f; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { line[x] = (line[x] - ((line[x] >> 2) & 0x3f3f3f)) + fill; } line += pitch >> 2; } }
static void ParseMapInfoLower (MapInfoHandler *handlers, const char *strings[], level_pwad_info_t *levelinfo, cluster_info_t *clusterinfo, DWORD flags) { int entry; MapInfoHandler *handler; byte *info; info = levelinfo ? (byte *)levelinfo : (byte *)clusterinfo; while (SC_GetString ()) { if (SC_MatchString (MapInfoTopLevel) != -1) { SC_UnGet (); break; } entry = SC_MustMatchString (strings); handler = handlers + entry; switch (handler->type) { case MITYPE_IGNORE: break; case MITYPE_EATNEXT: SC_MustGetString (); break; case MITYPE_INT: SC_MustGetNumber (); *((int *)(info + handler->data1)) = sc_Number; break; case MITYPE_FLOAT: SC_MustGetFloat (); *((float *)(info + handler->data1)) = sc_Float; break; case MITYPE_COLOR: { SC_MustGetString (); std::string string = V_GetColorStringByName (sc_String); if (string.length()) { *((DWORD *)(info + handler->data1)) = V_GetColorFromString (NULL, string.c_str()); } else { *((DWORD *)(info + handler->data1)) = V_GetColorFromString (NULL, sc_String); } } break; case MITYPE_MAPNAME: SC_MustGetString (); if (IsNum (sc_String)) { int map = atoi (sc_String); sprintf (sc_String, "MAP%02d", map); } strncpy ((char *)(info + handler->data1), sc_String, 8); break; case MITYPE_LUMPNAME: SC_MustGetString (); uppercopy ((char *)(info + handler->data1), sc_String); break; case MITYPE_SKY: SC_MustGetString (); // get texture name; uppercopy ((char *)(info + handler->data1), sc_String); SC_MustGetFloat (); // get scroll speed //if (HexenHack) //{ // *((fixed_t *)(info + handler->data2)) = sc_Number << 8; //} //else //{ // *((fixed_t *)(info + handler->data2)) = (fixed_t)(sc_Float * 65536.0f); //} break; case MITYPE_SETFLAG: flags |= handler->data1; break; case MITYPE_SCFLAGS: flags = (flags & handler->data2) | handler->data1; break; case MITYPE_CLUSTER: SC_MustGetNumber (); *((int *)(info + handler->data1)) = sc_Number; if (HexenHack) { cluster_info_t *clusterH = FindClusterInfo (sc_Number); if (clusterH) clusterH->flags |= CLUSTER_HUB; } break; case MITYPE_STRING: SC_MustGetString (); ReplaceString ((const char **)(info + handler->data1), sc_String); break; case MITYPE_CSTRING: SC_MustGetString (); strncpy ((char *)(info + handler->data1), sc_String, handler->data2); *((char *)(info + handler->data1 + handler->data2)) = '\0'; break; } } if (levelinfo) levelinfo->flags = flags; else clusterinfo->flags = flags; }
void DCanvas::Dim(int x1, int y1, int w, int h) const { if (!buffer) return; if (x1 < 0 || x1 + w > width || y1 < 0 || y1 + h > height) return; if (ui_dimamount < 0) ui_dimamount.Set (0.0f); else if (ui_dimamount > 1) ui_dimamount.Set (1.0f); if (ui_dimamount == 0) return; if (is8bit()) { int bg; int x, y; fixed_t amount = (fixed_t)(ui_dimamount * 64); unsigned int *fg2rgb = Col2RGB8[amount]; unsigned int *bg2rgb = Col2RGB8[64-amount]; unsigned int fg = fg2rgb[V_GetColorFromString(DefaultPalette->basecolors, ui_dimcolor.cstring())]; byte *dest = buffer + y1 * pitch + x1; int gap = pitch - w; int xcount = w / 4; int xcount_remainder = w % 4; for (y = h; y > 0; y--) { for (x = xcount; x > 0; x--) { // Unroll the loop for a speed improvement bg = bg2rgb[*dest]; bg = (fg+bg) | 0x1f07c1f; *dest++ = RGB32k[0][0][bg&(bg>>15)]; bg = bg2rgb[*dest]; bg = (fg+bg) | 0x1f07c1f; *dest++ = RGB32k[0][0][bg&(bg>>15)]; bg = bg2rgb[*dest]; bg = (fg+bg) | 0x1f07c1f; *dest++ = RGB32k[0][0][bg&(bg>>15)]; bg = bg2rgb[*dest]; bg = (fg+bg) | 0x1f07c1f; *dest++ = RGB32k[0][0][bg&(bg>>15)]; } for (x = xcount_remainder; x > 0; x--) { // account for widths that aren't multiples of 4 bg = bg2rgb[*dest]; bg = (fg+bg) | 0x1f07c1f; *dest++ = RGB32k[0][0][bg&(bg>>15)]; } dest += gap; } } else {
void D_ReadUserInfoStrings (int i, BYTE **stream, bool update) { userinfo_t *info = &players[i].userinfo; const char *ptr = *((const char **)stream); const char *breakpt; FString value; bool compact; int infotype = -1; if (*ptr++ != '\\') return; compact = (*ptr == '\\') ? ptr++, true : false; if (i < MAXPLAYERS) { for (;;) { int j; breakpt = strchr (ptr, '\\'); if (compact) { value = D_UnescapeUserInfo(ptr, breakpt != NULL ? breakpt - ptr : strlen(ptr)); infotype++; } else { assert(breakpt != NULL); // A malicious remote machine could invalidate the above assert. if (breakpt == NULL) { break; } const char *valstart = breakpt + 1; if ( (breakpt = strchr (valstart, '\\')) != NULL ) { value = D_UnescapeUserInfo(valstart, breakpt - valstart); } else { value = D_UnescapeUserInfo(valstart, strlen(valstart)); } for (j = 0; UserInfoStrings[j] && strnicmp (UserInfoStrings[j], ptr, valstart - ptr - 1) != 0; ++j) { } if (UserInfoStrings[j] == NULL) { infotype = -1; } else { infotype = j; } } switch (infotype) { case INFO_Autoaim: { double angles; angles = atof (value); if (angles > 35.f || angles < 0.f) { info->aimdist = ANGLE_1*35; } else { info->aimdist = abs ((int)(angles * (float)ANGLE_1)); } } break; case INFO_Name: { char oldname[MAXPLAYERNAME+1]; strcpy (oldname, info->netname); strncpy (info->netname, value, MAXPLAYERNAME); info->netname[MAXPLAYERNAME] = 0; CleanseString(info->netname); if (update && strcmp (oldname, info->netname) != 0) { Printf ("%s is now known as %s\n", oldname, info->netname); } } break; case INFO_Team: UpdateTeam (i, atoi(value), update); break; case INFO_Color: info->color = V_GetColorFromString (NULL, value); R_BuildPlayerTranslation (i); if (StatusBar != NULL && i == StatusBar->GetPlayer()) { StatusBar->AttachToPlayer (&players[i]); } break; case INFO_Skin: info->skin = R_FindSkin (value, players[i].CurrentPlayerClass); if (players[i].mo != NULL) { if (players[i].cls != NULL && players[i].mo->state->sprite == GetDefaultByType (players[i].cls)->SpawnState->sprite) { // Only change the sprite if the player is using a standard one players[i].mo->sprite = skins[info->skin].sprite; players[i].mo->scaleX = skins[info->skin].ScaleX; players[i].mo->scaleY = skins[info->skin].ScaleY; } } // Rebuild translation in case the new skin uses a different range // than the old one. R_BuildPlayerTranslation (i); if (StatusBar != NULL && i == StatusBar->GetPlayer()) { StatusBar->SetFace (&skins[info->skin]); } break; case INFO_Gender: info->gender = D_GenderToInt (value); break; case INFO_NeverSwitchOnPickup: if (value[0] >= '0' && value[0] <= '9') { info->neverswitch = atoi (value) ? true : false; } else if (stricmp (value, "true") == 0) { info->neverswitch = 1; } else { info->neverswitch = 0; } break; case INFO_MoveBob: info->MoveBob = (fixed_t)(atof (value) * 65536.f); break; case INFO_StillBob: info->StillBob = (fixed_t)(atof (value) * 65536.f); break; case INFO_PlayerClass: info->PlayerClass = D_PlayerClassToInt (value); break; default: break; } if (breakpt) { ptr = breakpt + 1; } else { break; } } } *stream += strlen (*((char **)stream)) + 1; }
} for (x = xcount_remainder; x > 0; x--) { // account for widths that aren't multiples of 4 bg = bg2rgb[*dest]; bg = (fg+bg) | 0x1f07c1f; *dest++ = RGB32k[0][0][bg&(bg>>15)]; } dest += gap; } } else { int x, y; int *line; int fill = V_GetColorFromString (NULL, color); line = (int *)(screen->buffer); if (famount == 1.0f) { fill = (fill >> 2) & 0x3f3f3f; for (y = y1; y < y1 + h; y++) { for (x = x1; x < x1 + w; x++) { line[x] = (line[x] - ((line[x] >> 2) & 0x3f3f3f)) + fill; } line += pitch >> 2; } }