Trunk Sync - r10911

There are a lot of changes here that should probably be examined, namely the Debug Console (which had conflicts) and Yarn's "any resolution" mainhalls code (Which also had conflicts) but for the most part this should be fairly clean.

git-svn-id: svn://svn.icculus.org/fs2open/branches/antipodes@10912 387891d4-d844-0410-90c0-e4c51a9137d3
This commit is contained in:
Zacam authored and niffiwan committed 2014-09-11 19:22:13 +10:00
1 parent 4e5715058e
commit 4952b70488
233 files changed
+9496 -6010

No files matched your search

+4 -1
View File
@@ -263,7 +263,10 @@ FS2_SOURCES = \
debris/debris.cpp \
debris/debris.h \
debugconsole/console.cpp \
debugconsole/dbugfile.h \
debugconsole/console.h \
debugconsole/consolecmds.cpp \
debugconsole/consoleparse.cpp \
debugconsole/consoleparse.h \
debugconsole/timerbar.cpp \
debugconsole/timerbar.h \
exceptionhandler/exceptionhandler.cpp \
-7
View File
@@ -75,13 +75,9 @@ void parse_ai_profiles_tbl(const char *filename)
char *saved_Mp = NULL;
char buf[NAME_LENGTH];
// open localization
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0)
{
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", (filename) ? filename : "<default ai_profiles.tbl>", rval));
lcl_ext_close();
return;
}
@@ -514,9 +510,6 @@ void parse_ai_profiles_tbl(const char *filename)
// add tbl/tbm to multiplayer validation list
extern void fs2netd_add_table_validation(const char *tblname);
fs2netd_add_table_validation(filename);
// close localization
lcl_ext_close();
}
void ai_profiles_init()
+5 -17
View File
@@ -369,9 +369,13 @@ int ai_big_maybe_follow_subsys_path(int do_dot_check)
object *target_objp;
aip = &Ai_info[Ships[Pl_objp->instance].ai_index];
if ( aip->target_objnum < 0 )
return 0;
target_objp = &Objects[aip->target_objnum];
if ( (aip->targeted_subsys != NULL) && (aip->target_objnum >= 0) && (aip->targeted_subsys->system_info->path_num >= 0) ) {
if ( (aip->targeted_subsys != NULL) && (aip->targeted_subsys->system_info->path_num >= 0) ) {
int subsys_path_num, subsys_in_sight, checked_sight;
float dist;
@@ -742,23 +746,7 @@ void ai_big_maybe_fire_weapons(float dist_to_enemy, float dot_to_enemy, vec3d *f
}
if (tswp->num_secondary_banks > 0) {
int priority1, priority2;
priority1 = -1;
priority2 = -1;
// Maybe favor selecting a bomb.
// Note, if you're firing a bomb, if it's aspect seeking, the firing conditions can be looser.
if (Ship_info[Ships[En_objp->instance].ship_info_index].flags & (SIF_BIG_SHIP | SIF_HUGE_SHIP))
if (En_objp->phys_info.speed * dist_to_enemy < 5000.0f) // Don't select a bomb if enemy moving fast relative to distance
priority1 = WIF_BOMB;
if (!(En_objp->flags & OF_PROTECTED) || (aip->goals[0].ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP))) {
//ai_select_secondary_weapon(Pl_objp, tswp, priority1, priority2); // Note, need to select to get weapon speed and lifetime
if(aip->goals[0].ai_mode & (AI_GOAL_DISABLE_SHIP | AI_GOAL_DISARM_SHIP)) {
priority1 = WIF_PUNCTURE;
}
ai_choose_secondary_weapon(Pl_objp, aip, En_objp);
int current_bank = tswp->current_secondary_bank;
weapon_info *swip = &Weapon_info[tswp->secondary_bank_weapons[current_bank]];
+36 -23
View File
@@ -18,6 +18,7 @@
#include "ai/ai.h"
#include "debugconsole/console.h"
#include "globalincs/linklist.h"
#include "object/object.h"
#include "physics/physics.h"
@@ -780,9 +781,6 @@ void reset_ai_class_names()
#define AI_CLASS_INCREMENT 10
void parse_aitbl()
{
// open localization
lcl_ext_open();
read_file_text("ai.tbl", CF_TYPE_TABLES);
reset_parse();
@@ -814,9 +812,6 @@ void parse_aitbl()
reset_ai_class_names();
}
}
// close localization
lcl_ext_close();
atexit(free_ai_stuff);
}
@@ -836,7 +831,6 @@ void ai_init()
if ((rval = setjmp(parse_abort)) != 0) {
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", "ai.tbl", rval));
lcl_ext_close();
} else {
parse_aitbl();
}
@@ -2303,7 +2297,8 @@ void ai_attack_object(object *attacker, object *attacked, ship_subsys *ssp)
aip->ok_to_target_timestamp = timestamp(DELAY_TARGET_TIME); // No dynamic targeting for 7 seconds.
// Goober5000
if ((temp = find_ignore_new_object_index(aip, aip->target_objnum)) >= 0)
temp = find_ignore_new_object_index(aip, aip->target_objnum);
if (temp >= 0)
{
aip->ignore_new_objnums[temp] = UNUSED_OBJNUM;
}
@@ -6135,7 +6130,9 @@ void render_all_ship_bay_paths(object *objp)
if ( pm->ship_bay == NULL )
return;
for ( i = 0; i < pm->ship_bay->num_paths; i++ ) {
memset(&v, 0, sizeof(v));
for ( i = 0; i < pm->ship_bay->num_paths; i++ ) {
mp = &pm->paths[pm->ship_bay->path_indexes[i]];
for ( j = 0; j < mp->nverts; j++ ) {
@@ -6177,6 +6174,8 @@ void render_all_subsys_paths(object *objp)
if ( pm->ship_bay == NULL )
return;
memset(&v, 0, sizeof(v));
for ( i = 0; i < pm->n_paths; i++ ) {
mp = &pm->paths[i];
@@ -6238,6 +6237,8 @@ void render_path_points(object *objp)
for (i=0; i<num_points; i++) {
vertex v0;
memset(&v0, 0, sizeof(v0));
g3_rotate_vertex( &v0, &pp->pos );
@@ -7368,7 +7369,8 @@ int ai_set_attack_subsystem(object *objp, int subnum)
aip->ignore_objnum = UNUSED_OBJNUM;
// Goober5000
if ((temp = find_ignore_new_object_index(aip, aip->target_objnum)) >= 0)
temp = find_ignore_new_object_index(aip, aip->target_objnum);
if (temp >= 0)
{
aip->ignore_new_objnums[temp] = UNUSED_OBJNUM;
}
@@ -11367,16 +11369,14 @@ float get_wing_largest_radius(object *objp, int formation_object_flag)
float Wing_y_scale = 2.0f;
float Wing_scale = 1.0f;
DCF(wing_y_scale, "")
DCF(wing_y_scale, "Adjusts the wing formation scale along the Y axis (Default is 2.0)")
{
dc_get_arg(ARG_FLOAT);
Wing_y_scale = Dc_arg_float;
dc_stuff_float(&Wing_y_scale);
}
DCF(wing_scale, "")
DCF(wing_scale, "Adjusts the wing formation scale. (Default is 1.0f)")
{
dc_get_arg(ARG_FLOAT);
Wing_scale = Dc_arg_float;
dc_stuff_float(&Wing_scale);
}
/**
@@ -12644,6 +12644,8 @@ int ai_acquire_emerge_path(object *pl_objp, int parent_objnum, int allowed_path_
{
int i, num_allowed_paths = 0, allowed_bay_paths[MAX_SHIP_BAY_PATHS];
memset(allowed_bay_paths, 0, sizeof(allowed_bay_paths));
for (i = 0; i < bay->num_paths; i++)
{
if (allowed_path_mask & (1 << i))
@@ -12892,6 +12894,10 @@ int ai_acquire_depart_path(object *pl_objp, int parent_objnum, int allowed_path_
// take the closest path we can find
ship_bay_path = ai_find_closest_depart_path(aip, pm, allowed_path_mask);
if ( ship_bay_path < 0 )
return -1;
path_index = bay->path_indexes[ship_bay_path];
aip->submode_parm0 = ship_bay_path;
bay->depart_flags |= (1<<ship_bay_path);
@@ -14014,8 +14020,12 @@ void ai_frame(int objnum)
if (target_objnum != -1) {
if (aip->target_objnum != target_objnum)
aip->aspect_locked_time = 0.0f;
set_target_objnum(aip, target_objnum);
En_objp = &Objects[target_objnum];
target_objnum = set_target_objnum(aip, target_objnum);
if (target_objnum >= 0)
{
En_objp = &Objects[target_objnum];
}
}
}
}
@@ -14778,14 +14788,17 @@ int firing_aspect_seeking_bomb(object *objp)
bank_index = swp->current_secondary_bank;
if (bank_index != -1)
if (swp->secondary_bank_ammo[bank_index] > 0) {
if (Weapon_info[swp->secondary_bank_weapons[bank_index]].wi_flags & WIF_BOMB) {
if (Weapon_info[swp->secondary_bank_weapons[bank_index]].wi_flags & WIF_HOMING_ASPECT) {
return 1;
if (bank_index != -1) {
if (swp->secondary_bank_weapons[bank_index] > 0) {
if (swp->secondary_bank_ammo[bank_index] > 0) {
if (Weapon_info[swp->secondary_bank_weapons[bank_index]].wi_flags & WIF_BOMB) {
if (Weapon_info[swp->secondary_bank_weapons[bank_index]].wi_flags & WIF_HOMING_ASPECT) {
return 1;
}
}
}
}
}
return 0;
}
+11 -5
View File
@@ -22,6 +22,7 @@
#include "iff_defs/iff_defs.h"
#include "weapon/muzzleflash.h"
#include "parse/scripting.h"
#include "debugconsole/console.h"
#include <limits.h>
@@ -38,8 +39,7 @@
float Lethality_range_const = 2.0f;
DCF(lethality_range, "N for modifying range: 1 / (1+N) at 100")
{
dc_get_arg(ARG_FLOAT);
Lethality_range_const = Dc_arg_float;
dc_stuff_float(&Lethality_range_const);
}
float Player_lethality_bump[NUM_SKILL_LEVELS] = {
@@ -1466,10 +1466,16 @@ ship_subsys *aifft_list[MAX_AIFFT_TURRETS];
float aifft_rank[MAX_AIFFT_TURRETS];
int aifft_list_size = 0;
int aifft_max_checks = 5;
DCF(mf, "")
DCF(mf, "Adjusts the maximum number of tries an AI may do when trying to pick a subsystem to attack (Default is 5)")
{
dc_get_arg(ARG_INT);
aifft_max_checks = Dc_arg_int;
dc_stuff_int(&aifft_max_checks);
if (aifft_max_checks <= 0) {
dc_printf("Value must be a non-negative, non-zero integer\n");
dc_printf("aifft_max_checks set to default value of 5\n");
aifft_max_checks = 5;
}
}
+7 -3
View File
@@ -196,8 +196,8 @@ anim_instance *anim_play(anim_play_struct *aps)
}
if(aps->base_w < 0 || aps->base_h < 0) {
instance->base_w = gr_screen.max_w_unscaled;
instance->base_h = gr_screen.max_h_unscaled;
instance->base_w = gr_screen.max_w_unscaled_zoomed;
instance->base_h = gr_screen.max_h_unscaled_zoomed;
} else {
instance->base_w = aps->base_w;
instance->base_h = aps->base_h;
@@ -488,6 +488,10 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
// determine x,y to display the bitmap at
if ( instance->world_pos == NULL ) {
int old_max_w_unscaled = gr_screen.max_w_unscaled;
int old_max_h_unscaled = gr_screen.max_h_unscaled;
int old_max_w_unscaled_zoomed = gr_screen.max_w_unscaled_zoomed;
int old_max_h_unscaled_zoomed = gr_screen.max_h_unscaled_zoomed;
gr_set_screen_scale(instance->base_w, instance->base_h);
gr_set_clip(0, 0, instance->base_w, instance->base_h, GR_RESIZE_MENU);
if ( instance->aa_color == NULL ) {
@@ -497,7 +501,7 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
gr_set_color_fast( (color*)instance->aa_color );
gr_aabitmap(instance->x, instance->y, GR_RESIZE_MENU_NO_OFFSET);
}
gr_reset_screen_scale();
gr_set_screen_scale(old_max_w_unscaled, old_max_h_unscaled, old_max_w_unscaled_zoomed, old_max_h_unscaled_zoomed);
gr_reset_clip();
}
else {
+6 -27
View File
@@ -39,6 +39,8 @@
#include "network/multimsgs.h"
#include "network/multi.h"
#include "parse/scripting.h"
#include "debugconsole/console.h"
#include <algorithm>
#include "globalincs/compatibility.h"
@@ -867,12 +869,11 @@ void asteroid_maybe_reposition(object *objp, asteroid_field *asfieldp)
asteroid_wrap_pos(objp, asfieldp);
Asteroids[objp->instance].target_objnum = -1;
vm_vec_normalized_dir(&vec_to_asteroid, &objp->pos, &Eye_position);
dist = vm_vec_normalized_dir(&vec_to_asteroid, &objp->pos, &Eye_position);
dot = vm_vec_dot(&Eye_matrix.vec.fvec, &vec_to_asteroid);
dist = vm_vec_dist_quick(&objp->pos, &Eye_position);
if (( dot > 0.7f) && (dist < 3000.0f)) {
// player would see asteroid pop out other side, so reverse velocity instead of wrapping
// player would see asteroid pop out other side, so reverse velocity instead of wrapping
objp->pos = old_asteroid_pos;
vm_vec_copy_scale(&objp->phys_info.vel, &old_vel, -1.0f);
objp->phys_info.desired_vel = objp->phys_info.vel;
@@ -1404,23 +1405,8 @@ void asteroid_level_close()
Asteroid_field.num_initial_asteroids=0;
}
DCF(asteroids,"Turns asteroids on/off")
{
if ( Dc_command ) {
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);
if ( Dc_arg_type & ARG_TRUE )
Asteroids_enabled = 1;
else if ( Dc_arg_type & ARG_FALSE )
Asteroids_enabled = 0;
else if ( Dc_arg_type & ARG_NONE )
Asteroids_enabled ^= 1;
}
if ( Dc_help )
dc_printf( "Usage: asteroids [bool]\nTurns asteroid system on/off. If nothing passed, then toggles it.\n" );
if ( Dc_status )
dc_printf( "asteroids are %s\n", (Asteroids_enabled?"ON":"OFF") );
}
DCF_BOOL2(asteroids, Asteroids_enabled, "enables or disables asteroids", "Usage: asteroids [bool]\nTurns asteroid system on/off. If nothing passed, then toggles it.\n");
void hud_target_asteroid()
{
@@ -1909,12 +1895,8 @@ void asteroid_parse_tbl()
"are no species for them to belong to."
);
// open localization
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0) {
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", "asteroid.tbl", rval));
lcl_ext_close();
return;
}
@@ -2043,9 +2025,6 @@ void asteroid_parse_tbl()
} else {
Asteroid_icon_closeup_zoom = 0.5f; // magic number from retail
}
// close localization
lcl_ext_close();
}
/**
-7
View File
@@ -1274,13 +1274,9 @@ void parse_autopilot_table(char *filename)
int rval;
SCP_vector<SCP_string> lines;
// open localization
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0)
{
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", (filename) ? filename : "<default autopilot.tbl>", rval));
lcl_ext_close();
return;
}
@@ -1337,9 +1333,6 @@ void parse_autopilot_table(char *filename)
required_string("#END");
// close localization
lcl_ext_close();
}
+91 -70
View File
@@ -37,6 +37,7 @@
#include "jpgutils/jpgutils.h"
#include "parse/parselo.h"
#include "network/multiutil.h"
#include "debugconsole/console.h"
#define BMPMAN_INTERNAL
#include "bmpman/bm_internal.h"
@@ -669,46 +670,53 @@ int bm_reload(int bitmap_handle, const char* filename)
DCF(bm_frag,"Shows BmpMan fragmentation")
{
if ( Dc_command ) {
if (dc_optional_string_either("help", "--help")) {
dc_printf("Displays a graphic showing the BmpMan fragmentation. Color key:\n");
dc_printf("\tGray : NONE\n");
dc_printf("\tRed : PCXn");
dc_printf("\tGreen : USER, TGA, PNG, DDS\n");
dc_printf("\tBlue : ANI, EFF\n\n");
gr_clear();
dc_printf("Once done reviewing the graphic, press any key to return to the console\n");
return;
}
gr_clear();
int x=0, y=0;
int xs=2, ys=2;
int w=4, h=4;
for (int i=0; i<MAX_BITMAPS; i++ ) {
switch( bm_bitmaps[i].type ) {
case BM_TYPE_NONE:
gr_set_color(128,128,128);
break;
case BM_TYPE_PCX:
gr_set_color(255,0,0);
break;
case BM_TYPE_USER:
case BM_TYPE_TGA:
case BM_TYPE_PNG:
case BM_TYPE_DDS:
gr_set_color(0,255,0);
break;
case BM_TYPE_ANI:
case BM_TYPE_EFF:
gr_set_color(0,0,255);
break;
}
gr_rect( x+xs, y+ys, w, h );
x += w+xs+xs;
if ( x > 639 ) {
x = 0;
y += h + ys + ys;
}
int x=0, y=0;
int xs=2, ys=2;
int w=4, h=4;
for (int i=0; i<MAX_BITMAPS; i++ ) {
switch( bm_bitmaps[i].type ) {
case BM_TYPE_NONE:
gr_set_color(128,128,128);
break;
case BM_TYPE_PCX:
gr_set_color(255,0,0);
break;
case BM_TYPE_USER:
case BM_TYPE_TGA:
case BM_TYPE_PNG:
case BM_TYPE_DDS:
gr_set_color(0,255,0);
break;
case BM_TYPE_ANI:
case BM_TYPE_EFF:
gr_set_color(0,0,255);
break;
}
gr_flip();
key_getch();
gr_rect( x+xs, y+ys, w, h );
x += w+xs+xs;
if ( x > 639 ) {
x = 0;
y += h + ys + ys;
}
}
gr_flip();
key_getch();
}
static int find_block_of(int n)
@@ -2068,48 +2076,52 @@ void bm_unload_all()
DCF(bmpman,"Shows/changes bitmap caching parameters and usage")
{
if ( Dc_command ) {
dc_get_arg(ARG_STRING);
if ( !strcmp( Dc_arg, "flush" )) {
dc_printf( "Total RAM usage before flush: %d bytes\n", bm_texture_ram );
int i;
for (i = 0; i < MAX_BITMAPS; i++) {
if ( bm_bitmaps[i].type != BM_TYPE_NONE ) {
bm_free_data(i);
}
}
dc_printf( "Total RAM after flush: %d bytes\n", bm_texture_ram );
} else if ( !strcmp( Dc_arg, "ram" )) {
dc_get_arg(ARG_INT);
Bm_max_ram = Dc_arg_int*1024*1024;
} else {
// print usage, not stats
Dc_help = 1;
}
if ( dc_optional_string_either("help", "--help")) {
dc_printf( "Usage: BmpMan [arg]\nWhere arg can be any of the following:\n" );
dc_printf( "\tflush Unloads all bitmaps.\n" );
dc_printf( "\tram [x] Sets max mem usage to x MB. (Set to 0 to have no limit.)\n" );
dc_printf( "\t? Displays status of Bitmap manager.\n" );
return;
}
if ( Dc_help ) {
dc_printf( "Usage: BmpMan keyword\nWhere keyword can be in the following forms:\n" );
dc_printf( "BmpMan flush Unloads all bitmaps.\n" );
dc_printf( "BmpMan ram x Sets max mem usage to x MB. (Set to 0 to have no limit.)\n" );
dc_printf( "\nUse '? BmpMan' to see status of Bitmap manager.\n" );
Dc_status = 0; // don't print status if help is printed. Too messy.
}
if ( Dc_status ) {
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf( "Total RAM usage: %d bytes\n", bm_texture_ram );
if ( Bm_max_ram > 1024*1024 )
dc_printf( "Max RAM allowed: %.1f MB\n", i2fl(Bm_max_ram)/(1024.0f*1024.0f) );
else if ( Bm_max_ram > 1024 )
dc_printf( "Max RAM allowed: %.1f KB\n", i2fl(Bm_max_ram)/(1024.0f) );
else if ( Bm_max_ram > 0 )
dc_printf( "Max RAM allowed: %d bytes\n", Bm_max_ram );
else
dc_printf( "No RAM limit\n" );
if (Bm_max_ram > 1024*1024) {
dc_printf( "\tMax RAM allowed: %.1f MB\n", i2fl(Bm_max_ram)/(1024.0f*1024.0f) );
} else if ( Bm_max_ram > 1024 ) {
dc_printf( "\tMax RAM allowed: %.1f KB\n", i2fl(Bm_max_ram)/(1024.0f) );
} else if ( Bm_max_ram > 0 ) {
dc_printf( "\tMax RAM allowed: %d bytes\n", Bm_max_ram );
} else {
dc_printf( "\tNo RAM limit\n" );
}
return;
}
if (dc_optional_string("flush")) {
dc_printf( "Total RAM usage before flush: %d bytes\n", bm_texture_ram );
int i;
for (i = 0; i < MAX_BITMAPS; i++) {
if ( bm_bitmaps[i].type != BM_TYPE_NONE ) {
bm_free_data(i);
}
}
dc_printf( "Total RAM after flush: %d bytes\n", bm_texture_ram );
} else if (dc_optional_string("ram")) {
dc_stuff_int(&Bm_max_ram);
if (Bm_max_ram > 0) {
dc_printf("BmpMan limited to %i, MB's\n", Bm_max_ram);
Bm_max_ram *= 1024 * 1024;
} else if (Bm_max_ram == 0) {
dc_printf("!!BmpMan memory is unlimited!!\n");
} else {
dc_printf("Illegal value. Must be non-negative.");
}
} else {
dc_printf("<BmpMan> No argument given\n");
}
}
@@ -2855,6 +2867,9 @@ int bm_set_render_target(int handle, int face)
gr_screen.save_max_w_unscaled = gr_screen.max_w_unscaled;
gr_screen.save_max_h_unscaled = gr_screen.max_h_unscaled;
gr_screen.save_max_w_unscaled_zoomed = gr_screen.max_w_unscaled_zoomed;
gr_screen.save_max_h_unscaled_zoomed = gr_screen.max_h_unscaled_zoomed;
}
if (n < 0) {
@@ -2863,12 +2878,18 @@ int bm_set_render_target(int handle, int face)
gr_screen.max_w_unscaled = gr_screen.save_max_w_unscaled;
gr_screen.max_h_unscaled = gr_screen.save_max_h_unscaled;
gr_screen.max_w_unscaled_zoomed = gr_screen.save_max_w_unscaled_zoomed;
gr_screen.max_h_unscaled_zoomed = gr_screen.save_max_h_unscaled_zoomed;
} else {
gr_screen.max_w = bm_bitmaps[n].bm.w;
gr_screen.max_h = bm_bitmaps[n].bm.h;
gr_screen.max_w_unscaled = bm_bitmaps[n].bm.w;
gr_screen.max_h_unscaled = bm_bitmaps[n].bm.h;
gr_screen.max_w_unscaled_zoomed = bm_bitmaps[n].bm.w;
gr_screen.max_h_unscaled_zoomed = bm_bitmaps[n].bm.h;
}
gr_screen.rendering_to_face = face;
+3 -3
View File
@@ -739,12 +739,12 @@ void subtitle::do_frame(float frametime)
vec3d scale;
bm_get_info(image_id, &orig_w, &orig_h);
scale.xyz.x = image_pos.w / (float) orig_w;
scale.xyz.y = image_pos.h / (float) orig_h;
scale.xyz.x = (image_pos.w > 0) ? (image_pos.w / (float) orig_w) : 1.0f;
scale.xyz.y = (image_pos.h > 0) ? (image_pos.h / (float) orig_h) : 1.0f;
scale.xyz.z = 1.0f;
gr_push_scale_matrix(&scale);
gr_bitmap(image_pos.x, image_pos.y, GR_RESIZE_NONE);
gr_bitmap(fl2i(image_pos.x / scale.xyz.x), fl2i(image_pos.y / scale.xyz.y), GR_RESIZE_NONE);
gr_pop_scale_matrix();
}
// no scaling
+1 -1
View File
@@ -387,6 +387,6 @@ namespace cfile
}
};
};
}
#endif /* __CFILE_H__ */
+4 -3
View File
@@ -388,7 +388,7 @@ void cf_build_root_list(const char *cdrom_dir)
// truncated string check
if ( (strlen(Cfile_user_dir) + strlen(str_temp) + 1) >= CF_MAX_PATHNAME_LENGTH ) {
Int3();
Error(LOCATION, "Home directory plus mod directory exceeds CF_MAX_PATHNAME_LENGTH\n");
}
root = cf_create_root();
@@ -444,7 +444,7 @@ void cf_build_root_list(const char *cdrom_dir)
// truncated string check
if ( (strlen(root->path) + strlen(str_temp) + 1) >= CF_MAX_PATHNAME_LENGTH ) {
Int3();
Error(LOCATION, "Installed path plus mod directory exceeds CF_MAX_PATHNAME_LENGTH\n");
}
path_len = strlen(root->path);
@@ -507,7 +507,7 @@ int is_ext_in_list( const char *ext_list, const char *ext )
{
char tmp_ext[128];
strncpy( tmp_ext, ext, 127 );
strcpy_s( tmp_ext, ext);
strlwr(tmp_ext);
if ( strstr(ext_list, tmp_ext )) {
return 1;
@@ -695,6 +695,7 @@ void cf_search_root_pack(int root_index)
find.offset = INTEL_INT( find.offset ); //-V570
find.size = INTEL_INT( find.size ); //-V570
find.write_time = INTEL_INT( find.write_time ); //-V570
find.filename[sizeof(find.filename)-1] = '\0';
if ( find.size == 0 ) {
int search_path_len = strlen(search_path);
+270 -213
View File
@@ -31,17 +31,34 @@
#include <string.h>
#include <stdlib.h>
enum cmdline_arg_type
{
AT_NONE =0,
AT_INT,
AT_FLOAT,
AT_STRING
};
// values and order MUST match cmdline_arg_type
const char *cmdline_arg_types[] =
{
"NONE",
"INT",
"FLOAT",
"STRING",
};
// variables
class cmdline_parm {
public:
cmdline_parm *next, *prev;
char *name; // name of parameter, must start with '-' char
char *help; // help text for this parameter
bool stacks; // whether this arg stacks with each use or is replaced by newest use (should only be used for strings!!)
const char *name; // name of parameter, must start with '-' char
const char *help; // help text for this parameter
const bool stacks; // whether this arg stacks with each use or is replaced by newest use (should only be used for strings!!)
char *args; // string value for parameter arguments (NULL if no arguments)
int name_found; // true if parameter on command line, otherwise false
const int arg_type; // from enum cmdline_arg_type; used for help
cmdline_parm(char *name, char *help, bool stacks = false);
cmdline_parm(const char *name, const char *help, const int arg_type, const bool stacks = false);
~cmdline_parm();
int found();
int get_int();
@@ -50,12 +67,11 @@ public:
bool check_if_args_is_valid();
};
static cmdline_parm Parm_list(NULL, NULL);
static cmdline_parm Parm_list(NULL, NULL, AT_NONE);
static int Parm_list_inited = 0;
extern int Show_framerate; // from freespace.cpp
enum
{
// DO NOT CHANGE ANYTHING ABOUT THESE FIRST TWO OR WILL MESS UP THE LAUNCHER
@@ -80,7 +96,7 @@ enum
typedef struct
{
// DO NOT CHANGE THE SIZE OF THIS STRING!
// DO NOT CHANGE THE SIZE OF THIS AT_STRING!
char name[32];
} EasyFlag;
@@ -110,21 +126,24 @@ typedef struct
// Please group them by type, ie graphics, gameplay etc, maximum 20 different types
Flag exe_params[] =
{
{ "-nospec", "Disable specular", true, 0, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-spec", },
{ "-noglow", "Disable glow maps", true, 0, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-glow", },
{ "-noenv", "Disable environment maps", true, 0, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-env", },
{ "-nospec", "Disable specular", true, EASY_DEFAULT_MEM, EASY_MEM_ALL_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-spec", },
{ "-noglow", "Disable glow maps", true, EASY_DEFAULT_MEM, EASY_MEM_ALL_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-glow", },
{ "-noenv", "Disable environment maps", true, EASY_DEFAULT_MEM, EASY_MEM_ALL_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-env", },
{ "-nomotiondebris", "Disable motion debris", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-nomotiondebris",},
{ "-noscalevid", "Disable scale-to-window for movies", true, 0, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-noscalevid", },
{ "-missile_lighting", "Apply lighting to missiles" , true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-missile_lighting", },
{ "-nonormal", "Disable normal maps", true, 0, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-normal" },
{ "-nonormal", "Disable normal maps", true, EASY_DEFAULT_MEM, EASY_MEM_ALL_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-normal" },
{ "-noheight", "Disable height/parallax maps", true, EASY_DEFAULT_MEM, EASY_MEM_ALL_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-height" },
{ "-3dshockwave", "Enable 3D shockwaves", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-3dshockwave" },
{ "-post_process", "Enable post processing", true, 0, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-post_process" },
{ "-soft_particles", "Enable soft particles", true, 0, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-soft_particles" },
{ "-fxaa", "Enable FXAA anti-aliasing", true, 0, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fxaa" },
{ "-nolightshafts", "Disable lightshafts", true, 0, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-flightshaftsoff"},
{ "-post_process", "Enable post processing", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-post_process" },
{ "-soft_particles", "Enable soft particles", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-soft_particles" },
{ "-fxaa", "Enable FXAA anti-aliasing", true, EASY_MEM_ALL_ON, EASY_DEFAULT_MEM, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fxaa" },
{ "-nolightshafts", "Disable lightshafts", true, EASY_DEFAULT, EASY_ALL_ON, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-flightshaftsoff"},
{ "-fb_explosions", "Enable Framebuffer Shockwaves", true, EASY_ALL_ON, EASY_DEFAULT, "Graphics", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fb_explosions", },
{ "-img2dds", "Compress non-compressed images", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-img2dds", },
{ "-no_vsync", "Disable vertical sync", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_vsync", },
{ "-no_fps_capping", "Don't limit frames-per-second", true, 0, EASY_DEFAULT, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_fps_capping", },
{ "-cache_bitmaps", "Cache bitmaps between missions", true, 0, EASY_DEFAULT_MEM, "Game Speed", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-cache_bitmaps", },
{ "-dualscanlines", "Add another pair of scanning lines", true, 0, EASY_DEFAULT, "HUD", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dualscanlines", },
@@ -163,16 +182,18 @@ Flag exe_params[] =
{ "-disable_fbo", "Disable OpenGL RenderTargets", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_fbo", },
{ "-disable_pbo", "Disable OpenGL Pixel Buffer Objects", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_pbo", },
{ "-no_glsl", "Disable GLSL (shader) support", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_glsl", },
{ "-ati_swap", "Fix colour issues on some ATI cards", true, 0, EASY_DEFAULT, "Troubleshoot", "http://scp.indiegames.us/mantis/view.php?id=1669", },
{ "-ati_swap", "Fix colour issues on some ATI cards", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ati_swap", },
{ "-no_3d_sound", "Use only 2D/stereo for sound effects", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_3d_sound", },
{ "-disable_glsl_model","Don't use shaders for model rendering", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_glsl_model", },
{ "-mipmap", "Enable mipmapping", true, 0, EASY_DEFAULT_MEM, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-mipmap", },
{ "-use_gldrawelements","Don't use glDrawRangeElements", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
{ "-old_collision", "Use old collision detection system", true, 0, EASY_DEFAULT, "Troubleshoot", "", },
#ifndef SCP_UNIX
{ "-disable_di_mouse", "Don't use DirectInput for mouse control", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-disable_di_mouse", },
#endif
{ "-use_gldrawelements","Don't use glDrawRangeElements", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-use_gldrawelements", },
{ "-old_collision", "Use old collision detection system", true, EASY_DEFAULT, EASY_ALL_ON, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-old_collision", },
{ "-ingame_join", "Allow in-game joining", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ingame_join", },
{ "-voicer", "Enable voice recognition", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-voicer", },
{ "-fb_explosions", "Enable Framebuffer Shockwaves", true, 0, EASY_DEFAULT, "Experimental", "", },
{ "-fps", "Show frames per second on HUD", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-fps", },
{ "-pos", "Show position of camera", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-pos", },
@@ -181,9 +202,9 @@ Flag exe_params[] =
{ "-stats", "Show statistics", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-stats", },
{ "-coords", "Show coordinates", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-coords", },
{ "-show_mem_usage", "Show memory usage", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-show_mem_usage", },
{ "-pofspew", "", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-pofspew", },
{ "-tablecrcs", "", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-tablecrcs", },
{ "-missioncrcs", "", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-missioncrcs", },
{ "-pofspew", "Generate all ibx files immediately", false, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-pofspew", },
{ "-tablecrcs", "Dump table CRCs for multi validation", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-tablecrcs", },
{ "-missioncrcs", "Dump mission CRCs for multi validation", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-missioncrcs", },
{ "-dis_collisions", "Disable collisions", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dis_collisions", },
{ "-dis_weapons", "Disable weapon rendering", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-dis_weapons", },
{ "-output_sexps", "Output SEXPs to sexps.html", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-output_sexps", },
@@ -197,27 +218,30 @@ Flag exe_params[] =
{ "-no_unfocused_pause","Don't pause if the window isn't focused", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-no_unfocused_pause", },
};
// forward declaration
const char * get_param_desc(const char *flag_name);
// here are the command line parameters that we will be using for FreeSpace
// RETAIL options ----------------------------------------------
cmdline_parm connect_arg("-connect", NULL); // Cmdline_connect_addr
cmdline_parm gamename_arg("-gamename", NULL); // Cmdline_game_name
cmdline_parm gamepassword_arg("-password", NULL); // Cmdline_game_password
cmdline_parm allowabove_arg("-allowabove", NULL); // Cmdline_rank_above
cmdline_parm allowbelow_arg("-allowbelow", NULL); // Cmdline_rank_below
cmdline_parm standalone_arg("-standalone", NULL);
cmdline_parm nosound_arg("-nosound", NULL); // Cmdline_freespace_no_sound
cmdline_parm nomusic_arg("-nomusic", NULL); // Cmdline_freespace_no_music
cmdline_parm startgame_arg("-startgame", NULL); // Cmdline_start_netgame
cmdline_parm gameclosed_arg("-closed", NULL); // Cmdline_closed_game
cmdline_parm gamerestricted_arg("-restricted", NULL); // Cmdline_restricted_game
cmdline_parm port_arg("-port", NULL);
cmdline_parm multilog_arg("-multilog", NULL); // Cmdline_multi_log
cmdline_parm client_dodamage("-clientdamage", NULL); // Cmdline_client_dodamage
cmdline_parm pof_spew("-pofspew", NULL); // Cmdline_spew_pof_info
cmdline_parm mouse_coords("-coords", NULL); // Cmdline_mouse_coords
cmdline_parm timeout("-timeout", NULL); // Cmdline_timeout
cmdline_parm bit32_arg("-32bit", NULL); // (only here for retail compatibility reasons, doesn't actually do anything)
cmdline_parm connect_arg("-connect", "Automatically connect to multiplayer IP:PORT", AT_STRING); // Cmdline_connect_addr
cmdline_parm gamename_arg("-gamename", "Set multiplayer game name", AT_STRING); // Cmdline_game_name
cmdline_parm gamepassword_arg("-password", "Set multiplayer game password", AT_STRING); // Cmdline_game_password
cmdline_parm allowabove_arg("-allowabove", "Ranks above this can join multi", AT_STRING); // Cmdline_rank_above
cmdline_parm allowbelow_arg("-allowbelow", "Ranks below this can join multi", AT_STRING); // Cmdline_rank_below
cmdline_parm standalone_arg("-standalone", NULL, AT_NONE);
cmdline_parm nosound_arg("-nosound", NULL, AT_NONE); // Cmdline_freespace_no_sound
cmdline_parm nomusic_arg("-nomusic", NULL, AT_NONE); // Cmdline_freespace_no_music
cmdline_parm startgame_arg("-startgame", NULL, AT_NONE); // Cmdline_start_netgame
cmdline_parm gameclosed_arg("-closed", NULL, AT_NONE); // Cmdline_closed_game
cmdline_parm gamerestricted_arg("-restricted", NULL, AT_NONE); // Cmdline_restricted_game
cmdline_parm port_arg("-port", "Multiplayer network port", AT_INT);
cmdline_parm multilog_arg("-multilog", NULL, AT_NONE); // Cmdline_multi_log
cmdline_parm client_dodamage("-clientdamage", NULL, AT_NONE); // Cmdline_client_dodamage
cmdline_parm pof_spew("-pofspew", NULL, AT_NONE); // Cmdline_spew_pof_info
cmdline_parm mouse_coords("-coords", NULL, AT_NONE); // Cmdline_mouse_coords
cmdline_parm timeout("-timeout", "Multiplayer network timeout (secs)", AT_INT); // Cmdline_timeout
cmdline_parm bit32_arg("-32bit", "Deprecated", AT_NONE); // (only here for retail compatibility reasons, doesn't actually do anything)
char *Cmdline_connect_addr = NULL;
char *Cmdline_game_name = NULL;
@@ -244,31 +268,31 @@ int Cmdline_use_last_pilot = 0;
// FSO options -------------------------------------------------
// Graphics related
cmdline_parm spec_exp_arg("-spec_exp", NULL); // comand line FOV -Bobboau
cmdline_parm clip_dist_arg("-clipdist", NULL); // Cmdline_clip_dist
cmdline_parm fov_arg("-fov", NULL); // Cmdline_fov -- comand line FOV -Bobboau
cmdline_parm ogl_spec_arg("-ogl_spec", NULL); // Cmdline_ogl_spec
cmdline_parm spec_static_arg("-spec_static", NULL);
cmdline_parm spec_point_arg("-spec_point", NULL);
cmdline_parm spec_tube_arg("-spec_tube", NULL);
cmdline_parm ambient_factor_arg("-ambient_factor", NULL); // Cmdline_ambient_factor
cmdline_parm env("-noenv", NULL); // Cmdline_env
cmdline_parm missile_lighting_arg("-missile_lighting", NULL); // Cmdline_missile_lighting
cmdline_parm glow_arg("-noglow", NULL); // Cmdline_glow -- use Bobs glow code
cmdline_parm nomotiondebris_arg("-nomotiondebris", NULL); // Cmdline_nomotiondebris -- Removes those ugly floating rocks -C
cmdline_parm noscalevid_arg("-noscalevid", NULL); // Cmdline_noscalevid -- disable video scaling that fits to window
cmdline_parm spec_arg("-nospec", NULL); // Cmdline_spec --
cmdline_parm noemissive_arg("-no_emissive_light", NULL); // Cmdline_no_emissive -- don't use emissive light in OGL
cmdline_parm normal_arg("-nonormal", NULL); // Cmdline_normal -- disable normal mapping
cmdline_parm height_arg("-noheight", NULL); // Cmdline_height -- enable support for parallax mapping
cmdline_parm enable_3d_shockwave_arg("-3dshockwave", NULL);
cmdline_parm softparticles_arg("-soft_particles", NULL);
cmdline_parm postprocess_arg("-post_process", NULL);
cmdline_parm bloom_intensity_arg("-bloom_intensity", NULL);
cmdline_parm fxaa_arg("-fxaa", NULL);
cmdline_parm fxaa_preset_arg("-fxaa_preset", NULL);
cmdline_parm fb_explosions_arg("-fb_explosions", NULL);
cmdline_parm flightshaftsoff_arg("-nolightshafts", NULL);
cmdline_parm fov_arg("-fov", "Vertical field-of-view factor", AT_FLOAT); // Cmdline_fov -- comand line FOV -Bobboau
cmdline_parm clip_dist_arg("-clipdist", "Changes the distance from the viewpoint for the near-clipping plane", AT_FLOAT); // Cmdline_clip_dist
cmdline_parm spec_exp_arg("-spec_exp", "Adjusts the size of shiny spots on ships", AT_FLOAT);
cmdline_parm ogl_spec_arg("-ogl_spec", "Shininess of specular light", AT_FLOAT); // Cmdline_ogl_spec
cmdline_parm spec_static_arg("-spec_static", "Adjusts suns contribution to specular highlights", AT_FLOAT);
cmdline_parm spec_point_arg("-spec_point", "Adjusts laser weapons contribution to specular highlights", AT_FLOAT);
cmdline_parm spec_tube_arg("-spec_tube", "Adjusts beam weapons contribution to specular highlights", AT_FLOAT);
cmdline_parm ambient_factor_arg("-ambient_factor", "Adjusts ambient light applied to all parts of a ship", AT_INT); // Cmdline_ambient_factor
cmdline_parm missile_lighting_arg("-missile_lighting", NULL, AT_NONE); // Cmdline_missile_lighting
cmdline_parm env("-noenv", NULL, AT_NONE); // Cmdline_env
cmdline_parm glow_arg("-noglow", NULL, AT_NONE); // Cmdline_glow -- use Bobs glow code
cmdline_parm nomotiondebris_arg("-nomotiondebris", NULL, AT_NONE); // Cmdline_nomotiondebris -- Removes those ugly floating rocks -C
cmdline_parm noscalevid_arg("-noscalevid", NULL, AT_NONE); // Cmdline_noscalevid -- disable video scaling that fits to window
cmdline_parm spec_arg("-nospec", NULL, AT_NONE); // Cmdline_spec --
cmdline_parm noemissive_arg("-no_emissive_light", "Disable emissive light from ships", AT_NONE); // Cmdline_no_emissive -- don't use emissive light in OGL
cmdline_parm normal_arg("-nonormal", NULL, AT_NONE); // Cmdline_normal -- disable normal mapping
cmdline_parm height_arg("-noheight", NULL, AT_NONE); // Cmdline_height -- enable support for parallax mapping
cmdline_parm enable_3d_shockwave_arg("-3dshockwave", NULL, AT_NONE);
cmdline_parm softparticles_arg("-soft_particles", NULL, AT_NONE);
cmdline_parm postprocess_arg("-post_process", NULL, AT_NONE);
cmdline_parm bloom_intensity_arg("-bloom_intensity", "Set bloom intensity, requires -post_process", AT_INT);
cmdline_parm fxaa_arg("-fxaa", NULL, AT_NONE);
cmdline_parm fxaa_preset_arg("-fxaa_preset", "FXAA quality (0-9), requires -post_process and -fxaa", AT_INT);
cmdline_parm fb_explosions_arg("-fb_explosions", NULL, AT_NONE);
cmdline_parm flightshaftsoff_arg("-nolightshafts", NULL, AT_NONE);
float Cmdline_clip_dist = Default_min_draw_distance;
float Cmdline_fov = 0.75f;
@@ -295,10 +319,10 @@ bool Cmdline_fb_explosions = 0;
extern bool ls_force_off;
// Game Speed related
cmdline_parm cache_bitmaps_arg("-cache_bitmaps", NULL); // Cmdline_cache_bitmaps
cmdline_parm img2dds_arg("-img2dds", NULL); // Cmdline_img2dds
cmdline_parm no_fpscap("-no_fps_capping", NULL); // Cmdline_NoFPSCap
cmdline_parm no_vsync_arg("-no_vsync", NULL); // Cmdline_no_vsync
cmdline_parm cache_bitmaps_arg("-cache_bitmaps", NULL, AT_NONE); // Cmdline_cache_bitmaps
cmdline_parm img2dds_arg("-img2dds", NULL, AT_NONE); // Cmdline_img2dds
cmdline_parm no_fpscap("-no_fps_capping", "Don't limit frames-per-second", AT_NONE); // Cmdline_NoFPSCap
cmdline_parm no_vsync_arg("-no_vsync", NULL, AT_NONE); // Cmdline_no_vsync
int Cmdline_cache_bitmaps = 0; // caching of bitmaps between missions (faster loads, can hit swap on reload with <512 Meg RAM though) - taylor
int Cmdline_img2dds = 0;
@@ -306,11 +330,11 @@ int Cmdline_NoFPSCap = 0; // Disable FPS capping - kazan
int Cmdline_no_vsync = 0;
// HUD related
cmdline_parm ballistic_gauge("-ballistic_gauge", NULL); // Cmdline_ballistic_gauge
cmdline_parm dualscanlines_arg("-dualscanlines", NULL); // Cmdline_dualscanlines -- Change to phreaks options including new targeting code
cmdline_parm orb_radar("-orbradar", NULL); // Cmdline_orb_radar
cmdline_parm rearm_timer_arg("-rearm_timer", NULL); // Cmdline_rearm_timer
cmdline_parm targetinfo_arg("-targetinfo", NULL); // Cmdline_targetinfo -- Adds ship name/class to right of target box -C
cmdline_parm ballistic_gauge("-ballistic_gauge", NULL, AT_NONE); // Cmdline_ballistic_gauge
cmdline_parm dualscanlines_arg("-dualscanlines", NULL, AT_NONE); // Cmdline_dualscanlines -- Change to phreaks options including new targeting code
cmdline_parm orb_radar("-orbradar", NULL, AT_NONE); // Cmdline_orb_radar
cmdline_parm rearm_timer_arg("-rearm_timer", NULL, AT_NONE); // Cmdline_rearm_timer
cmdline_parm targetinfo_arg("-targetinfo", NULL, AT_NONE); // Cmdline_targetinfo -- Adds ship name/class to right of target box -C
int Cmdline_ballistic_gauge = 0; // WMCoolmon's gauge thingy
int Cmdline_dualscanlines = 0;
@@ -319,12 +343,12 @@ int Cmdline_rearm_timer = 0;
int Cmdline_targetinfo = 0;
// Gameplay related
cmdline_parm use_3dwarp("-3dwarp", NULL); // Cmdline_3dwarp
cmdline_parm ship_choice_3d_arg("-ship_choice_3d", NULL); // Cmdline_ship_choice_3d
cmdline_parm weapon_choice_3d_arg("-weapon_choice_3d", NULL); // Cmdline_weapon_choice_3d
cmdline_parm use_warp_flash("-warp_flash", NULL); // Cmdline_warp_flash
cmdline_parm allow_autpilot_interrupt("-no_ap_interrupt", NULL); // Cmdline_warp_flash
cmdline_parm stretch_menu("-stretch_menu", NULL); // Cmdline_stretch_menu
cmdline_parm use_3dwarp("-3dwarp", NULL, AT_NONE); // Cmdline_3dwarp
cmdline_parm ship_choice_3d_arg("-ship_choice_3d", NULL, AT_NONE); // Cmdline_ship_choice_3d
cmdline_parm weapon_choice_3d_arg("-weapon_choice_3d", NULL, AT_NONE); // Cmdline_weapon_choice_3d
cmdline_parm use_warp_flash("-warp_flash", NULL, AT_NONE); // Cmdline_warp_flash
cmdline_parm allow_autpilot_interrupt("-no_ap_interrupt", NULL, AT_NONE);
cmdline_parm stretch_menu("-stretch_menu", NULL, AT_NONE); // Cmdline_stretch_menu
int Cmdline_3dwarp = 0;
int Cmdline_ship_choice_3d = 0;
@@ -334,26 +358,26 @@ int Cmdline_autopilot_interruptable = 1;
int Cmdline_stretch_menu = 0;
// Audio related
cmdline_parm query_speech_arg("-query_speech", NULL); // Cmdline_query_speech
cmdline_parm snd_preload_arg("-snd_preload", NULL); // Cmdline_snd_preload
cmdline_parm voice_recognition_arg("-voicer", NULL); // Cmdline_voice_recognition
cmdline_parm query_speech_arg("-query_speech", NULL, AT_NONE); // Cmdline_query_speech
cmdline_parm snd_preload_arg("-snd_preload", NULL, AT_NONE); // Cmdline_snd_preload
cmdline_parm voice_recognition_arg("-voicer", NULL, AT_NONE); // Cmdline_voice_recognition
int Cmdline_query_speech = 0;
int Cmdline_snd_preload = 0; // preload game sounds during mission load
int Cmdline_voice_recognition = 0;
// MOD related
cmdline_parm mod_arg("-mod", NULL, true); // Cmdline_mod -- DTP modsupport
cmdline_parm mod_arg("-mod", "List of folders to overwrite/add-to the default data", AT_STRING, true); // Cmdline_mod -- DTP modsupport
char *Cmdline_mod = NULL; //DTP for mod argument
// Multiplayer/Network related
cmdline_parm almission_arg("-almission", NULL); // Cmdline_almission -- DTP for autoload Multi mission
cmdline_parm ingamejoin_arg("-ingame_join", NULL); // Cmdline_ingamejoin
cmdline_parm mpnoreturn_arg("-mpnoreturn", NULL); // Cmdline_mpnoreturn -- Removes 'Return to Flight Deck' in respawn dialog -C
cmdline_parm missioncrcspew_arg("-missioncrcs", NULL); // Cmdline_spew_mission_crcs
cmdline_parm tablecrcspew_arg("-tablecrcs", NULL); // Cmdline_spew_table_crcs
cmdline_parm objupd_arg("-cap_object_update", NULL);
cmdline_parm almission_arg("-almission", "Autoload multiplayer mission", AT_STRING); // Cmdline_almission -- DTP for autoload Multi mission
cmdline_parm ingamejoin_arg("-ingame_join", NULL, AT_NONE); // Cmdline_ingamejoin
cmdline_parm mpnoreturn_arg("-mpnoreturn", NULL, AT_NONE); // Cmdline_mpnoreturn -- Removes 'Return to Flight Deck' in respawn dialog -C
cmdline_parm missioncrcspew_arg("-missioncrcs", NULL, AT_STRING); // Cmdline_spew_mission_crcs
cmdline_parm tablecrcspew_arg("-tablecrcs", NULL, AT_STRING); // Cmdline_spew_table_crcs
cmdline_parm objupd_arg("-cap_object_update", "Multiplayer object update cap (0-3)", AT_INT);
char *Cmdline_almission = NULL; //DTP for autoload multi mission.
int Cmdline_ingamejoin = 0;
@@ -363,21 +387,23 @@ char *Cmdline_spew_table_crcs = NULL;
int Cmdline_objupd = 3; // client object updates on LAN by default
// Troubleshooting
cmdline_parm loadallweapons_arg("-loadallweps", NULL); // Cmdline_load_all_weapons
cmdline_parm htl_arg("-nohtl", NULL); // Cmdline_nohtl -- don't use HT&L
cmdline_parm noibx_arg("-noibx", NULL); // Cmdline_noibx
cmdline_parm nomovies_arg("-nomovies", NULL); // Cmdline_nomovies -- Allows video streaming
cmdline_parm no_set_gamma_arg("-no_set_gamma", NULL); // Cmdline_no_set_gamma
cmdline_parm no_vbo_arg("-novbo", NULL); // Cmdline_novbo
cmdline_parm no_fbo_arg("-disable_fbo", NULL); // Cmdline_no_fbo
cmdline_parm no_pbo_arg("-disable_pbo", NULL); // Cmdline_no_pbo
cmdline_parm noglsl_arg("-no_glsl", NULL); // Cmdline_noglsl -- disable GLSL support in OpenGL
cmdline_parm mipmap_arg("-mipmap", NULL); // Cmdline_mipmap
cmdline_parm atiswap_arg("-ati_swap", NULL); // Cmdline_atiswap - Fix ATI color swap issue for screenshots.
cmdline_parm no3dsound_arg("-no_3d_sound", NULL); // Cmdline_no_3d_sound - Disable use of full 3D sounds
cmdline_parm no_glsl_models_arg("-disable_glsl_model", NULL); // Cmdline_no_glsl_model_rendering -- switches model rendering to fixed pipeline
cmdline_parm no_drawrangeelements("-use_gldrawelements", NULL); // Cmdline_drawelements -- Uses glDrawElements instead of glDrawRangeElements
cmdline_parm keyboard_layout("-keyboard_layout", NULL);
cmdline_parm loadallweapons_arg("-loadallweps", NULL, AT_NONE); // Cmdline_load_all_weapons
cmdline_parm htl_arg("-nohtl", NULL, AT_NONE); // Cmdline_nohtl -- don't use HT&L
cmdline_parm noibx_arg("-noibx", NULL, AT_NONE); // Cmdline_noibx
cmdline_parm nomovies_arg("-nomovies", NULL, AT_NONE); // Cmdline_nomovies -- Allows video streaming
cmdline_parm no_set_gamma_arg("-no_set_gamma", NULL, AT_NONE); // Cmdline_no_set_gamma
cmdline_parm no_vbo_arg("-novbo", NULL, AT_NONE); // Cmdline_novbo
cmdline_parm no_fbo_arg("-disable_fbo", NULL, AT_NONE); // Cmdline_no_fbo
cmdline_parm no_pbo_arg("-disable_pbo", NULL, AT_NONE); // Cmdline_no_pbo
cmdline_parm noglsl_arg("-no_glsl", NULL, AT_NONE); // Cmdline_noglsl -- disable GLSL support in OpenGL
cmdline_parm mipmap_arg("-mipmap", NULL, AT_NONE); // Cmdline_mipmap
cmdline_parm atiswap_arg("-ati_swap", NULL, AT_NONE); // Cmdline_atiswap - Fix ATI color swap issue for screenshots.
cmdline_parm no3dsound_arg("-no_3d_sound", NULL, AT_NONE); // Cmdline_no_3d_sound - Disable use of full 3D sounds
cmdline_parm no_glsl_models_arg("-disable_glsl_model", NULL, AT_NONE); // Cmdline_no_glsl_model_rendering -- switches model rendering to fixed pipeline
cmdline_parm no_di_mouse_arg("-disable_di_mouse", "Disable DirectInput mouse code (Windows only)", AT_NONE); // Cmdline_no_di_mouse -- Disables directinput use for mouse control
cmdline_parm no_drawrangeelements("-use_gldrawelements", NULL, AT_NONE); // Cmdline_drawelements -- Uses glDrawElements instead of glDrawRangeElements
cmdline_parm keyboard_layout("-keyboard_layout", "Specify keyboard layout (qwertz or azerty)", AT_STRING);
cmdline_parm old_collision_system("-old_collision", NULL, AT_NONE); // Cmdline_old_collision_sys
int Cmdline_load_all_weapons = 0;
int Cmdline_nohtl = 0;
@@ -395,30 +421,32 @@ int Cmdline_drawelements = 0;
char* Cmdline_keyboard_layout = NULL;
// Developer/Testing related
cmdline_parm start_mission_arg("-start_mission", NULL); // Cmdline_start_mission
cmdline_parm old_collision_system("-old_collision", NULL); // Cmdline_new_collision
cmdline_parm dis_collisions("-dis_collisions", NULL); // Cmdline_dis_collisions
cmdline_parm dis_weapons("-dis_weapons", NULL); // Cmdline_dis_weapons
cmdline_parm noparseerrors_arg("-noparseerrors", NULL); // Cmdline_noparseerrors -- turns off parsing errors -C
cmdline_parm start_mission_arg("-start_mission", "Skip mainhall and run this mission", AT_STRING); // Cmdline_start_mission
cmdline_parm dis_collisions("-dis_collisions", NULL, AT_NONE); // Cmdline_dis_collisions
cmdline_parm dis_weapons("-dis_weapons", NULL, AT_NONE); // Cmdline_dis_weapons
cmdline_parm noparseerrors_arg("-noparseerrors", NULL, AT_NONE); // Cmdline_noparseerrors -- turns off parsing errors -C
#ifdef Allow_NoWarn
cmdline_parm nowarn_arg("-no_warn", NULL); // Cmdline_nowarn
cmdline_parm nowarn_arg("-no_warn", "Disable warnings (not recommended)", AT_NONE); // Cmdline_nowarn
#endif
cmdline_parm extra_warn_arg("-extra_warn", NULL); // Cmdline_extra_warn
cmdline_parm fps_arg("-fps", NULL); // Cmdline_show_fps
cmdline_parm show_mem_usage_arg("-show_mem_usage", NULL); // Cmdline_show_mem_usage
cmdline_parm pos_arg("-pos", NULL); // Cmdline_show_pos
cmdline_parm stats_arg("-stats", NULL); // Cmdline_show_stats
cmdline_parm save_render_targets_arg("-save_render_target", NULL); // Cmdline_save_render_targets
cmdline_parm debug_window_arg("-debug_window", NULL); // Cmdline_debug_window
cmdline_parm window_arg("-window", NULL); // Cmdline_window
cmdline_parm fullscreen_window_arg("-fullscreen_window",NULL);
cmdline_parm res_arg("-res", NULL); // Cmdline_lores
cmdline_parm verify_vps_arg("-verify_vps", NULL); // Cmdline_verify_vps -- spew VP crcs to vp_crcs.txt
cmdline_parm parse_cmdline_only(PARSE_COMMAND_LINE_STRING, NULL);
cmdline_parm reparse_mainhall_arg("-reparse_mainhall", NULL); //Cmdline_reparse_mainhall
cmdline_parm frame_profile_arg("-profile_frame_time", NULL); //Cmdline_frame_profile
cmdline_parm frame_profile_write_file("-profile_write_file", NULL); // Cmdline_profile_write_file
cmdline_parm no_unfocused_pause_arg("-no_unfocused_pause", NULL); //Cmdline_no_unfocus_pause
cmdline_parm extra_warn_arg("-extra_warn", "Enable 'extra' warnings", AT_NONE); // Cmdline_extra_warn
cmdline_parm fps_arg("-fps", NULL, AT_NONE); // Cmdline_show_fps
cmdline_parm show_mem_usage_arg("-show_mem_usage", NULL, AT_NONE); // Cmdline_show_mem_usage
cmdline_parm pos_arg("-pos", NULL, AT_NONE); // Cmdline_show_pos
cmdline_parm stats_arg("-stats", NULL, AT_NONE); // Cmdline_show_stats
cmdline_parm save_render_targets_arg("-save_render_target", NULL, AT_NONE); // Cmdline_save_render_targets
cmdline_parm debug_window_arg("-debug_window", NULL, AT_NONE); // Cmdline_debug_window
cmdline_parm window_arg("-window", NULL, AT_NONE); // Cmdline_window
cmdline_parm fullscreen_window_arg("-fullscreen_window", "Fullscreen/borderless window (Windows only)", AT_NONE);
cmdline_parm res_arg("-res", "Resolution, formatted like 1600x900", AT_STRING);
cmdline_parm verify_vps_arg("-verify_vps", NULL, AT_NONE); // Cmdline_verify_vps -- spew VP crcs to vp_crcs.txt
cmdline_parm parse_cmdline_only(PARSE_COMMAND_LINE_STRING, "Ignore any cmdline_fso.cfg files", AT_NONE);
#ifdef SCP_UNIX
cmdline_parm no_grab("-nograb", NULL, AT_NONE); // Cmdline_no_grab
#endif
cmdline_parm reparse_mainhall_arg("-reparse_mainhall", NULL, AT_NONE); //Cmdline_reparse_mainhall
cmdline_parm frame_profile_arg("-profile_frame_time", NULL, AT_NONE); //Cmdline_frame_profile
cmdline_parm frame_profile_write_file("-profile_write_file", NULL, AT_NONE); // Cmdline_profile_write_file
cmdline_parm no_unfocused_pause_arg("-no_unfocused_pause", NULL, AT_NONE); //Cmdline_no_unfocus_pause
char *Cmdline_start_mission = NULL;
int Cmdline_old_collision_sys = 0;
@@ -445,17 +473,17 @@ bool Cmdline_profile_write_file = false;
bool Cmdline_no_unfocus_pause = false;
// Other
cmdline_parm get_flags_arg("-get_flags", NULL);
cmdline_parm output_sexp_arg("-output_sexps", NULL); //WMC - outputs all SEXPs to sexps.html
cmdline_parm output_scripting_arg("-output_scripting", NULL); //WMC
cmdline_parm get_flags_arg("-get_flags", "Output the launcher flags file", AT_NONE);
cmdline_parm output_sexp_arg("-output_sexps", NULL, AT_NONE); //WMC - outputs all SEXPs to sexps.html
cmdline_parm output_scripting_arg("-output_scripting", NULL, AT_NONE); //WMC
// Deprecated flags - CommanderDJ
cmdline_parm deprecated_spec_arg("-spec", NULL);
cmdline_parm deprecated_glow_arg("-glow", NULL);
cmdline_parm deprecated_normal_arg("-normal", NULL);
cmdline_parm deprecated_env_arg("-env", NULL);
cmdline_parm deprecated_tbp_arg("-tbp", NULL);
cmdline_parm deprecated_jpgtga_arg("-jpgtga", NULL);
cmdline_parm deprecated_spec_arg("-spec", "Deprecated", AT_NONE);
cmdline_parm deprecated_glow_arg("-glow", "Deprecated", AT_NONE);
cmdline_parm deprecated_normal_arg("-normal", "Deprecated", AT_NONE);
cmdline_parm deprecated_env_arg("-env", "Deprecated", AT_NONE);
cmdline_parm deprecated_tbp_arg("-tbp", "Deprecated", AT_NONE);
cmdline_parm deprecated_jpgtga_arg("-jpgtga", "Deprecated", AT_NONE);
int Cmdline_deprecated_spec = 0;
int Cmdline_deprecated_glow = 0;
@@ -695,11 +723,19 @@ void os_validate_parms(int argc, char *argv[])
// not the prettiest thing but the job gets done
static const int STR_SIZE = 25; // max len of exe_params.name + 5 spaces
int p = 0, sp = 0;
while (exe_params[p].name[0] == '-') {
sp = strlen(exe_params[p].name);
printf(" [ %s ]%*s- %s\n", exe_params[p].name, (STR_SIZE - sp - 1), NOX(" "), exe_params[p].desc);
p++;
const int AT_SIZE = 8; // max len of cmdline_arg_types[] + 2 spaces
int sp=0, atp=0;
for (parmp = GET_FIRST(&Parm_list); parmp !=END_OF_LIST(&Parm_list); parmp = GET_NEXT(parmp) ) {
// don't output deprecated flags
if (stricmp("deprecated", parmp->help)) {
sp = strlen(parmp->name);
if (parmp->arg_type != AT_NONE) {
atp = strlen(cmdline_arg_types[parmp->arg_type]);
printf(" [ %s ]%*s[ %s ]%*s- %s\n", parmp->name, (STR_SIZE - sp -1), NOX(" "), cmdline_arg_types[parmp->arg_type], AT_SIZE-atp, NOX(" "), parmp->help);
} else {
printf(" [ %s ]%*s- %s\n", parmp->name, (STR_SIZE - sp -1 +AT_SIZE+4), NOX(" "), parmp->help);
}
}
}
printf("\n");
@@ -809,106 +845,105 @@ void os_process_cmdline(char* cmdline)
void os_init_cmdline(int argc, char *argv[])
{
FILE *fp;
bool parse_config = true;
for (int i = 0; i < argc; i++)
{
if (!stricmp(argv[i], PARSE_COMMAND_LINE_STRING) != NULL) {
parse_config = false;
}
}
if (strstr(cmdline, PARSE_COMMAND_LINE_STRING) == NULL) {
// read the cmdline.cfg file from the data folder, and pass the command line arguments to
// the the parse_parms and validate_parms line. Read these first so anything actually on
// the command line will take precedence
// read the cmdline_fso.cfg file from the data folder, and pass the command line arguments to
// the the parse_parms and validate_parms line. Read these first so anything actually on
// the command line will take precedence
#ifdef _WIN32
fp = fopen("data\\cmdline_fso.cfg", "rt");
fp = fopen("data\\cmdline_fso.cfg", "rt");
#elif defined(APPLE_APP)
char resolved_path[MAX_PATH], data_path[MAX_PATH_LEN];
char resolved_path[MAX_PATH], data_path[MAX_PATH_LEN];
GetCurrentDirectory(MAX_PATH_LEN-1, data_path);
snprintf(resolved_path, MAX_PATH, "%s/data/cmdline_fso.cfg", data_path);
GetCurrentDirectory(MAX_PATH_LEN-1, data_path);
snprintf(resolved_path, MAX_PATH, "%s/data/cmdline_fso.cfg", data_path);
fp = fopen(resolved_path, "rt");
fp = fopen(resolved_path, "rt");
#else
fp = fopen("data/cmdline_fso.cfg", "rt");
fp = fopen("data/cmdline_fso.cfg", "rt");
#endif
// if the file exists, get a single line, and deal with it
if ( fp && parse_config ) {
char *buf, *p;
// if the file exists, get a single line, and deal with it
if ( fp ) {
char *buf, *p;
size_t len = filelength( fileno(fp) ) + 2;
buf = new char [len];
size_t len = filelength( fileno(fp) ) + 2;
buf = new char [len];
fgets(buf, len-1, fp);
fgets(buf, len-1, fp);
// replace the newline character with a NULL
if ( (p = strrchr(buf, '\n')) != NULL ) {
*p = '\0';
// replace the newline character with a NULL
if ( (p = strrchr(buf, '\n')) != NULL ) {
*p = '\0';
}
#ifdef SCP_UNIX
// append a space for the os_parse_parms() check
strcat_s(buf, len, " ");
#endif
os_parse_parms(buf);
os_validate_parms(buf);
delete [] buf;
fclose(fp);
}
#ifdef SCP_UNIX
// append a space for the os_parse_parms() check
strcat_s(buf, len, " ");
#endif
// parse user specific cmdline_fso config file (will supersede options in global file)
char cmdname[MAX_PATH];
os_process_cmdline(buf);
delete [] buf;
fclose(fp);
}
#ifdef SCP_UNIX
// parse user specific cmdline config file (will supersede options in global file)
char cmdname[MAX_PATH];
snprintf(cmdname, MAX_PATH, "%s/%s/data/cmdline_fso.cfg", detect_home(), Osreg_user_dir);
fp = fopen(cmdname, "rt");
if ( !fp ) {
// try for non "_fso", for older code versions
snprintf(cmdname, MAX_PATH, "%s/%s/data/cmdline.cfg", detect_home(), Osreg_user_dir);
snprintf(cmdname, MAX_PATH, "%s/%s/data/cmdline_fso.cfg", detect_home(), Osreg_user_dir);
fp = fopen(cmdname, "rt");
}
// if the file exists, get a single line, and deal with it
if ( fp ) {
char *buf, *p;
size_t len = filelength( fileno(fp) ) + 2;
buf = new char [len];
fgets(buf, len-1, fp);
// replace the newline character with a NULL
if ( (p = strrchr(buf, '\n')) != NULL ) {
*p = '\0';
if ( !fp ) {
// try for non "_fso", for older code versions
snprintf(cmdname, MAX_PATH, "%s/%s/data/cmdline.cfg", detect_home(), Osreg_user_dir);
fp = fopen(cmdname, "rt");
}
// append a space for the os_parse_parms() check
strcat_s(buf, len, " ");
// if the file exists, get a single line, and deal with it
if ( fp ) {
char *buf, *p;
os_process_cmdline(buf);
delete [] buf;
fclose(fp);
}
size_t len = filelength( fileno(fp) ) + 2;
buf = new char [len];
fgets(buf, len-1, fp);
// replace the newline character with a NULL
if ( (p = strrchr(buf, '\n')) != NULL ) {
*p = '\0';
}
// append a space for the os_parse_parms() check
strcat_s(buf, len, " ");
os_parse_parms(buf);
os_validate_parms(buf);
delete [] buf;
fclose(fp);
}
#endif
} // If cmdline included PARSE_COMMAND_LINE_STRING
// By parsing cmdline last, anything actually on the command line will take precedence.
os_parse_parms(argc, argv);
os_validate_parms(argc, argv);
}
// arg constructor
// name_ - name of the parameter, must start with '-' character
// help_ - help text for this parameter
cmdline_parm::cmdline_parm(char *name_, char *help_, bool stacks_)
/*
* arg constructor
*
* @param name_ name of the parameter, must start with '-' character
* @param help_ help text for this parameter
* @param arg_type_ parameters arguement type (if any)
* @param stacks_ can the parameter be stacked
*/
cmdline_parm::cmdline_parm(const char *name_, const char *help_, const int arg_type_, const bool stacks_):
name(name_), help(help_), stacks(stacks_), arg_type(arg_type_)
{
name = name_;
help = help_;
stacks = stacks_;
args = NULL;
name_found = 0;
@@ -918,7 +953,13 @@ cmdline_parm::cmdline_parm(char *name_, char *help_, bool stacks_)
}
if (name != NULL) {
// not in the static Parm_list init, so lookup the NULL help args
if (help == NULL) {
help = get_param_desc(name);
}
list_append(&Parm_list, this);
} else {
list_init(&Parm_list);
}
}
@@ -959,6 +1000,7 @@ int cmdline_parm::found()
// returns - the interger representation for the parameter argument
int cmdline_parm::get_int()
{
Assertion(arg_type == AT_INT, "Coding error! Cmdline arg (%s) called cmdline_parm::get_int() with invalid arg_type (%s)", name, cmdline_arg_types[arg_type]);
check_if_args_is_valid();
int offset = 0;
@@ -983,6 +1025,7 @@ int cmdline_parm::get_int()
// returns - the float representation for the parameter argument
float cmdline_parm::get_float()
{
Assertion(arg_type == AT_FLOAT, "Coding error! Cmdline arg (%s) called cmdline_parm::get_float() with invalid arg_type (%s)", name, cmdline_arg_types[arg_type]);
check_if_args_is_valid();
int offset = 0;
@@ -1007,6 +1050,7 @@ float cmdline_parm::get_float()
// returns - the string value for the parameter argument
char *cmdline_parm::str()
{
Assertion(arg_type == AT_STRING, "Coding error! Cmdline arg (%s) called cmdline_parm::str() with invalid arg_type (%s)", name, cmdline_arg_types[arg_type]);
check_if_args_is_valid();
return args;
@@ -1639,3 +1683,16 @@ int parse_cmdline(int argc, char *argv[])
// I did this because of fred2_parse_cmdline()
return SetCmdlineParams();
}
const char * get_param_desc(const char *flag_name)
{
int i;
int flag_size = sizeof(Flag);
int num_flags = sizeof(exe_params) / flag_size;
for (i = 0; i < num_flags; ++i) {
if (!strcmp(flag_name, exe_params[i].name)) {
return exe_params[i].desc;
}
}
return "UNKNOWN - FIXME!";
}
+20 -20
View File
@@ -29,6 +29,7 @@
#include "network/multi_pmsg.h"
#include "network/multiutil.h"
#include "parse/scripting.h"
#include "debugconsole/console.h"
#ifndef NDEBUG
@@ -178,6 +179,8 @@ static UI_BUTTON List_buttons[LIST_BUTTONS_MAX]; // buttons for each line of te
static UI_WINDOW Ui_window;
static unsigned int Defaults_cycle_pos; // the controls preset that was last selected
int Control_config_overlay_id;
static struct {
int key; // index of other control in conflict with this one
int joy; // index of other control in conflict with this one
@@ -348,7 +351,7 @@ int Config_allowed[] = {
#ifndef NDEBUG
int Show_controls_info = 0;
DCF_BOOL(show_controls_info, Show_controls_info)
DCF_BOOL(show_controls_info, Show_controls_info);
#endif
static int Axes_origin[JOY_NUM_AXES];
@@ -1293,8 +1296,8 @@ void control_config_init()
Ui_window.tooltip_handler = control_config_tooltip_handler;
// load in help overlay bitmap
help_overlay_load(CONTROL_CONFIG_OVERLAY);
help_overlay_set_state(CONTROL_CONFIG_OVERLAY,0);
Control_config_overlay_id = help_overlay_get_index(CONTROL_CONFIG_OVERLAY);
help_overlay_set_state(Control_config_overlay_id,gr_screen.res,0);
// reset conflict flashing
Conflict_stamp = -1;
@@ -1384,9 +1387,6 @@ void control_config_close()
while (Config_item_undo){
free_undo_block();
}
// unload the overlay bitmap
help_overlay_unload(CONTROL_CONFIG_OVERLAY);
if (Background_bitmap){
bm_release(Background_bitmap);
@@ -1498,7 +1498,7 @@ void control_config_do_frame(float frametime)
}
} else {
if (help_overlay_active(CONTROL_CONFIG_OVERLAY)) {
if (help_overlay_active(Control_config_overlay_id)) {
CC_Buttons[gr_screen.res][HELP_BUTTON].button.reset_status();
Ui_window.set_ignore_gadgets(1);
}
@@ -1508,14 +1508,14 @@ void control_config_do_frame(float frametime)
Ui_window.process(0);
if ( (k > 0) || B1_JUST_RELEASED ) {
if (help_overlay_active(CONTROL_CONFIG_OVERLAY)) {
help_overlay_set_state(CONTROL_CONFIG_OVERLAY, 0);
if (help_overlay_active(Control_config_overlay_id)) {
help_overlay_set_state(Control_config_overlay_id, gr_screen.res, 0);
Ui_window.set_ignore_gadgets(0);
k = 0;
}
}
if ( !help_overlay_active(CONTROL_CONFIG_OVERLAY) ) {
if ( !help_overlay_active(Control_config_overlay_id) ) {
Ui_window.set_ignore_gadgets(0);
}
@@ -1542,7 +1542,7 @@ void control_config_do_frame(float frametime)
}
if ((k > 0) && !Config_allowed[k & KEY_MASK]) {
popup(0, 1, POPUP_OK, XSTR( "That is a non-bindable key. Please try again.", 207));
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR( "That is a non-bindable key. Please try again.", 207));
k = 0;
}
@@ -1609,7 +1609,7 @@ void control_config_do_frame(float frametime)
}
} else if (Search_mode) {
if (help_overlay_active(CONTROL_CONFIG_OVERLAY)) {
if (help_overlay_active(Control_config_overlay_id)) {
CC_Buttons[gr_screen.res][HELP_BUTTON].button.reset_status();
Ui_window.set_ignore_gadgets(1);
}
@@ -1619,14 +1619,14 @@ void control_config_do_frame(float frametime)
Ui_window.process(0);
if ( (k > 0) || B1_JUST_RELEASED ) {
if ( help_overlay_active(CONTROL_CONFIG_OVERLAY) ) {
help_overlay_set_state(CONTROL_CONFIG_OVERLAY, 0);
if ( help_overlay_active(Control_config_overlay_id) ) {
help_overlay_set_state(Control_config_overlay_id, gr_screen.res, 0);
Ui_window.set_ignore_gadgets(0);
k = 0;
}
}
if ( !help_overlay_active(CONTROL_CONFIG_OVERLAY) ) {
if ( !help_overlay_active(Control_config_overlay_id) ) {
Ui_window.set_ignore_gadgets(0);
}
@@ -1720,7 +1720,7 @@ void control_config_do_frame(float frametime)
CC_Buttons[gr_screen.res][UNDO_BUTTON].button.enable(Config_item_undo != NULL);
if ( help_overlay_active(CONTROL_CONFIG_OVERLAY) ) {
if ( help_overlay_active(Control_config_overlay_id) ) {
CC_Buttons[gr_screen.res][HELP_BUTTON].button.reset_status();
Ui_window.set_ignore_gadgets(1);
}
@@ -1728,14 +1728,14 @@ void control_config_do_frame(float frametime)
k = Ui_window.process();
if ( (k > 0) || B1_JUST_RELEASED ) {
if ( help_overlay_active(CONTROL_CONFIG_OVERLAY) ) {
help_overlay_set_state(CONTROL_CONFIG_OVERLAY, 0);
if ( help_overlay_active(Control_config_overlay_id) ) {
help_overlay_set_state(Control_config_overlay_id, gr_screen.res, 0);
Ui_window.set_ignore_gadgets(0);
k = 0;
}
}
if ( !help_overlay_active(CONTROL_CONFIG_OVERLAY) ) {
if ( !help_overlay_active(Control_config_overlay_id) ) {
Ui_window.set_ignore_gadgets(0);
}
@@ -2108,7 +2108,7 @@ void control_config_do_frame(float frametime)
}
// blit help overlay if active
help_overlay_maybe_blit(CONTROL_CONFIG_OVERLAY);
help_overlay_maybe_blit(Control_config_overlay_id, gr_screen.res);
gr_flip();
}
+2
View File
@@ -288,6 +288,8 @@ extern int Axis_map_to[];
extern int Invert_axis[];
extern int Invert_axis_defaults[];
extern int Control_config_overlay_id;
extern config_item Control_config[]; //!< Stores the keyboard configuration
extern SCP_vector<config_item*> Control_config_presets; // tabled control presets; pointers to config_item arrays
extern char **Scan_code_text;
+289 -236
View File
@@ -19,10 +19,14 @@
#include "globalincs/systemvars.h"
#include "globalincs/def_files.h"
#define TARGET_TAB 0
#define SHIP_TAB 1
#define WEAPON_TAB 2
#define COMPUTER_TAB 3
// z64: These enumerations MUST equal to those in controlsconfig.cpp...
// z64: Really need a better way than this.
enum CC_tab {
TARGET_TAB =0,
SHIP_TAB =1,
WEAPON_TAB =2,
COMPUTER_TAB =3
};
int Failed_key_index;
@@ -36,8 +40,7 @@ int Axis_enabled_defaults[JOY_NUM_AXES] = { 1, 1, 1, 0, 0, 0 };
int Invert_axis[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
int Invert_axis_defaults[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
// arrays which hold the key mappings. The array index represents a key-independent action.
//
//! arrays which hold the key mappings. The array index represents a key-independent action.
//XSTR:OFF
config_item Control_config[CCFG_MAX + 1] = {
// targeting a ship
@@ -290,10 +293,10 @@ char *Joy_button_text_french[] = {
"Bouton 13", "Bouton 14", "Bouton 15", "Bouton 16", "Bouton 17", "Bouton 18",
"Bouton 19", "Bouton 20", "Bouton 21", "Bouton 22", "Bouton 23", "Bouton 24",
"Bouton 25", "Bouton 26", "Bouton 27", "Bouton 28", "Bouton 29", "Bouton 30",
"Bouton 31", "Bouton 32", "Chapeau Arriere", "Chapeau Avant", "Chapeau Gauche", "Chapeau Droite"
"Bouton 31", "Bouton 32", "Chapeau Arri\x8Are", "Chapeau Avant", "Chapeau Gauche", "Chapeau Droite"
};
// This is the text that is displayed on the screen for the keys a player selects
//! This is the text that is displayed on the screen for the keys a player selects
char *Scan_code_text_english[] = {
"", "Esc", "1", "2", "3", "4", "5", "6",
"7", "8", "9", "0", "-", "=", "Backspace", "Tab",
@@ -458,10 +461,11 @@ int translate_key_to_index(const char *key, bool find_override)
return -1;
}
// Given the system default key 'key', return the current key that is bound to the function
// Both are 'key' and the return value are descriptive strings that can be displayed
// directly to the user. If 'key' isn't a real key or not normally bound to anything,
// or there is no key current bound to the function, NULL is returned.
/*! Given the system default key 'key', return the current key that is bound to that function.
* Both are 'key' and the return value are descriptive strings that can be displayed
* directly to the user. If 'key' isn't a real key, is not normally bound to anything,
* or there is no key currently bound to the function, NULL is returned.
*/
char *translate_key(char *key)
{
int index = -1, key_code = -1, joy_code = -1;
@@ -553,7 +557,7 @@ void control_config_common_init()
Control_config[i].continuous_ongoing = false;
}
control_config_common_load_overrides();
control_config_common_load_overrides();
if(Lcl_gr){
Scan_code_text = Scan_code_text_german;
Joy_button_text = Joy_button_text_german;
@@ -576,237 +580,286 @@ void control_config_common_init()
#include <map>
#include <string>
SCP_map<SCP_string, int> mEnumNameToVal;
SCP_map<SCP_string, int> mKeyNameToVal;
SCP_map<SCP_string, CC_type> mCCTypeNameToVal;
SCP_map<SCP_string, char> mCCTabNameToVal;
void LoadEnumsIntoMap();
/*! Helper function to LoadEnumsIntoMaps(), Loads the Keyboard definitions/enumerations into mKeyNameToVal
*/
void LoadEnumsIntoKeyMap(void) {
// Dirty macro hack :D
#define ADD_ENUM_TO_KEY_MAP(Enum) mKeyNameToVal[#Enum] = (Enum);
ADD_ENUM_TO_KEY_MAP(KEY_SHIFTED)
/*
ADD_ENUM_TO_KEY_MAP(KEY_ALTED)
ADD_ENUM_TO_KEY_MAP(KEY_CTRLED)
ADD_ENUM_TO_KEY_MAP(KEY_DEBUGGED)
ADD_ENUM_TO_KEY_MAP(KEY_DEBUGGED1)
ADD_ENUM_TO_KEY_MAP(KEY_MASK)
ADD_ENUM_TO_KEY_MAP(KEY_DEBUG_KEY)
*/
ADD_ENUM_TO_KEY_MAP(KEY_0)
ADD_ENUM_TO_KEY_MAP(KEY_1)
ADD_ENUM_TO_KEY_MAP(KEY_2)
ADD_ENUM_TO_KEY_MAP(KEY_3)
ADD_ENUM_TO_KEY_MAP(KEY_4)
ADD_ENUM_TO_KEY_MAP(KEY_5)
ADD_ENUM_TO_KEY_MAP(KEY_6)
ADD_ENUM_TO_KEY_MAP(KEY_7)
ADD_ENUM_TO_KEY_MAP(KEY_8)
ADD_ENUM_TO_KEY_MAP(KEY_9)
ADD_ENUM_TO_KEY_MAP(KEY_A)
ADD_ENUM_TO_KEY_MAP(KEY_B)
ADD_ENUM_TO_KEY_MAP(KEY_C)
ADD_ENUM_TO_KEY_MAP(KEY_D)
ADD_ENUM_TO_KEY_MAP(KEY_E)
ADD_ENUM_TO_KEY_MAP(KEY_F)
ADD_ENUM_TO_KEY_MAP(KEY_G)
ADD_ENUM_TO_KEY_MAP(KEY_H)
ADD_ENUM_TO_KEY_MAP(KEY_I)
ADD_ENUM_TO_KEY_MAP(KEY_J)
ADD_ENUM_TO_KEY_MAP(KEY_K)
ADD_ENUM_TO_KEY_MAP(KEY_L)
ADD_ENUM_TO_KEY_MAP(KEY_M)
ADD_ENUM_TO_KEY_MAP(KEY_N)
ADD_ENUM_TO_KEY_MAP(KEY_O)
ADD_ENUM_TO_KEY_MAP(KEY_P)
ADD_ENUM_TO_KEY_MAP(KEY_Q)
ADD_ENUM_TO_KEY_MAP(KEY_R)
ADD_ENUM_TO_KEY_MAP(KEY_S)
ADD_ENUM_TO_KEY_MAP(KEY_T)
ADD_ENUM_TO_KEY_MAP(KEY_U)
ADD_ENUM_TO_KEY_MAP(KEY_V)
ADD_ENUM_TO_KEY_MAP(KEY_W)
ADD_ENUM_TO_KEY_MAP(KEY_X)
ADD_ENUM_TO_KEY_MAP(KEY_Y)
ADD_ENUM_TO_KEY_MAP(KEY_Z)
ADD_ENUM_TO_KEY_MAP(KEY_MINUS)
ADD_ENUM_TO_KEY_MAP(KEY_EQUAL)
ADD_ENUM_TO_KEY_MAP(KEY_DIVIDE)
ADD_ENUM_TO_KEY_MAP(KEY_SLASH)
ADD_ENUM_TO_KEY_MAP(KEY_SLASH_UK)
ADD_ENUM_TO_KEY_MAP(KEY_COMMA)
ADD_ENUM_TO_KEY_MAP(KEY_PERIOD)
ADD_ENUM_TO_KEY_MAP(KEY_SEMICOL)
ADD_ENUM_TO_KEY_MAP(KEY_LBRACKET)
ADD_ENUM_TO_KEY_MAP(KEY_RBRACKET)
ADD_ENUM_TO_KEY_MAP(KEY_RAPOSTRO)
ADD_ENUM_TO_KEY_MAP(KEY_LAPOSTRO)
ADD_ENUM_TO_KEY_MAP(KEY_ESC)
ADD_ENUM_TO_KEY_MAP(KEY_ENTER)
ADD_ENUM_TO_KEY_MAP(KEY_BACKSP)
ADD_ENUM_TO_KEY_MAP(KEY_TAB)
ADD_ENUM_TO_KEY_MAP(KEY_SPACEBAR)
ADD_ENUM_TO_KEY_MAP(KEY_NUMLOCK)
ADD_ENUM_TO_KEY_MAP(KEY_SCROLLOCK)
ADD_ENUM_TO_KEY_MAP(KEY_CAPSLOCK)
ADD_ENUM_TO_KEY_MAP(KEY_LSHIFT)
ADD_ENUM_TO_KEY_MAP(KEY_RSHIFT)
ADD_ENUM_TO_KEY_MAP(KEY_LALT)
ADD_ENUM_TO_KEY_MAP(KEY_RALT)
ADD_ENUM_TO_KEY_MAP(KEY_LCTRL)
ADD_ENUM_TO_KEY_MAP(KEY_RCTRL)
ADD_ENUM_TO_KEY_MAP(KEY_F1)
ADD_ENUM_TO_KEY_MAP(KEY_F2)
ADD_ENUM_TO_KEY_MAP(KEY_F3)
ADD_ENUM_TO_KEY_MAP(KEY_F4)
ADD_ENUM_TO_KEY_MAP(KEY_F5)
ADD_ENUM_TO_KEY_MAP(KEY_F6)
ADD_ENUM_TO_KEY_MAP(KEY_F7)
ADD_ENUM_TO_KEY_MAP(KEY_F8)
ADD_ENUM_TO_KEY_MAP(KEY_F9)
ADD_ENUM_TO_KEY_MAP(KEY_F10)
ADD_ENUM_TO_KEY_MAP(KEY_F11)
ADD_ENUM_TO_KEY_MAP(KEY_F12)
ADD_ENUM_TO_KEY_MAP(KEY_PAD0)
ADD_ENUM_TO_KEY_MAP(KEY_PAD1)
ADD_ENUM_TO_KEY_MAP(KEY_PAD2)
ADD_ENUM_TO_KEY_MAP(KEY_PAD3)
ADD_ENUM_TO_KEY_MAP(KEY_PAD4)
ADD_ENUM_TO_KEY_MAP(KEY_PAD5)
ADD_ENUM_TO_KEY_MAP(KEY_PAD6)
ADD_ENUM_TO_KEY_MAP(KEY_PAD7)
ADD_ENUM_TO_KEY_MAP(KEY_PAD8)
ADD_ENUM_TO_KEY_MAP(KEY_PAD9)
ADD_ENUM_TO_KEY_MAP(KEY_PADMINUS)
ADD_ENUM_TO_KEY_MAP(KEY_PADPLUS)
ADD_ENUM_TO_KEY_MAP(KEY_PADPERIOD)
ADD_ENUM_TO_KEY_MAP(KEY_PADDIVIDE)
ADD_ENUM_TO_KEY_MAP(KEY_PADMULTIPLY)
ADD_ENUM_TO_KEY_MAP(KEY_PADENTER)
ADD_ENUM_TO_KEY_MAP(KEY_INSERT)
ADD_ENUM_TO_KEY_MAP(KEY_HOME)
ADD_ENUM_TO_KEY_MAP(KEY_PAGEUP)
ADD_ENUM_TO_KEY_MAP(KEY_DELETE)
ADD_ENUM_TO_KEY_MAP(KEY_END)
ADD_ENUM_TO_KEY_MAP(KEY_PAGEDOWN)
ADD_ENUM_TO_KEY_MAP(KEY_UP)
ADD_ENUM_TO_KEY_MAP(KEY_DOWN)
ADD_ENUM_TO_KEY_MAP(KEY_LEFT)
ADD_ENUM_TO_KEY_MAP(KEY_RIGHT)
ADD_ENUM_TO_KEY_MAP(KEY_PRINT_SCRN)
ADD_ENUM_TO_KEY_MAP(KEY_PAUSE)
ADD_ENUM_TO_KEY_MAP(KEY_BREAK)
#undef ADD_ENUM_TO_KEY_MAP
}
/*! Helper function to LoadEnumsIntoMaps(), Loads the Control Types enumerations into mCCTypeNameToVal
*/
void LoadEnumsIntoCCTypeMap(void) {
// Dirty macro hack :D
#define ADD_ENUM_TO_CCTYPE_MAP(Enum) mCCTypeNameToVal[#Enum] = (Enum);
ADD_ENUM_TO_CCTYPE_MAP(CC_TYPE_TRIGGER)
ADD_ENUM_TO_CCTYPE_MAP(CC_TYPE_CONTINUOUS)
#undef ADD_ENUM_TO_CCTYPE_MAP
}
/*! Helper function to LoadEnumsIntoMaps(), Loads the Control Tabs enumerations into mCCTabNameToVal
*/
void LoadEnumsIntoCCTabMap(void) {
// Dirty macro hack :D
#define ADD_ENUM_TO_CCTAB_MAP(Enum) mCCTabNameToVal[#Enum] = (Enum);
ADD_ENUM_TO_CCTAB_MAP(TARGET_TAB)
ADD_ENUM_TO_CCTAB_MAP(SHIP_TAB)
ADD_ENUM_TO_CCTAB_MAP(WEAPON_TAB)
ADD_ENUM_TO_CCTAB_MAP(COMPUTER_TAB)
#undef ADD_ENUM_TO_CCTAB_MAP
}
/*! Loads the various control configuration maps to allow the parsing functions to appropriately map string tokns to
* their associated enumerations. The string tokens in the controlconfigdefaults.tbl match directly to their names in
* the C++ code, such as "KEY_5" in the .tbl mapping to the #define KEY_5 value
*/
void LoadEnumsIntoMaps() {
LoadEnumsIntoKeyMap();
LoadEnumsIntoCCTypeMap();
LoadEnumsIntoCCTabMap();
}
/**
* @brief Parses controlconfigdefault.tbl, and overrides the default control configuration for each valid entry in the .tbl
*/
void control_config_common_load_overrides()
{
LoadEnumsIntoMap();
if (cf_exists_full("controlconfigdefaults.tbl", CF_TYPE_TABLES))
read_file_text("controlconfigdefaults.tbl", CF_TYPE_TABLES);
else
read_file_text_from_array(defaults_get_file("controlconfigdefaults.tbl"));
reset_parse();
LoadEnumsIntoMaps();
if (cf_exists_full("controlconfigdefaults.tbl", CF_TYPE_TABLES)) {
read_file_text("controlconfigdefaults.tbl", CF_TYPE_TABLES);
} else {
read_file_text_from_array(defaults_get_file("controlconfigdefaults.tbl"));
}
reset_parse();
// start parsing
// TODO: Split this out into more helps. Too many tabs!
while(optional_string("#ControlConfigOverride")) {
config_item *cfg_preset = new config_item[CCFG_MAX + 1];
std::copy(Control_config, Control_config + CCFG_MAX + 1, cfg_preset);
Control_config_presets.push_back(cfg_preset);
config_item *cfg_preset = new config_item[CCFG_MAX + 1];
std::copy(Control_config, Control_config + CCFG_MAX + 1, cfg_preset);
Control_config_presets.push_back(cfg_preset);
while (required_string_either("#End","$Bind Name:"))
{
const int iBufferLength = 64;
char szTempBuffer[iBufferLength];
required_string("$Bind Name:");
stuff_string(szTempBuffer, F_NAME, iBufferLength);
const size_t cCntrlAryLength = sizeof(Control_config) / sizeof(Control_config[0]);
for (size_t i = 0; i < cCntrlAryLength; ++i)
{
config_item& r_ccConfig = cfg_preset[i];
if (!strcmp(szTempBuffer, r_ccConfig.text))
{
/**
* short key_default;
* short joy_default;
* char tab;
* bool hasXSTR;
* char type;
*/
int iTemp;
if (optional_string("$Key Default:"))
{stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.key_default = (short)mEnumNameToVal[szTempBuffer];}
if (optional_string("$Joy Default:"))
{stuff_int(&iTemp); r_ccConfig.joy_default = (short)iTemp;}
if (optional_string("$Key Mod Shift:"))
{stuff_int(&iTemp); r_ccConfig.key_default |= (iTemp == 1) ? KEY_SHIFTED : 0;}
if (optional_string("$Key Mod Alt:"))
{stuff_int(&iTemp); r_ccConfig.key_default |= (iTemp == 1) ? KEY_ALTED : 0;}
if (optional_string("$Key Mod Ctrl:"))
{stuff_int(&iTemp); r_ccConfig.key_default |= (iTemp == 1) ? KEY_CTRLED : 0;}
if (optional_string("$Category:"))
{stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.tab = (char)mEnumNameToVal[szTempBuffer];}
if (optional_string("$Has XStr:"))
{stuff_int(&iTemp); r_ccConfig.hasXSTR = (iTemp == 1);}
if (optional_string("$Type:"))
{stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.type = (char)mEnumNameToVal[szTempBuffer];}
if (optional_string("+Disable"))
r_ccConfig.disabled = true;
// Nerf the buffer now.
szTempBuffer[0] = '\0';
}
else if ((i + 1) == cCntrlAryLength)
{
error_display(1, "Bind Name not found: %s\n", szTempBuffer);
advance_to_eoln(NULL);
ignore_white_space();
return;
}
}
}
while (required_string_either("#End","$Bind Name:")) {
const int iBufferLength = 64;
char szTempBuffer[iBufferLength];
required_string("#End");
}
required_string("$Bind Name:");
stuff_string(szTempBuffer, F_NAME, iBufferLength);
const size_t cCntrlAryLength = sizeof(Control_config) / sizeof(Control_config[0]);
for (size_t i = 0; i < cCntrlAryLength; ++i) {
config_item& r_ccConfig = cfg_preset[i];
if (!strcmp(szTempBuffer, r_ccConfig.text)) {
/**
* short key_default;
* short joy_default;
* char tab;
* bool hasXSTR;
* char type;
*/
int iTemp;
if (optional_string("$Key Default:")) {
stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.key_default = (short)mKeyNameToVal[szTempBuffer];
}
if (optional_string("$Joy Default:")) {
stuff_int(&iTemp);
r_ccConfig.joy_default = (short)iTemp;
}
if (optional_string("$Key Mod Shift:")) {
stuff_int(&iTemp);
r_ccConfig.key_default |= (iTemp == 1) ? KEY_SHIFTED : 0;
}
if (optional_string("$Key Mod Alt:")) {
stuff_int(&iTemp);
r_ccConfig.key_default |= (iTemp == 1) ? KEY_ALTED : 0;
}
if (optional_string("$Key Mod Ctrl:")) {
stuff_int(&iTemp);
r_ccConfig.key_default |= (iTemp == 1) ? KEY_CTRLED : 0;
}
if (optional_string("$Category:")) {
stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.tab = (char)mKeyNameToVal[szTempBuffer];
}
if (optional_string("$Has XStr:")) {
stuff_int(&iTemp);
r_ccConfig.hasXSTR = (iTemp == 1);
}
if (optional_string("$Type:")) {
stuff_string(szTempBuffer, F_NAME, iBufferLength);
r_ccConfig.type = (char)mKeyNameToVal[szTempBuffer];
}
if (optional_string("+Disable")) {
r_ccConfig.disabled = true;
}
// Nerf the buffer now.
szTempBuffer[0] = '\0';
} else if ((i + 1) == cCntrlAryLength) {
error_display(1, "Bind Name not found: %s\n", szTempBuffer);
advance_to_eoln(NULL);
ignore_white_space();
return;
}
}
}
required_string("#End");
}
// Overwrite the control config with the first preset that was found
if (Control_config_presets.size() > 0) {
std::copy(Control_config_presets[0], Control_config_presets[0] + CCFG_MAX + 1, Control_config);
}
}
#define ADD_ENUM_TO_ENUM_MAP(Enum) mEnumNameToVal[#Enum] = (Enum);
void LoadEnumsIntoMap()
{
mEnumNameToVal["KEY_SHIFTED"] = KEY_SHIFTED;
/*
ADD_ENUM_TO_ENUM_MAP(KEY_SHIFTED)
ADD_ENUM_TO_ENUM_MAP(KEY_ALTED)
ADD_ENUM_TO_ENUM_MAP(KEY_CTRLED)
ADD_ENUM_TO_ENUM_MAP(KEY_DEBUGGED)
ADD_ENUM_TO_ENUM_MAP(KEY_DEBUGGED1)
ADD_ENUM_TO_ENUM_MAP(KEY_MASK)
ADD_ENUM_TO_ENUM_MAP(KEY_DEBUG_KEY)
*/
ADD_ENUM_TO_ENUM_MAP(KEY_0)
ADD_ENUM_TO_ENUM_MAP(KEY_1)
ADD_ENUM_TO_ENUM_MAP(KEY_2)
ADD_ENUM_TO_ENUM_MAP(KEY_3)
ADD_ENUM_TO_ENUM_MAP(KEY_4)
ADD_ENUM_TO_ENUM_MAP(KEY_5)
ADD_ENUM_TO_ENUM_MAP(KEY_6)
ADD_ENUM_TO_ENUM_MAP(KEY_7)
ADD_ENUM_TO_ENUM_MAP(KEY_8)
ADD_ENUM_TO_ENUM_MAP(KEY_9)
ADD_ENUM_TO_ENUM_MAP(KEY_A)
ADD_ENUM_TO_ENUM_MAP(KEY_B)
ADD_ENUM_TO_ENUM_MAP(KEY_C)
ADD_ENUM_TO_ENUM_MAP(KEY_D)
ADD_ENUM_TO_ENUM_MAP(KEY_E)
ADD_ENUM_TO_ENUM_MAP(KEY_F)
ADD_ENUM_TO_ENUM_MAP(KEY_G)
ADD_ENUM_TO_ENUM_MAP(KEY_H)
ADD_ENUM_TO_ENUM_MAP(KEY_I)
ADD_ENUM_TO_ENUM_MAP(KEY_J)
ADD_ENUM_TO_ENUM_MAP(KEY_K)
ADD_ENUM_TO_ENUM_MAP(KEY_L)
ADD_ENUM_TO_ENUM_MAP(KEY_M)
ADD_ENUM_TO_ENUM_MAP(KEY_N)
ADD_ENUM_TO_ENUM_MAP(KEY_O)
ADD_ENUM_TO_ENUM_MAP(KEY_P)
ADD_ENUM_TO_ENUM_MAP(KEY_Q)
ADD_ENUM_TO_ENUM_MAP(KEY_R)
ADD_ENUM_TO_ENUM_MAP(KEY_S)
ADD_ENUM_TO_ENUM_MAP(KEY_T)
ADD_ENUM_TO_ENUM_MAP(KEY_U)
ADD_ENUM_TO_ENUM_MAP(KEY_V)
ADD_ENUM_TO_ENUM_MAP(KEY_W)
ADD_ENUM_TO_ENUM_MAP(KEY_X)
ADD_ENUM_TO_ENUM_MAP(KEY_Y)
ADD_ENUM_TO_ENUM_MAP(KEY_Z)
ADD_ENUM_TO_ENUM_MAP(KEY_MINUS)
ADD_ENUM_TO_ENUM_MAP(KEY_EQUAL)
ADD_ENUM_TO_ENUM_MAP(KEY_DIVIDE)
ADD_ENUM_TO_ENUM_MAP(KEY_SLASH)
ADD_ENUM_TO_ENUM_MAP(KEY_SLASH_UK)
ADD_ENUM_TO_ENUM_MAP(KEY_COMMA)
ADD_ENUM_TO_ENUM_MAP(KEY_PERIOD)
ADD_ENUM_TO_ENUM_MAP(KEY_SEMICOL)
ADD_ENUM_TO_ENUM_MAP(KEY_LBRACKET)
ADD_ENUM_TO_ENUM_MAP(KEY_RBRACKET)
ADD_ENUM_TO_ENUM_MAP(KEY_RAPOSTRO)
ADD_ENUM_TO_ENUM_MAP(KEY_LAPOSTRO)
ADD_ENUM_TO_ENUM_MAP(KEY_ESC)
ADD_ENUM_TO_ENUM_MAP(KEY_ENTER)
ADD_ENUM_TO_ENUM_MAP(KEY_BACKSP)
ADD_ENUM_TO_ENUM_MAP(KEY_TAB)
ADD_ENUM_TO_ENUM_MAP(KEY_SPACEBAR)
ADD_ENUM_TO_ENUM_MAP(KEY_NUMLOCK)
ADD_ENUM_TO_ENUM_MAP(KEY_SCROLLOCK)
ADD_ENUM_TO_ENUM_MAP(KEY_CAPSLOCK)
ADD_ENUM_TO_ENUM_MAP(KEY_LSHIFT)
ADD_ENUM_TO_ENUM_MAP(KEY_RSHIFT)
ADD_ENUM_TO_ENUM_MAP(KEY_LALT)
ADD_ENUM_TO_ENUM_MAP(KEY_RALT)
ADD_ENUM_TO_ENUM_MAP(KEY_LCTRL)
ADD_ENUM_TO_ENUM_MAP(KEY_RCTRL)
ADD_ENUM_TO_ENUM_MAP(KEY_F1)
ADD_ENUM_TO_ENUM_MAP(KEY_F2)
ADD_ENUM_TO_ENUM_MAP(KEY_F3)
ADD_ENUM_TO_ENUM_MAP(KEY_F4)
ADD_ENUM_TO_ENUM_MAP(KEY_F5)
ADD_ENUM_TO_ENUM_MAP(KEY_F6)
ADD_ENUM_TO_ENUM_MAP(KEY_F7)
ADD_ENUM_TO_ENUM_MAP(KEY_F8)
ADD_ENUM_TO_ENUM_MAP(KEY_F9)
ADD_ENUM_TO_ENUM_MAP(KEY_F10)
ADD_ENUM_TO_ENUM_MAP(KEY_F11)
ADD_ENUM_TO_ENUM_MAP(KEY_F12)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD0)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD1)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD2)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD3)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD4)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD5)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD6)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD7)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD8)
ADD_ENUM_TO_ENUM_MAP(KEY_PAD9)
ADD_ENUM_TO_ENUM_MAP(KEY_PADMINUS)
ADD_ENUM_TO_ENUM_MAP(KEY_PADPLUS)
ADD_ENUM_TO_ENUM_MAP(KEY_PADPERIOD)
ADD_ENUM_TO_ENUM_MAP(KEY_PADDIVIDE)
ADD_ENUM_TO_ENUM_MAP(KEY_PADMULTIPLY)
ADD_ENUM_TO_ENUM_MAP(KEY_PADENTER)
ADD_ENUM_TO_ENUM_MAP(KEY_INSERT)
ADD_ENUM_TO_ENUM_MAP(KEY_HOME)
ADD_ENUM_TO_ENUM_MAP(KEY_PAGEUP)
ADD_ENUM_TO_ENUM_MAP(KEY_DELETE)
ADD_ENUM_TO_ENUM_MAP(KEY_END)
ADD_ENUM_TO_ENUM_MAP(KEY_PAGEDOWN)
ADD_ENUM_TO_ENUM_MAP(KEY_UP)
ADD_ENUM_TO_ENUM_MAP(KEY_DOWN)
ADD_ENUM_TO_ENUM_MAP(KEY_LEFT)
ADD_ENUM_TO_ENUM_MAP(KEY_RIGHT)
ADD_ENUM_TO_ENUM_MAP(KEY_PRINT_SCRN)
ADD_ENUM_TO_ENUM_MAP(KEY_PAUSE)
ADD_ENUM_TO_ENUM_MAP(KEY_BREAK)
ADD_ENUM_TO_ENUM_MAP(TARGET_TAB)
ADD_ENUM_TO_ENUM_MAP(SHIP_TAB)
ADD_ENUM_TO_ENUM_MAP(WEAPON_TAB)
ADD_ENUM_TO_ENUM_MAP(COMPUTER_TAB)
}
}
+2 -9
View File
@@ -55,12 +55,8 @@ void cutscene_init()
int rval;
cutscene_info cutinfo;
// open localization
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0) {
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", "cutscenes.tbl", rval));
lcl_ext_close();
return;
}
@@ -107,9 +103,6 @@ void cutscene_init()
}
required_string("#End");
// close localization
lcl_ext_close();
}
// function to return 0 based index of which CD a particular movie is on
@@ -261,7 +254,7 @@ int cutscenes_validate_cd(char *mve_name, int prompt_for_cd)
int cd_present = 0;
int cd_drive_num;
int cd_mve_is_on;
char volume_name[128];
char volume_name[MAX_PATH_LEN];
int num_attempts = 0;
@@ -334,7 +327,7 @@ void cutscenes_screen_play()
else
sprintf(str, XSTR("Unable to play movie %s.", 204), Cutscenes[which_cutscene].name);
popup(0, 1, POPUP_OK, str );
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, str );
}
}
+1 -1
View File
@@ -796,7 +796,7 @@ THEORAFILE *theora_open(char *filename)
// lower case filename for checking
memset( lower_name, 0, sizeof(lower_name) );
strncpy( lower_name, filename, strlen(filename) );
strncpy( lower_name, filename, sizeof(lower_name)-1 );
strlwr(lower_name);
char *p = strchr( lower_name, '.' );
File diff suppressed because it is too large. Load diff
+279
View File
@@ -0,0 +1,279 @@
#ifndef _CONSOLE_H
#define _CONSOLE_H
/*
* z64555's debug console, created for the FreeSpace Source Code project
*
* Portions of this source code are based on works by Volition, Inc. circa 1999. You may not sell or otherwise
* commercially exploit the source or things you created based on the source.
*/
/**
* @file console.h
* @brief An overhauled/updated debug console to allow monitoring, testing, and general debugging of new features.
*
* @details
* Of key interest is Volition's DCF macro, which adds the function argument to the available command list in the
* debug console. These functions may be defined in the .cpp file that they are related to, but it is recommended
* that they be in their own .cpp if they have multiple sub-arguments (ex: Git has its sub-arguments delimited by
* a pair of -'s, or --)
*/
#include "debugconsole/consoleparse.h"
#include "globalincs/pstypes.h"
#include "globalincs/vmallocator.h"
#define DC_MAX_COMMANDS 300
class debug_command;
/**
* @def DCF
*
* @brief The potent DCF macro, used to define new debug commands for the console.
*
* @param function_name[in] The name of the function, as shown in the debug console
* @param help_txt[in] The short-help text, as shown as listed from the 'help' command
*
* @details
* Each DCF is responsible for getting data from the debug console's command line. The parsing functions for the
* command line have been set up to have similar syntax and usage as the parselo commands. (see consoleparse.h)
* Most, if not all, argument and subcommand strings should be parsed by the dc_optional_string functions.
* Usage example:
* DCF(toggle_it, "description")
* {
* if (dc_optional_string_either("help", "--help")) {
* dc_printf("Usage: sample. Toggles This_var on/off\n");
*
* } else if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
* dc_printf("This_var is %s\n", (This_var ? "ON" : "OFF"));
*
* } else {
* This_var = !This_var;
*
* }
* }
*
* In the console, the command would be listed as 'toggle_it', and dcf_help would display it as:
* toggle_it - Usage: sample. Toggles This_var on/off.
* Note: The only allowed function type is a void fn( void )
*/
#define DCF(function_name, help_text) \
void dcf_##function_name(); \
debug_command dcmd_##function_name(#function_name, help_text, dcf_##function_name); \
void dcf_##function_name()
/**
* @def Shortcut for debug commands that toggle a bool, such as Show_lightning
*
* @param [in] function_name Name of the function, as shown in the debug console
* @param [in] bool_variable Name of the variable to allow toggling.
*/
#define DCF_BOOL(function_name, bool_variable) \
void dcf_##function_name(); \
debug_command dcmd_##function_name(#function_name, "Sets or toggles the boolean: "#bool_variable, dcf_##function_name ); \
void dcf_##function_name() { \
bool bool_tmp = bool_variable != 0; \
if (dc_optional_string_either("help", "--help")) { \
dc_printf( "Usage: %s [bool]\nSets %s to true or false. If nothing passed, then toggles it.\n", #function_name, #bool_variable ); \
return; \
} \
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) { \
dc_printf("%s = %s\n", #bool_variable, (bool_variable ? "TRUE" : "FALSE")); \
return; \
} \
if (!dc_maybe_stuff_boolean(&bool_tmp)) { \
if (bool_variable != 0) \
bool_variable = 0; \
else \
bool_variable = 1; \
} else { \
if (bool_tmp) \
bool_variable = 1; \
else \
bool_variable = 0; \
} \
dc_printf("%s set to %s\n", #bool_variable, (bool_variable != 0 ? "TRUE" : "FALSE")); \
}
/**
* @def Same as DCF_BOOL, but with custom help strings
*
* @param [in] function_name Name of the function, as shown in the debug console
* @param [in] bool_variable Name of the variable to allow toggling.
*/
#define DCF_BOOL2(function_name, bool_variable, short_help, long_help) \
void dcf_##function_name(); \
debug_command dcmd_##function_name(#function_name, short_help, dcf_##function_name ); \
void dcf_##function_name() { \
if (dc_optional_string_either("help", "--help")) { \
dc_printf( #long_help ); \
return; \
} \
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) { \
dc_printf("%s = %s\n", #function_name, (bool_variable ? "TRUE" : "FALSE")); \
return; \
} \
if (!dc_maybe_stuff_boolean(&bool_variable)) { \
bool_variable = !bool_variable; \
} \
}
/**
* @def Shortcut for single-variable setters/monitors
*
* @param [in] function_name
* @param [in] float_variable
* @param [in] short_help
*/
#define DCF_FLOAT(function_name, float_variable, short_help) \
void dcf_##function_name(); \
debug_command dcmd_##function_name(#function_name, short_help, dcf_##function_name ); \
void dcf_##function_name() { \
float value; \
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) { \
dc_printf("%s = %f\n", #float_variable, float_variable); \
return; \
} \
dc_stuff_float(&value); \
float_variable = value; \
dc_printf("%s set to %f\n", #float_variable, float_variable); \
}
/**
* @def Shortcut for single-variable setters/monitors with lower/upper bounds clamping
*
* @param [in] function_name
* @param [in] float_variable
* @param [in] lower_bounds
* @param [in] upper_bounds
* @param [in] short_help
*/
#define DCF_FLOAT2(function_name, float_variable, lower_bounds, upper_bounds, short_help) \
void dcf_##function_name(); \
debug_command dcmd_##function_name(#function_name, short_help, dcf_##function_name ); \
void dcf_##function_name() { \
float value; \
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) { \
dc_printf("%s = %f\n", #float_variable, float_variable); \
return; \
} \
dc_stuff_float(&value); \
CLAMP(float_variable, lower_bounds, upper_bounds); \
float_variable = value; \
dc_printf("%s set to %f\n", #float_variable, float_variable); \
}
/**
* @def Shortcut for single-variable setters/monitors
*
* @param [in] function_name
* @param [in] int_variable
* @param [in] short_help
*/
#define DCF_INT(function_name, int_variable, short_help) \
void dcf_##function_name(); \
debug_command dcmd_##function_name(#function_name, short_help, dcf_##function_name ); \
void dcf_##function_name() { \
int value; \
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) { \
dc_printf("%s = %i\n", #int_variable, int_variable); \
return; \
} \
dc_stuff_int(&value); \
int_variable = value; \
dc_printf("%s set to %i\n", #int_variable, int_variable); \
}
/**
* @def Shortcut for single-variable setters/monitors with lower/upper bounds clamping
*
* @param [in] function_name
* @param [in] int_variable
* @param [in] lower_bounds
* @param [in] upper_bounds
* @param [in] short_help
*/
#define DCF_INT2(function_name, int_variable, lower_bounds, upper_bounds, short_help) \
void dcf_##function_name(); \
debug_command dcmd_##function_name(#function_name, short_help, dcf_##function_name ); \
void dcf_##function_name() { \
int value; \
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) { \
dc_printf("%s = %i\n", #int_variable, int_variable); \
return; \
} \
dc_stuff_int(&value); \
CLAMP(int_variable, lower_bounds, upper_bounds); \
int_variable = value; \
dc_printf("%s set to %i\n", #int_variable, int_variable); \
}
/**
* @class debug_command
* @brief Class to aggregate a debug command with its name (as shown in the console) and short help.
*
* @details
* Note: Long help, as evoked by '<command> help', should be handled by the function itself. It is recommended
* that arguments that have sub-arguments be in their own function, so as to aide in organization and to keep the
* size of the command function down.
*/
class debug_command {
public:
const char *name; //!< The name of the command, as shown in the debug console
const char *help; //!< The short help string, as shown by 'help <command>'
void (*func)(); //!< Pointer to the function that to run when this command is evoked
debug_command();
/**
* @brief Adds a debug command to the debug_commands map, if it isn't in there already.
*
* @details The DCF macro more or less guarantees that a command won't be duplicated on compile time. But no harm in
* some extra caution.
*/
debug_command(const char *name, const char *help, void (*func)());
};
/**
* @class is_dcmd
* @brief Predicate class used to search for a dcmd by name
*/
class is_dcmd {
public:
const char *name;
is_dcmd(const char *_name) : name(_name) {}
bool operator() (debug_command* dcmd)
{
return (strcmp(name, dcmd->name) == 0);
}
};
extern bool Dc_debug_on;
extern int dc_commands_size;
extern uint lastline;
extern SCP_string dc_command_str; // The rest of the command line, from the end of the last processed arg on.
/**
* @brief Pauses the output of a command and allows user to scroll through the output history.
*
* @details Returns true if user has pressed Esc, returns false otherwise. Use this in your function to (safely?) break
* out of the loop it's presumably in.
*/
bool dc_pause_output(void);
/**
* @brief Prints the given char string to the debug console
* @details See the doc for std::printf() for formating and more details
*/
void dc_printf(const char *format, ...);
/**
* @brief Opens and processes the debug console. (Blocking call)
* @details TODO: Make this a non-blocking call so that the game can still run while the debug console is open.
*/
void debug_console(void (*func)(void) = NULL);
#endif // _CONSOLE_H
+162
View File
@@ -0,0 +1,162 @@
/*
* z64555's debug console
* Created for the FreeSpace Source Code project
*
* Portions of this source code are based on works by Volition, Inc. circa
* 1999. You may not sell or otherwise commercially exploit the source or things you
* created based on the source
*/
/**
* @file consolecmds.cpp
*
* @brief This file contains the "built-in" commands for the debug console, and is listed by the 'help' and '?' commands
*
* @details
* All other debug commands should be in their respective files and added to the console with the DCF macro. For
* further documentation, please see console.h
*/
#include "debugconsole/console.h"
#include "debugconsole/consoleparse.h"
#include "globalincs/pstypes.h"
#include "globalincs/vmallocator.h"
#include "io/key.h"
#include <algorithm>
// ========================= GLOBALS =========================
debug_command *dc_commands[DC_MAX_COMMANDS];
int dc_commands_size = 0;
// ========================= LOCALS ==========================
// dcf_shell commands
void dc_shell_font( void );
void dc_shell_resize( void );
void dc_shell_resize_buf( void );
// =================== class debug_command ===================
debug_command::debug_command()
: name(""), help(""), func(NULL) {
};
debug_command::debug_command(const char *_name, const char *_help, void(*_func)())
: name(_name), help(_help), func(_func) {
int i = 0;
int ret = 0;
if (dc_commands_size >= DC_MAX_COMMANDS) {
Error(LOCATION, "Too many debug console commands! Please inform a coder to increase DC_MAX_COMMANDS.");
return;
}
// Start the insertion sort by finding where to stick the debug command
for (; i < dc_commands_size; ++i) {
ret = stricmp(dc_commands[i]->name, _name);
if (ret == 0) {
Error(LOCATION, "Debug Command %s already exists! Please inform a coder immediately.", _name);
return;
} else if (ret > 0) {
// Insert the command here
break;
} // Else, do nothing
}
// Then, do the insertion
if (i < dc_commands_size) {
for (int j = dc_commands_size; j > i; --j) {
dc_commands[j] = dc_commands[j - 1];
}
dc_commands[i] = this;
dc_commands_size++;
} else {
dc_commands[dc_commands_size] = this;
dc_commands_size++;
}
}
// ============================== IMPLEMENTATIONS =============================
DCF(debug, "Runs a command in debug mode.")
{
int i;
SCP_string command = "";
Dc_debug_on = true;
dc_stuff_string_white(command);
if (command == "") {
dc_printf("<debug> No command given\n");
return;
} // Else, command is present.
for (i = 0; i < dc_commands_size; ++i) {
if (stricmp(dc_commands[i]->name, command.c_str()) == 0) {
break;
} // Else, continue
}
if (i == dc_commands_size) {
dc_printf("<debug> Command not found: '%s'\n", command.c_str());
return;
} // Else, we found our command
dc_printf("<debug> Executing command: '%s'\n", command.c_str());
// try {
dc_commands[i]->func();
// } catch {
// }
Dc_debug_on = false;
}
DCF(help, "Displays the help list." )
{
extern uint DROWS;
int i;
SCP_string command = "";
dc_maybe_stuff_string_white(command);
if ((command == "help") || (command == "man"))
{
// Moron filter :D
dc_printf("GTVA Command: Sorry pilot. You're on your own.\n");
return;
} else if (command != "") {
for (i = 0; i < dc_commands_size; ++i) {
if (stricmp(dc_commands[i]->name, command.c_str()) == 0) {
break;
} // Else, continue
}
if (i == dc_commands_size) {
dc_printf("Command not found: '%s'\n", command.c_str());
return;
} // Else, we found our command
dc_printf("%s\n", dc_commands[i]->help);
return;
} // Else, command line is empty, print out the help list
dc_printf("FreeSpace Open Debug Console\n");
dc_printf(" These commands are defined internally.\n");
dc_printf(" Typing 'help function_name' will give the short help on the function.\n");
dc_printf(" Some functions may have detailed help, try passing \"help\" or \"--help\" to them.");
dc_printf(" F3 selects last command line. Up and Down arrow keys scroll through the command history\n");
dc_printf("\n");
dc_printf(" Available commands:\n");
for (i = 0; i < dc_commands_size; ++i) {
if (((lastline % DROWS) == 0) && (lastline != 0)) {
dc_pause_output();
}
dc_printf(" %s - %s\n", dc_commands[i]->name, dc_commands[i]->help);
}
}
debug_command dc_man("man", "Also displays the help list", dcf_help);
File diff suppressed because it is too large. Load diff
+459
View File
@@ -0,0 +1,459 @@
#ifndef _CONSOLEPARSE_H
#define _CONSOLEPARSE_H
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Command-line parsing functions for z64555's debug console, created for the FreeSpace Source Code project
//
// Portions of this source code are based on works by Volition, Inc. circa 1999. You may not sell or otherwise
// commercially exploit the source or things you created based on the source.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* @file consoleparse.h
* @brief Parsing functions for the command line. Previously known as the command line scanner
*
* @details A lot of functions here are blatently copied from parselo.h :D
*/
#include "globalincs/pstypes.h"
#include <cstdarg>
#define MAX_CLI_LEN 512
#define MAX_TOKEN_LENGTH 255
enum dc_token {
DCT_NONE = 0, //!< No token
DCT_STRING, //!< String
DCT_FLOAT, //!< Floating point
DCT_INT, //!< Integral
DCT_UINT, //!< Unsigned Integral
DCT_BYTE, //!< Integral with values between -128 and 127
DCT_UBYTE, //!< Integral with values between 0 and 255
DCT_BOOL, //!< Integral or string evaluated as a boolean
DCT_MAX_ITEMS //!< Maximum number of dc_token elements. Primarily used as an end value in loops
};
/**
* @class errParse
*
* @brief Class thrown when a required token is not found
*
* @details This is a basic parser error, it contains the token (a single word) that was found, and the expected token
* type. Some DCT's, such as the DCT_STRING's, have their own specific requirements for error handling, and as
* such get their own class derived from errParse. The catching routines should be able to catch the derived error
* objects, but if not, they can be caught by a routine looking for the base class and then be casted to their
* proper type.
*/
class errParse {
public:
SCP_string found_token;
dc_token expected_type;
/**
* @brief Invalid/Unexpected token constructor
* @param [in] found_str The token that was found
* @param [in] expected_dct The token type that was expected
*/
errParse(const char *found_str, dc_token expected_dct)
: found_token(found_str), expected_type(expected_dct)
{
}
};
/**
* @class errParseString
*
* @brief Class thrown when an expected string was not found. Can/should contain all of the expected strings.
*/
class errParseString : public errParse
{
public:
SCP_vector<SCP_string> expected_tokens;
/**
* @brief Invalid/Unexpected token constructor.
*
* @param [in] found_str The string that was found
* @param [in] str The token that was expected
*/
errParseString(const char *found_str, char *str)
: errParse(found_str, DCT_STRING)
{
expected_tokens.push_back(str);
}
/**
* @brief Invalid/Unexpected token constructor.
*
* @param [in] found_str The string that was found
* @param [in] str1 The first token that was expected
* @param [in] str2 The second token that was expected
*/
errParseString(const char *found_str, char *str1, char *str2)
: errParse(found_str, DCT_STRING)
{
expected_tokens.push_back(str1);
expected_tokens.push_back(str2);
}
/**
* @brief Invalid/Unexpected token constructor.
*
* @param [in] found_str The string that was found
* @param [in] strings The strings that were expected
*/
errParseString(const char *found_str, SCP_vector<SCP_string> &strings)
: errParse(found_str, DCT_STRING), expected_tokens(strings)
{
}
};
/**
* @class errParseOverflow
*
* @brief Class thrown when the parsed string or token could not be stuffed into the smaller destination container
*
* @var found_str Contains the first 'len' valid characters.
*/
class errParseOverflow : public errParse
{
public:
size_t len; //!< The size of the destination container
errParseOverflow(const char *found_str, size_t _len)
: errParse(found_str, DCT_STRING), len(_len)
{
}
};
/**
* @brief Initializes the DC command line parser
*/
void dc_parse_init(SCP_string &str);
/**
* @brief Advances the parser past whitespace characters
*/
void dc_ignore_white_space(void);
/**
* @brief Advances the parser past grayspace characters
*/
void dc_ignore_gray_space(void);
// Required/Optional Token
/**
* @brief Searches for a specified required string, throwing an errParse if not found.
*
* @param[in] pstr The string to search for
*
* @throws errParseString with the required string
*/
void dc_required_string(char *pstr);
/**
* @brief Searchs for either of the specified required strings, throwing an errParse if neither are found
*
* @param[in] str1 The first string to search for
* @param[in] str2 The second string to search for
*
* @retval 0 if str1 was found, or
* @retval 1 if str2 was found
*
* @throws errParseString with the required strings
*/
int dc_required_string_either(char *str1, char *str2);
/**
* @brief Searches for specified required strings
*
* @param[in] n The number of char[] or c_str's given
* @param[in] ... A comma delimited list of one or more required strings.
*
* @returns The index of the specified required strings (as if they were an array)
*
* @throws errParseString with the required strings
*/
uint dc_required_string_any(const uint n, ...);
/**
* @brief Searches for an optional string
*
* @param[in] pstr The char[] to look for
*
* @retval true if the string was found,
* @retval false otherwise
*/
bool dc_optional_string(const char *pstr);
/**
* @brief Searches for an optional string and it's alias
*
* @param[in] str1 The char[] to look for
* @param[in] str2 The alternative char[] to look for
*
* @retval true if the string was found,
* @retval false otherwise
*/
bool dc_optional_string_either(const char *str1, const char *str2);
// ==========================
// Stuffers
// ==========================
/**
* @brief Stuffs a float to the given variable.
*
* @param[in] f The float variable to stuff to
*
* @throws errParse if an unexpected or otherwise malformed float string is found.
* @throws errParse if nothing was found
*/
void dc_stuff_float(float *f);
/**
* @brief Stuffs an int to the given variable. Supports binary (0b), hexadecimal (0x), and octal (0o) formats
*
* @param[in] i The int variable to stuff to
*
* @details The binary, hexadecimal, and octal formats must be prefixed by their associated string.
* Ex: "0xDEADBEEF" would be parsed properly while "DEADBEEF" would throw an error
*
* @throws errParse if an unexpected or otherwise malformed float string is found.
* @throws errParse if nothing was found
*/
void dc_stuff_int(int *i);
/**
* @brief Stuffs an unsigned int to the given variable. Supports binary (0b), hexadecimal (0x), and octal (0o) formats
*
* @param[in] i The unsigned int variable to stuff to
*
* @details The binary, hexadecimal, and octal formats must be prefixed by their associated string.
* Ex: "0xDEADBEEF" would be parsed properly while "DEADBEEF" would throw an error
*
* @throws errParse if an unexpected or otherwise malformed float string is found.
* @throws errParse if nothing was found
*/
void dc_stuff_uint(uint *i);
/**
* @brief Stuffs an unsigned byte to the given variable. Supports binary (0b), hexadecimal (0x), and octal (0o) formats
*
* @param[in] i The ubyte variable to stuff to
*
* @details The binary, hexadecimal, and octal formats must be prefixed by their associated string.
* Ex: "0x0F" would be parsed properly while "0F" would throw an error
*
* @throws errParse if an unexpected or otherwise malformed float string is found.
* @throws errParse if nothing was found
*/
void dc_stuff_ubyte(ubyte *i);
/**
* @brief stuffs a boolean evaluated integer or string into the given variable.
*
* @param[in] b The bool variable to stuff to
*
* @details Supports a number of literal strings as true and false, including "true", "false", "yes", "no" and the
* yes/no equivalents in other languages supported in localization.
* TODO: Make a static string map to handle this instead of being hard-coded
*
* @throws errParse if an unexpected or otherwise malformed float string is found.
* @throws errParse if nothing was found
*/
void dc_stuff_boolean(bool *b);
/**
* @brief stuffs a boolean evaluated integer or string into the given variable.
*
* @param[in] i The int variable to stuff to. 0 is false, 1 is true
*
* @details Supports a number of literal strings as true and false, including "true", "false", "yes", "no" and the
* yes/no equivalents in other languages supported in localization.
* TODO: Make a static string map to handle this instead of being hard-coded
*
* @throws errParse if an unexpected or otherwise malformed float string is found.
* @throws errParse if nothing was found
*/
void dc_stuff_boolean(int *i);
/**
* @brief Stuffs a string to out_str from the command line, stopping at the end of the command line
*
* @param[out] str Destination string
* @param[in] maxlen Maximum length to copy. (maxlen <= sizeof(str)) && (maxlen <= MAX_TOKEN_LENGTH)
*
* @throws errParse when nothing left was found on the command line
* @throws errParseOverflow when parser cannot stuff the entirety of the found string into out_str
*/
void dc_stuff_string(char *str, size_t maxlen);
/**
* @brief Stuffs a string to out_str from the command line, stopping at the end of the command line
*
* @param[out] str Destination string
*
* @throws errParse when nothing left was found on the command line
*/
void dc_stuff_string(SCP_string &str);
/**
* @brief Stuffs a whitespace delimited string to out_str from the command line, stopping at the end of the command line
*
* @param[out] str Destination string
* @param[in] len Maximum length to copy. (len <= sizeof(str)) && (len <= MAX_TOKEN_LENGTH)
*
* @throws errParse when nothing left was found on the command line
* @throws errParseOverflow when parser cannot stuff the entirety of the found string into out_str
*/
void dc_stuff_string_white(char *str, size_t len);
/**
* @brief Stuffs a whitespace delimited string to out_str from the command line, stopping at the end of the command line
*
* @param[out] str Destination string
*
* @throws errParse when nothing left was found on the command line
*/
void dc_stuff_string_white(SCP_string &str);
/**
* @brief Tries to stuff a float from the Command_string.
*
* @param[in] f The float variable to maybe stuff.
*
* @details
* If there's nothing on the command line, *f = 0 and false is returned
*
* If there's something on the command line, and we're able to convert it, *f = the converted value, true is
* returned, and the parser is advanced past the token
*
* If there's something on command line, but we can't convert it, an errParse is thrown
*/
bool dc_maybe_stuff_float(float *f);
/**
* @brief Tries to stuff an int from the Command_string.
*
* @param[in] i The int variable to maybe stuff.
*
* @details
* If there's nothing on the command line, *i = 0 and false is returned
*
* If there's something on the command line, and we're able to convert it, *i = the converted value, true is
* returned, and the parser is advanced past the token
*
* If there's something on command line, but we can't convert it, an errParse is thrown
*/
bool dc_maybe_stuff_int(int *i);
/**
* @brief Tries to stuff an uint from the Command_string.
*
* @param[in] i The uint variable to maybe stuff.
*
* @details
* If there's nothing on the command line, *i = 0 and false is returned
*
* If there's something on the command line, and we're able to convert it, *i = the converted value, true is
* returned, and the parser is advanced past the token
*
* If there's something on command line, but we can't convert it, an errParse is thrown
*/
bool dc_maybe_stuff_uint(uint *i);
/**
* @brief Tries to stuff an ubyte from the Command_string.
*
* @param[in] i The ubyte variable to maybe stuff.
*
* @details
* If there's nothing on the command line, *i = 0 and false is returned
*
* If there's something on the command line, and we're able to convert it, *i = the converted value, true is
* returned, and the parser is advanced past the token
*
* If there's something on command line, but we can't convert it, an errParse is thrown
*/
bool dc_maybe_stuff_ubyte(ubyte *i);
/**
* @brief Tries to stuff a bool from the Command_string.
*
* @param[in] b The bool variable to maybe stuff.
*
* @details
* If there's nothing on the command line, *b = false and false is returned
*
* If there's something on the command line, and we're able to convert it, *b = the converted value, true is
* returned, and the parser is advanced past the token
*
* If there's something on command line, but we can't convert it, an errParse is thrown
*/
bool dc_maybe_stuff_boolean(bool *b);
/**
* @brief Tries to stuff an int with a bool value from the Command_string.
*
* @param[in] i The int variable to maybe stuff.
*
* @details
* If there's nothing on the command line, *i = 0 and false is returned
*
* If there's something on the command line, and we're able to convert it, *i = the converted value, true is
* returned, and the parser is advanced past the token
*
* If there's something on command line, but we can't convert it, an errParse is thrown
*/
bool dc_maybe_stuff_boolean(int *i);
/**
* @brief Tries to stuff a string to out_str from the command line, stopping at the end of the command line
*
* @param[out] str Destination string. If nothing was found, str = ""
* @param[in] len Maximum length to copy. (len <= sizeof(str)) && (len <= MAX_TOKEN_LENGTH)
*
* @retval true if the operation was successful,
* @retval false otherwise
*
* @throws errParseOverflow when parser cannot stuff the entirety of the found string into out_str
*/
bool dc_maybe_stuff_string(char *str, size_t len);
/**
* @brief Tries to stuff a string to out_str from the command line, stopping at the end of the command line
*
* @param[out] str Destination string. If nothing was found, str = ""
*
* @retval true if the operation was successful,
* @retval false otherwise
*/
bool dc_maybe_stuff_string(SCP_string &str);
/**
* @brief Tries to stuff a whitespace delimited string to out_str from the command line, stopping at the end of the command line
*
* @param[out] str Destination string. If nothing was found, str = ""
* @param[in] len Maximum length to copy. (maxlen <= sizeof(str)) && (maxlen <= MAX_TOKEN_LENGTH)
*
* @retval true if the operation was successful,
* @retval false otherwise
*
* @throws errParseOverflow when parser cannot stuff the entirety of the found string into out_str
*/
bool dc_maybe_stuff_string_white(char *str, size_t len);
/**
* @brief Tries to stuff a whitespace delimited string to out_str from the command line, stopping at the end of the command line
*
* @param[out] str Destination string. If nothing was found, str = ""
*
* @retval true if the operation was successful,
* @retval false otherwise
*/
bool dc_maybe_stuff_string_white(SCP_string &str);
#endif // _CONSOLEPARSE_H
+3 -8
View File
@@ -163,12 +163,8 @@ void parse_fireball_tbl(const char *filename)
lod_checker lod_check;
color fb_color;
// open localization
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0) {
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", filename, rval));
lcl_ext_close();
return;
}
@@ -241,9 +237,6 @@ void parse_fireball_tbl(const char *filename)
}
required_string("#End");
// close localization
lcl_ext_close();
}
void fireball_parse_tbl()
@@ -381,7 +374,9 @@ void fireball_render(object * obj)
MONITOR_INC( NumFireballsRend, 1 );
num = obj->instance;
memset(&p, 0, sizeof(p));
num = obj->instance;
fb = &Fireballs[num];
if ( Fireballs[num].current_bitmap < 0 )
+1
View File
@@ -58,6 +58,7 @@ void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_n
vm_vec_scale_add( &center, pos, &orient->vec.fvec, -(max_radius/2.5f)/3.0f );
memset(verts, 0, sizeof(verts));
if (Warp_glow_bitmap >= 0) {
float r = radius;
+6 -2
View File
@@ -22,6 +22,7 @@ FictionViewerDlg::FictionViewerDlg(CWnd* pParent /*=NULL*/)
//{{AFX_DATA_INIT(FictionViewerDlg)
m_story_file = _T("");
m_font_file = _T("");
m_voice_file = _T("");
m_fiction_music = 0;
//}}AFX_DATA_INIT
}
@@ -33,6 +34,7 @@ void FictionViewerDlg::DoDataExchange(CDataExchange* pDX)
//{{AFX_DATA_MAP(FictionViewerDlg)
DDX_Text(pDX, IDC_STORY_FILE, m_story_file);
DDX_Text(pDX, IDC_FONT_FILE, m_font_file);
DDX_Text(pDX, IDC_VOICE_FILE, m_voice_file);
DDX_CBIndex(pDX, IDC_FICTION_MUSIC, m_fiction_music);
//}}AFX_DATA_MAP
}
@@ -60,6 +62,7 @@ BOOL FictionViewerDlg::OnInitDialog()
// init variables
m_story_file = _T(fiction_file());
m_font_file = _T(fiction_font());
m_voice_file = _T(fiction_voice());
m_fiction_music = Mission_music[SCORE_FICTION_VIEWER] + 1;
CDialog::OnInitDialog();
@@ -73,7 +76,7 @@ void FictionViewerDlg::OnOK()
// load it up
fiction_viewer_reset();
fiction_viewer_load((char *)(LPCSTR) m_story_file, (char *)(LPCSTR) m_font_file);
fiction_viewer_load((const char *)(LPCSTR)m_story_file, (const char *)(LPCSTR)m_font_file, (const char *)(LPCSTR)m_voice_file);
// set music
Mission_music[SCORE_FICTION_VIEWER] = m_fiction_music - 1;
@@ -111,5 +114,6 @@ void FictionViewerDlg::OnClose()
int FictionViewerDlg::query_modified()
{
return strcmp(m_story_file, fiction_file()) || strcmp(m_font_file, fiction_font()) || m_fiction_music != (Mission_music[SCORE_FICTION_VIEWER] + 1);
return strcmp(m_story_file, fiction_file()) || strcmp(m_font_file, fiction_font()) ||
strcmp(m_voice_file, fiction_voice()) || m_fiction_music != (Mission_music[SCORE_FICTION_VIEWER] + 1);
}
+1
View File
@@ -24,6 +24,7 @@ public:
enum { IDD = IDD_FICTION_VIEWER };
CString m_story_file;
CString m_font_file;
CString m_voice_file;
int m_fiction_music;
//}}AFX_DATA
+18 -15
View File
@@ -20,6 +20,7 @@
#include "cfile/cfile.h"
#include "sound/audiostr.h"
#include "localization/localize.h"
#include "mod_table/mod_table.h"
#ifdef _DEBUG
#undef THIS_FILE
@@ -222,21 +223,23 @@ BOOL event_editor::OnInitDialog()
}
}
// add new heads, if not already in
maybe_add_head(box, "Head-TP2");
maybe_add_head(box, "Head-VC2");
maybe_add_head(box, "Head-TP4");
maybe_add_head(box, "Head-TP5");
maybe_add_head(box, "Head-TP6");
maybe_add_head(box, "Head-TP7");
maybe_add_head(box, "Head-TP8");
maybe_add_head(box, "Head-VP2");
maybe_add_head(box, "Head-VP2");
maybe_add_head(box, "Head-CM2");
maybe_add_head(box, "Head-CM3");
maybe_add_head(box, "Head-CM4");
maybe_add_head(box, "Head-CM5");
maybe_add_head(box, "Head-BSH");
if (!Disable_hc_message_ani) {
maybe_add_head(box, "Head-TP2");
maybe_add_head(box, "Head-VC2");
maybe_add_head(box, "Head-TP4");
maybe_add_head(box, "Head-TP5");
maybe_add_head(box, "Head-TP6");
maybe_add_head(box, "Head-TP7");
maybe_add_head(box, "Head-TP8");
maybe_add_head(box, "Head-VP2");
maybe_add_head(box, "Head-VP2");
maybe_add_head(box, "Head-CM2");
maybe_add_head(box, "Head-CM3");
maybe_add_head(box, "Head-CM4");
maybe_add_head(box, "Head-CM5");
maybe_add_head(box, "Head-BSH");
}
/*
box->AddString("Head-VC"); // force it in, since Sandeep wants it and it's not used in built-in messages
+1 -1
View File
@@ -652,7 +652,7 @@ void CFREDApp::record_window_data(window_data *wndd, CWnd *wnd)
void CAboutDlg::OnBug()
{
char *path = "http://mgo.maxgaming.net/mantis/login_page.php";
char *path = "http://scp.indiegames.us/mantis/";
char buffer[MAX_PATH];
sprintf(buffer,"explorer.exe \"%s\"", path);
+14 -12
View File
@@ -171,7 +171,6 @@ BEGIN
POPUP "&Import"
BEGIN
MENUITEM "&FreeSpace 1 mission...", 33074
MENUITEM "&Weapon loadouts...", 33075
END
MENUITEM SEPARATOR
MENUITEM "&Run FreeSpace\tAlt+R", 32985
@@ -880,6 +879,7 @@ BEGIN
PUSHBUTTON "Sound Environment",IDC_SOUND_ENVIRONMENT_BUTTON,158,244,140,15
CONTROL "Always Show Mission Goals In Briefing",IDC_ALWAYS_SHOW_GOALS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,326,180,142,10
CONTROL "Mission End to Mainhall",IDC_END_TO_MAINHALL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,326,190,142,10
END
IDD_PREFERENCES DIALOG 0, 0, 333, 81
@@ -2034,14 +2034,14 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,333,24,50,14
END
IDD_RESTRICT_PATHS DIALOG 0, 0, 141, 87
IDD_RESTRICT_PATHS DIALOG 0, 0, 241, 87
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Restrict Paths"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK",IDOK,84,20,50,14
PUSHBUTTON "Cancel",IDCANCEL,84,37,50,14
LISTBOX IDC_PATH_LIST,7,20,71,58,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,184,20,50,14
PUSHBUTTON "Cancel",IDCANCEL,184,37,50,14
LISTBOX IDC_PATH_LIST,7,20,171,58,LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
LTEXT "Restrict departure paths to the following:",IDC_RESTRICT_PATHS_LABEL,7,7,127,11
END
@@ -2055,10 +2055,10 @@ BEGIN
COMBOBOX IDC_BACKGROUND,7,16,83,265,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
END
IDD_FICTION_VIEWER DIALOG 0, 0, 205, 66
IDD_FICTION_VIEWER DIALOGEX 0, 0, 205, 85
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Fiction Viewer Editor"
FONT 8, "MS Sans Serif"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,148,7,50,14
PUSHBUTTON "Cancel",IDCANCEL,148,24,50,14
@@ -2066,8 +2066,10 @@ BEGIN
EDITTEXT IDC_STORY_FILE,45,7,99,14,ES_AUTOHSCROLL
RTEXT "Font File",IDC_STATIC,7,27,32,8
EDITTEXT IDC_FONT_FILE,45,24,99,14,ES_AUTOHSCROLL
RTEXT "Music",IDC_STATIC,14,43,25,8
COMBOBOX IDC_FICTION_MUSIC,45,42,99,140,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
RTEXT "Music",IDC_STATIC,15,60,25,8
COMBOBOX IDC_FICTION_MUSIC,45,59,99,140,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Voice File",IDC_STATIC,9,43,32,8
EDITTEXT IDC_VOICE_FILE,45,40,99,14,ES_AUTOHSCROLL
END
IDD_SOUND_ENVIRONMENT DIALOGEX 0, 0, 315, 89
@@ -2100,8 +2102,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,7,1,0
PRODUCTVERSION 3,7,1,0
FILEVERSION 3,7,1,000000
PRODUCTVERSION 3,7,1,000000
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -2118,7 +2120,7 @@ BEGIN
BEGIN
VALUE "CompanyName", "Volition Inc."
VALUE "FileDescription", "Fred 2 Open"
VALUE "FileVersion", "3.7.1.0000"
VALUE "FileVersion", "3.7.1.000000"
VALUE "InternalName", "Fred 2 Open"
VALUE "LegalCopyright", "Copyright © 1998"
VALUE "OriginalFilename", "fred2.exe"
-84
View File
@@ -79,7 +79,6 @@ BEGIN_MESSAGE_MAP(CFREDDoc, CDocument)
ON_COMMAND(ID_EDIT_UNDO, OnEditUndo)
ON_COMMAND(ID_FILE_PREFERENCES, OnFilePreferences)
ON_COMMAND(ID_FILE_IMPORT_FSM, OnFileImportFSM)
ON_COMMAND(ID_FILE_IMPORT_WEAPONS, OnFileImportWeapons)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
@@ -1015,89 +1014,6 @@ void CFREDDoc::OnFileImportFSM()
recreate_dialogs();
}
void restore_default_weapons(char *ships_tbl);
void CFREDDoc::OnFileImportWeapons()
{
int rval;
CString ships_tbl_mfc;
char ships_tbl[MAX_PATH_LEN];
char *ships_tbl_text;
char *ships_tbl_text_raw;
char *ch;
char temp[MAX_PATH_LEN];
char error_str[1024];
// set up import dialog
CFileDialog dlg(TRUE, "tbl", NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR, "FreeSpace Tables (*.tbl)|*.tbl|All files (*.*)|*.*||");
dlg.m_ofn.lpstrTitle = "Specify the ships.tbl with the required loadouts";
// set initial path
strcpy_s(temp, Fred_exe_dir);
if ((ch = stristr(temp, "FreeSpace2")) != NULL)
{
strcpy(ch, "FreeSpace\\Data\\Tables");
dlg.m_ofn.lpstrInitialDir = temp;
}
// get ships.tbl
if (dlg.DoModal() != IDOK)
return;
ships_tbl_mfc = dlg.GetPathName();
if (strlen(ships_tbl_mfc) > MAX_PATH_LEN - 1)
{
MessageBox(NULL, "Path name is too long", "Error", MB_OK);
return;
}
if (!strlen(ships_tbl_mfc))
return;
strcpy_s(ships_tbl, ships_tbl_mfc);
// allocate junk
ships_tbl_text = (char *) malloc(sizeof(char) * MISSION_TEXT_SIZE);
ships_tbl_text_raw = (char *) malloc(sizeof(char) * MISSION_TEXT_SIZE);
if (!ships_tbl_text || !ships_tbl_text_raw)
{
free(ships_tbl_text);
free(ships_tbl_text_raw);
Error(LOCATION, "Not enough memory to import weapons.");
return;
}
// open localization
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0) {
mprintf(("FREDDOC: Unable to parse '%s'! Error code = %i.\n", ships_tbl, rval));
sprintf(error_str, "Could not parse file: %s", ships_tbl);
MessageBox(NULL, error_str, "Unable to import weapon loadouts!", MB_ICONERROR | MB_OK);
lcl_ext_close();
return;
}
// load the other table and convert, freeing memory after use
read_file_text(ships_tbl, CF_TYPE_ANY, ships_tbl_text, ships_tbl_text_raw);
free(ships_tbl_text_raw);
restore_default_weapons(ships_tbl_text);
free(ships_tbl_text);
// close localization
lcl_ext_close();
// we haven't saved it yet
set_modified(TRUE);
// error check and notify
if (!Fred_view_wnd->global_error_check())
Fred_view_wnd->MessageBox("Weapon loadouts successfully imported with no errors.", "Woohoo!");
}
void CFREDDoc::recreate_dialogs()
{
if(Briefing_dialog)
-1
View File
@@ -89,7 +89,6 @@ protected:
afx_msg void OnFileNew();
afx_msg void editor_init_mission();
afx_msg void OnFileImportFSM();
afx_msg void OnFileImportWeapons();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
+2 -1
View File
@@ -53,6 +53,7 @@
#include "graphics/font.h"
#include "cmdline/cmdline.h"
#include "iff_defs/iff_defs.h"
#include "mod_table/mod_table.h"
extern float flFrametime;
extern subsys_to_render Render_subsys;
@@ -141,7 +142,7 @@ color colour_yellow;
void fred_enable_htl()
{
if (!Briefing_dialog) gr_set_proj_matrix( (4.0f/9.0f) * PI * FRED_DEFAULT_HTL_FOV, gr_screen.aspect*(float)gr_screen.clip_width/(float)gr_screen.clip_height, 1.0f, FRED_DEAFULT_HTL_DRAW_DIST);
if (Briefing_dialog) gr_set_proj_matrix( (4.0f/9.0f) * PI * FRED_BRIEFING_HTL_FOV, gr_screen.aspect*(float)gr_screen.clip_width/(float)gr_screen.clip_height, 1.0f, FRED_DEAFULT_HTL_DRAW_DIST);
if (Briefing_dialog) gr_set_proj_matrix( Briefing_window_FOV, gr_screen.aspect*(float)gr_screen.clip_width/(float)gr_screen.clip_height, 1.0f, FRED_DEAFULT_HTL_DRAW_DIST);
gr_set_view_matrix(&Eye_position, &Eye_matrix);
}
+8 -4
View File
@@ -64,6 +64,7 @@
#include "iff_defs/iff_defs.h"
#include "menuui/techmenu.h"
#include "missionui/fictionviewer.h"
#include "mod_table/mod_table.h"
#include <direct.h>
#include "cmdline/cmdline.h"
@@ -308,6 +309,9 @@ bool fred_init()
exit(1);
}
// Load game_settings.tbl
mod_table_init();
// initialize localization module. Make sure this is done AFTER initialzing OS.
// NOTE : Fred should ALWAYS run in English. Otherwise it might swap in another language
// when saving - which would cause inconsistencies when externalizing to tstrings.tbl via Exstr
@@ -496,8 +500,8 @@ void fix_ship_name(int ship)
int create_ship(matrix *orient, vec3d *pos, int ship_type)
{
// Save the Current Working dir to restore in a minute - fred is being stupid
char pwd[128];
getcwd(pwd, 128); // get the present working dir - probably <fs2path>[/modpapth]/data/missions/
char pwd[MAX_PATH_LEN];
getcwd(pwd, MAX_PATH_LEN); // get the present working dir - probably <fs2path>[/modpapth]/data/missions/
int obj, z1, z2;
@@ -927,8 +931,8 @@ void clear_mission()
event_music_reset_choices();
clear_texture_replacements();
// alternate ship type names
mission_parse_reset_alt();
mission_parse_reset_alt(); // alternate ship type names
mission_parse_reset_callsign();
strcpy(Cargo_names[0], "Nothing");
Num_cargo = 1;
+8
View File
@@ -73,6 +73,7 @@ CMissionNotesDlg::CMissionNotesDlg(CWnd* pParent /*=NULL*/) : CDialog(CMissionNo
m_no_autpilot = FALSE;
m_2d_mission = FALSE;
m_always_show_goals = FALSE;
m_end_to_mainhall = FALSE;
m_max_hull_repair_val = 0.0f;
m_max_subsys_repair_val = 100.0f;
m_contrail_threshold = CONTRAIL_THRESHOLD_DEFAULT;
@@ -124,6 +125,7 @@ void CMissionNotesDlg::DoDataExchange(CDataExchange* pDX)
DDX_Check(pDX, IDC_2D_MISSION, m_2d_mission);
DDX_Check(pDX, IDC_DEACTIVATE_AUTOPILOT, m_no_autpilot);
DDX_Check(pDX, IDC_ALWAYS_SHOW_GOALS, m_always_show_goals);
DDX_Check(pDX, IDC_END_TO_MAINHALL, m_end_to_mainhall);
DDX_Text(pDX, IDC_MAX_HULL_REPAIR_VAL, m_max_hull_repair_val);
DDV_MinMaxFloat(pDX, m_max_hull_repair_val, 0, 100);
DDX_Text(pDX, IDC_MAX_SUBSYS_REPAIR_VAL, m_max_subsys_repair_val);
@@ -356,6 +358,12 @@ void CMissionNotesDlg::OnOK()
The_mission.flags &= ~MISSION_FLAG_ALWAYS_SHOW_GOALS;
}
if ( m_end_to_mainhall ) {
The_mission.flags |= MISSION_FLAG_END_TO_MAINHALL;
} else {
The_mission.flags &= ~MISSION_FLAG_END_TO_MAINHALL;
}
if ( flags != The_mission.flags ){
set_modified();
}
+1
View File
@@ -64,6 +64,7 @@ public:
BOOL m_no_autpilot;
BOOL m_2d_mission;
BOOL m_always_show_goals;
BOOL m_end_to_mainhall;
float m_max_hull_repair_val;
float m_max_subsys_repair_val;
BOOL m_contrail_threshold_flag;
+14 -2
View File
@@ -133,10 +133,10 @@ int CFred_mission_save::save_mission_file(char *pathname)
err = -3;
// else if (save_briefing_info())
// err = -4;
else if (save_fiction())
err = -3;
else if (save_cutscenes())
err = -4;
else if (save_fiction())
err = -3;
else if (save_cmd_briefs())
err = -4;
else if (save_briefing())
@@ -795,6 +795,18 @@ int CFred_mission_save::save_fiction()
}
else
optional_string_fred("$Font:");
// save voice
if (strlen(fiction_voice()) > 0) //-V805
{
if (optional_string_fred("$Voice:"))
parse_comments();
else
fout("\n$Voice:");
fout(" %s", fiction_voice());
}
else
optional_string_fred("$Voice:");
}
else
{
+4 -1
View File
@@ -1060,6 +1060,8 @@
#define IDC_2D_MISSION2 1549
#define IDC_ALWAYS_SHOW_GOALS 1549
#define IDC_LABEL2 1550
#define IDC_ALWAYS_SHOW_GOALS2 1550
#define IDC_END_TO_MAINHALL 1550
#define IDC_NEW_TEXTURE 1551
#define IDC_TEXTURES 1552
#define IDC_OLD_TEXTURE_LIST 1553
@@ -1152,6 +1154,8 @@
#define IDC_FONT_FILE 1619
#define IDC_FICTION_MUSIC 1620
#define IDC_SOUND_ENVIRONMENT_LABEL 1621
#define IDC_FONT_FILE2 1621
#define IDC_VOICE_FILE 1621
#define IDC_SOUND_ENVIRONMENT_VOLUME_LABEL 1622
#define IDC_SOUND_ENVIRONENT_DAMPING_LABEL 1623
#define IDC_SOUND_ENVIRONMENT_DECAY_LABEL 1624
@@ -1439,7 +1443,6 @@
#define ID_FORMAT_FS1_RETAIL 33072
#define ID_EDITORS_SET_GLOBAL_SHIP_FLAGS 33073
#define ID_FILE_IMPORT_FSM 33074
#define ID_FILE_IMPORT_WEAPONS 33075
#define ID_VIEW_LIGHTING 33079
#define ID_EDITORS_VOICE 33080
#define ID_SHOW_IFF_0 33081
+18 -1
View File
@@ -2203,7 +2203,8 @@ int sexp_tree::add_default_operator(int op, int argnum)
(argnum == 1 && Operators[op].value == OP_INT_TO_STRING) ||
(argnum == 3 && Operators[op].value == OP_STRING_GET_SUBSTRING) ||
(argnum == 4 && Operators[op].value == OP_STRING_SET_SUBSTRING) ||
(argnum == 1 && Operators[op].value == OP_COPY_VARIABLE_FROM_INDEX))
(argnum == 1 && Operators[op].value == OP_COPY_VARIABLE_FROM_INDEX) ||
(argnum == 1 && Operators[op].value == OP_SCRIPT_EVAL_STRING))
{
int sexp_var_index = get_index_sexp_variable_name(item.text);
@@ -2634,6 +2635,7 @@ int sexp_tree::query_default_argument_available(int op, int i)
case OPF_FLEXIBLE_ARGUMENT:
case OPF_ANYTHING:
case OPF_SKYBOX_MODEL_NAME:
case OPF_SKYBOX_FLAGS:
case OPF_SHIP_OR_NONE:
case OPF_SUBSYSTEM_OR_NONE:
case OPF_SHIP_WING_POINT_OR_NONE:
@@ -4347,6 +4349,10 @@ sexp_list_item *sexp_tree::get_listing_opf(int opf, int parent_node, int arg_ind
list = get_listing_opf_skybox_model();
break;
case OPF_SKYBOX_FLAGS:
list = get_listing_opf_skybox_flags();
break;
case OPF_BACKGROUND_BITMAP:
list = get_listing_opf_background_bitmap();
break;
@@ -5791,6 +5797,17 @@ sexp_list_item *sexp_tree::get_listing_opf_skybox_model()
return head.next;
}
sexp_list_item *sexp_tree::get_listing_opf_skybox_flags()
{
sexp_list_item head;
int i;
for (i = 0; i < Num_skybox_flags; ++i) {
head.add_data(Skybox_flags[i]);
}
return head.next;
}
sexp_list_item *sexp_tree::get_listing_opf_background_bitmap()
{
sexp_list_item head;
+1
View File
@@ -236,6 +236,7 @@ public:
sexp_list_item *get_listing_opf_variable_names();
sexp_list_item *get_listing_opf_variable_type();
sexp_list_item *get_listing_opf_skybox_model();
sexp_list_item *get_listing_opf_skybox_flags();
sexp_list_item *get_listing_opf_background_bitmap();
sexp_list_item *get_listing_opf_sun_bitmap();
sexp_list_item *get_listing_opf_nebula_storm_type();
+16 -24
View File
@@ -2037,7 +2037,7 @@ void CShipEditorDlg::OnSpecialExp()
// alternate ship name stuff
void CShipEditorDlg::ship_alt_name_init(int base_ship)
{
int idx;
int idx, sel_idx;
CComboBox *ptr = (CComboBox*)GetDlgItem(IDC_SHIP_ALT);
if(ptr == NULL){
Int3();
@@ -2054,21 +2054,17 @@ void CShipEditorDlg::ship_alt_name_init(int base_ship)
// reset the combobox and add all relevant strings
ptr->ResetContent();
ptr->AddString("<none>");
sel_idx = (base_ship < 0 || !strlen(Fred_alt_names[base_ship])) ? -1 : -2;
for(idx=0; idx<Mission_alt_type_count; idx++){
ptr->AddString(Mission_alt_types[idx]);
if (sel_idx == -2 && !strcmp(Mission_alt_types[idx], Fred_alt_names[base_ship])) {
sel_idx = idx;
}
}
Assertion(sel_idx >= -1, "Alt name exists but can't be found in Mission_alt_types; get a coder!\n");
// "none"
if(base_ship < 0){
ptr->SetCurSel(0);
}
// otherwise look his stuff up
if(strlen(Fred_alt_names[base_ship])){
ptr->SelectString(0, Fred_alt_names[base_ship]);
} else {
ptr->SetCurSel(0);
}
sel_idx += 1;
ptr->SetCurSel(sel_idx);
}
void CShipEditorDlg::ship_alt_name_close(int base_ship)
@@ -2137,7 +2133,7 @@ void CShipEditorDlg::ship_alt_name_close(int base_ship)
// callsign stuff
void CShipEditorDlg::ship_callsign_init(int base_ship)
{
int idx;
int idx, sel_idx;
CComboBox *ptr = (CComboBox*)GetDlgItem(IDC_SHIP_CALLSIGN);
if(ptr == NULL){
Int3();
@@ -2154,21 +2150,17 @@ void CShipEditorDlg::ship_callsign_init(int base_ship)
// reset the combobox and add all relevant strings
ptr->ResetContent();
ptr->AddString("<none>");
sel_idx = (base_ship < 0 || !strlen(Fred_callsigns[base_ship])) ? -1 : -2;
for(idx=0; idx<Mission_callsign_count; idx++){
ptr->AddString(Mission_callsigns[idx]);
if (sel_idx == -2 && !strcmp(Mission_callsigns[idx], Fred_callsigns[base_ship])) {
sel_idx = idx;
}
}
Assertion(sel_idx >= -1, "Callsign exists but can't be found in Mission_callsigns; get a coder!\n");
// "none"
if(base_ship < 0){
ptr->SetCurSel(0);
}
// otherwise look his stuff up
if(strlen(Fred_callsigns[base_ship])){
ptr->SelectString(0, Fred_callsigns[base_ship]);
} else {
ptr->SetCurSel(0);
}
sel_idx += 1;
ptr->SetCurSel(sel_idx);
}
void CShipEditorDlg::ship_callsign_close(int base_ship)
+3 -1
View File
@@ -132,7 +132,9 @@ void CShipTexturesDlg::OnOK()
texture_set(&(*ii), &(*end));
}
}
Fred_texture_replacements.erase(end);
if (end != Fred_texture_replacements.end())
Fred_texture_replacements.erase(end);
// now put the new entries on the end of the list
for (i=0; i<texture_count; i++)
+359 -271
View File
@@ -33,6 +33,7 @@
#include "cutscene/cutscenes.h"
#include "cutscene/movie.h"
#include "debris/debris.h"
#include "debugconsole/console.h"
#include "exceptionhandler/exceptionhandler.h"
#include "external_dll/trackirpublic.h" // header file for the TrackIR routines (Swifty)
#include "fireball/fireballs.h"
@@ -192,7 +193,7 @@ extern int Om_tracker_flag; // needed for FS2OpenPXO config
// This function is defined in code\network\multiutil.cpp so will be linked from multiutil.obj
// it's required fro the -missioncrcs command line option - Kazan
void multi_spew_pxo_checksums(int max_files, char *outfile);
void multi_spew_pxo_checksums(int max_files, const char *outfile);
void fs2netd_spew_table_checksums(char *outfile);
extern bool frame_rate_display;
@@ -664,10 +665,9 @@ void big_explosion_flash(float flash)
int Sun_drew = 0;
float sn_glare_scale = 1.7f;
DCF(sn_glare, "")
DCF(sn_glare, "Sets the sun glare scale (Default is 1.7)")
{
dc_get_arg(ARG_FLOAT);
sn_glare_scale = Dc_arg_float;
dc_stuff_float(&sn_glare_scale);
}
float Supernova_last_glare = 0.0f;
@@ -1177,7 +1177,7 @@ void game_loading_callback(int count)
if (Processing_filename[0] != '\0') {
gr_set_shader(&busy_shader);
gr_shade(0, 0, gr_screen.clip_width_unscaled, 17, GR_RESIZE_MENU); // make sure it goes across the entire width
gr_shade(0, 0, gr_screen.max_w_unscaled, 17, GR_RESIZE_MENU); // make sure it goes across the entire width
gr_set_color_fast(&Color_white);
gr_string(5, 5, Processing_filename, GR_RESIZE_MENU);
@@ -1499,80 +1499,101 @@ DCF_BOOL(i_framerate, Interface_framerate )
DCF(warp, "Tests warpin effect")
{
if ( Dc_command ) {
bool warpin = true;
int idx = -1;
if (dc_optional_string_either("help", "--help")) {
dc_printf( "Params: bool warpin, string Target = ""\n Warps in if true, out if false. Player is target unless specific ship is specified\n" );
return;
} // Else, process command
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);
if( Dc_arg_type & ARG_TRUE) warpin = true;
else if(Dc_arg_type & ARG_FALSE) warpin = false;
// TODO: Provide status flag
if(!(Dc_arg_type & ARG_NONE))
{
dc_get_arg(ARG_STRING|ARG_NONE);
if(Dc_arg_type & ARG_STRING)
{
idx = ship_name_lookup(Dc_arg);
if(idx > -1)
{
if(warpin)
shipfx_warpin_start(&Objects[Ships[idx].objnum]);
else
shipfx_warpout_start(&Objects[Ships[idx].objnum]);
}
bool warpin;
char target[MAX_NAME_LEN];
int idx = -1;
dc_stuff_boolean(&warpin);
if (dc_maybe_stuff_string_white(target, MAX_NAME_LEN)) {
idx = ship_name_lookup(target);
} // Else, default target to player
if (idx < 0) {
// Player is target
if (Player_ai->target_objnum > -1) {
if(warpin) {
shipfx_warpin_start(&Objects[Player_ai->target_objnum]);
} else {
shipfx_warpout_start(&Objects[Player_ai->target_objnum]);
}
}
if(idx < 0)
{
if(Player_ai->target_objnum > -1)
{
if(warpin)
shipfx_warpin_start(&Objects[Player_ai->target_objnum]);
else
shipfx_warpout_start(&Objects[Player_ai->target_objnum]);
}
} else {
// Non-player is targer
if (warpin) {
shipfx_warpin_start(&Objects[Ships[idx].objnum]);
} else {
shipfx_warpout_start(&Objects[Ships[idx].objnum]);
}
}
if ( Dc_help ) dc_printf( "Usage: Show_mem\nWarps in if true, out if false, player target unless specific ship is specified\n" );
}
}
DCF(show_mem,"Toggles showing mem usage")
{
if ( Dc_command ) {
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);
if ( Dc_arg_type & ARG_TRUE ) Show_mem = 1;
else if ( Dc_arg_type & ARG_FALSE ) Show_mem = 0;
else if ( Dc_arg_type & ARG_NONE ) Show_mem ^= 1;
bool process = true;
if ( Show_mem ) {
Show_cpu = 0;
}
}
if ( Dc_help ) dc_printf( "Usage: Show_mem\nSets show_mem to true or false. If nothing passed, then toggles it.\n" );
if ( Dc_status ) {
dc_printf( "Show_mem is %s\n", (Show_mem?"TRUE":"FALSE") );
dc_printf( "Show_cpu is %s\n", (Show_cpu?"TRUE":"FALSE") );
if (dc_optional_string_either("help", "--help")) {
dc_printf( "Usage: (optional) bool Show_mem\n If true, Show_mem is set and Show_cpu is cleared. If false, then Show_mem is cleared. If nothing passed, then toggle.\n" );
process = false;
}
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf("Show_mem is %s\n", (Show_mem ? "TRUE" : "FALSE"));
dc_printf("Show_cpu is %s\n", (Show_cpu ? "TRUE" : "FALSE"));
process = false;
}
if (!process) {
// Help and/or status was given, so don't process the command
return;
} // Else, process the command
if (!dc_maybe_stuff_boolean(&Show_mem)) {
// Nothing passed, so toggle
Show_mem = !Show_mem;
} // Else, value was set/cleared by user
// Can't show mem and cpu at same time
if (Show_mem) {
Show_cpu = false;
}
}
DCF(show_cpu,"Toggles showing cpu usage")
{
if ( Dc_command ) {
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);
if ( Dc_arg_type & ARG_TRUE ) Show_cpu = 1;
else if ( Dc_arg_type & ARG_FALSE ) Show_cpu = 0;
else if ( Dc_arg_type & ARG_NONE ) Show_cpu ^= 1;
bool process = true;
if ( Show_cpu ) {
Show_mem = 0;
}
}
if ( Dc_help ) dc_printf( "Usage: Show_cpu\nSets show_cpu to true or false. If nothing passed, then toggles it.\n" );
if ( Dc_status ) {
dc_printf( "Show_mem is %s\n", (Show_mem?"TRUE":"FALSE") );
dc_printf( "Show_cpu is %s\n", (Show_cpu?"TRUE":"FALSE") );
if (dc_optional_string_either("help", "--help")) {
dc_printf( "Usage: (optional) bool Show_cpu\n If true, Show_cpu is set and Show_mem is cleared. If false, then Show_cpu is cleared. If nothing passed, then toggle.\n" );
process = false;
}
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf("Show_cpu is %s\n", (Show_cpu ? "TRUE" : "FALSE"));
dc_printf("Show_mem is %s\n", (Show_mem ? "TRUE" : "FALSE"));
process = false;
}
if (!process) {
// Help and/or status was given, so don't process the command
return;
} // Else, process the command
if (!dc_maybe_stuff_boolean(&Show_cpu)) {
// Nothing passed, so toggle
Show_cpu = !Show_cpu;
} // Else, value was set/cleared by user
// Can't show mem and cpu at same time
if (Show_cpu) {
Show_mem = false;
}
}
@@ -1582,42 +1603,56 @@ DCF(show_cpu,"Toggles showing cpu usage")
DCF(use_joy_mouse,"Makes joystick move mouse cursor")
{
if ( Dc_command ) {
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);
if ( Dc_arg_type & ARG_TRUE ) Use_joy_mouse = 1;
else if ( Dc_arg_type & ARG_FALSE ) Use_joy_mouse = 0;
else if ( Dc_arg_type & ARG_NONE ) Use_joy_mouse ^= 1;
}
if ( Dc_help ) dc_printf( "Usage: use_joy_mouse [bool]\nSets use_joy_mouse to true or false. If nothing passed, then toggles it.\n" );
if ( Dc_status ) dc_printf( "use_joy_mouse is %s\n", (Use_joy_mouse?"TRUE":"FALSE") );
bool process = true;
if (dc_optional_string_either("help", "--help")) {
dc_printf("Usage: use_joy_mouse [bool]\nSets use_joy_mouse to true or false. If nothing passed, then toggles it.\n");
process = false;
}
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf("use_joy_mouse is %s\n", (Use_joy_mouse ? "TRUE" : "FALSE"));
process = false;
}
if (!process) {
return;
}
if(!dc_maybe_stuff_boolean(&Use_joy_mouse)) {
// Nothing passed, so toggle
Use_joy_mouse = !Use_joy_mouse;
} // Else, value was set/cleared by user
os_config_write_uint( NULL, NOX("JoystickMovesCursor"), Use_joy_mouse );
}
DCF(palette_flash,"Toggles palette flash effect on/off")
{
if ( Dc_command ) {
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);
if ( Dc_arg_type & ARG_TRUE ) Use_palette_flash = 1;
else if ( Dc_arg_type & ARG_FALSE ) Use_palette_flash = 0;
else if ( Dc_arg_type & ARG_NONE ) Use_palette_flash ^= 1;
}
if ( Dc_help ) dc_printf( "Usage: palette_flash [bool]\nSets palette_flash to true or false. If nothing passed, then toggles it.\n" );
if ( Dc_status ) dc_printf( "palette_flash is %s\n", (Use_palette_flash?"TRUE":"FALSE") );
}
DCF_BOOL(palette_flash, Use_palette_flash);
int Use_low_mem = 0;
DCF(low_mem,"Uses low memory settings regardless of RAM")
{
if ( Dc_command ) {
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);
if ( Dc_arg_type & ARG_TRUE ) Use_low_mem = 1;
else if ( Dc_arg_type & ARG_FALSE ) Use_low_mem = 0;
else if ( Dc_arg_type & ARG_NONE ) Use_low_mem ^= 1;
}
if ( Dc_help ) dc_printf( "Usage: low_mem [bool]\nSets low_mem to true or false. If nothing passed, then toggles it.\n" );
if ( Dc_status ) dc_printf( "low_mem is %s\n", (Use_low_mem?"TRUE":"FALSE") );
bool process = true;
if (dc_optional_string_either("help", "--help")) {
dc_printf("Usage: low_mem [bool]\nSets low_mem to true or false. If nothing passed, then toggles it.\n");
process = false;
}
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf("low_mem is %s\n", (Use_low_mem ? "TRUE" : "FALSE"));
process = false;
}
if (!process) {
return;
}
if (!dc_maybe_stuff_boolean(&Use_low_mem)) {
// Nothing passed, so toggle
Use_low_mem = !Use_low_mem;
} // Else, value was set/cleared by user
os_config_write_uint( NULL, NOX("LowMem"), Use_low_mem );
}
@@ -1627,14 +1662,26 @@ DCF(low_mem,"Uses low memory settings regardless of RAM")
DCF(force_fullscreen, "Forces game to startup in fullscreen mode")
{
if ( Dc_command ) {
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);
if ( Dc_arg_type & ARG_TRUE ) Use_fullscreen_at_startup = 1;
else if ( Dc_arg_type & ARG_FALSE ) Use_fullscreen_at_startup = 0;
else if ( Dc_arg_type & ARG_NONE ) Use_fullscreen_at_startup ^= 1;
}
if ( Dc_help ) dc_printf( "Usage: force_fullscreen [bool]\nSets force_fullscreen to true or false. If nothing passed, then toggles it.\n" );
if ( Dc_status ) dc_printf( "force_fullscreen is %s\n", (Use_fullscreen_at_startup?"TRUE":"FALSE") );
bool process = true;
if (dc_optional_string_either("help", "--help")) {
dc_printf("Usage: low_mem [bool]\nSets low_mem to true or false. If nothing passed, then toggles it.\n");
process = false;
}
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf("low_mem is %s\n", (Use_fullscreen_at_startup ? "TRUE" : "FALSE"));
process = false;
}
if (!process) {
return;
}
if (dc_maybe_stuff_boolean(&Use_fullscreen_at_startup)) {
// Nothing passed, so toggle
Use_fullscreen_at_startup = !Use_fullscreen_at_startup;
} // Else, value was set/cleared by user
os_config_write_uint( NULL, NOX("ForceFullscreen"), Use_fullscreen_at_startup );
}
#endif
@@ -1643,37 +1690,33 @@ int Framerate_delay = 0;
float FreeSpace_gamma = 1.0f;
DCF(gamma,"Sets Gamma factor")
DCF(gamma,"Sets and saves Gamma Factor")
{
if ( Dc_command ) {
dc_get_arg(ARG_FLOAT|ARG_NONE);
if ( Dc_arg_type & ARG_FLOAT ) {
FreeSpace_gamma = Dc_arg_float;
} else {
dc_printf( "Gamma reset to 1.0f\n" );
FreeSpace_gamma = 1.0f;
}
if ( FreeSpace_gamma < 0.1f ) {
FreeSpace_gamma = 0.1f;
} else if ( FreeSpace_gamma > 5.0f ) {
FreeSpace_gamma = 5.0f;
}
gr_set_gamma(FreeSpace_gamma);
char tmp_gamma_string[32];
sprintf( tmp_gamma_string, NOX("%.2f"), FreeSpace_gamma );
os_config_write_string( NULL, NOX("Gamma"), tmp_gamma_string );
}
if ( Dc_help ) {
if (dc_optional_string_either("help", "--help")) {
dc_printf( "Usage: gamma <float>\n" );
dc_printf( "Sets gamma in range 1-3, no argument resets to default 1.2\n" );
Dc_status = 0; // don't print status if help is printed. Too messy.
return;
}
if ( Dc_status ) {
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf( "Gamma = %.2f\n", FreeSpace_gamma );
return;
}
if (!dc_maybe_stuff_float(&FreeSpace_gamma)) {
dc_printf( "Gamma reset to 1.0f\n" );
FreeSpace_gamma = 1.0f;
}
if ( FreeSpace_gamma < 0.1f ) {
FreeSpace_gamma = 0.1f;
} else if ( FreeSpace_gamma > 5.0f ) {
FreeSpace_gamma = 5.0f;
}
gr_set_gamma(FreeSpace_gamma);
char tmp_gamma_string[32];
sprintf( tmp_gamma_string, NOX("%.2f"), FreeSpace_gamma );
os_config_write_string( NULL, NOX("Gamma"), tmp_gamma_string );
}
#ifdef APPLE_APP
@@ -2409,33 +2452,54 @@ void game_show_time_left()
DCF(ai_pause,"Pauses ai")
{
if ( Dc_command ) {
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);
if ( Dc_arg_type & ARG_TRUE ) ai_paused = 1;
else if ( Dc_arg_type & ARG_FALSE ) ai_paused = 0;
else if ( Dc_arg_type & ARG_NONE ) ai_paused = !ai_paused;
bool process = true;
if (dc_optional_string_either("help", "--help")) {
dc_printf( "Usage: ai_paused [bool]\nSets ai_paused to true or false. If nothing passed, then toggles it.\n" );
process = false;
}
if (ai_paused) {
obj_init_all_ships_physics();
}
}
if ( Dc_help ) dc_printf( "Usage: ai_paused [bool]\nSets ai_paused to true or false. If nothing passed, then toggles it.\n" );
if ( Dc_status ) dc_printf( "ai_paused is %s\n", (ai_paused?"TRUE":"FALSE") );
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf( "ai_paused is %s\n", (ai_paused?"TRUE":"FALSE") );
process = false;
}
if (!process) {
return;
}
if (!dc_maybe_stuff_boolean(&ai_paused)) {
ai_paused = !ai_paused;
}
if (ai_paused) {
obj_init_all_ships_physics();
}
}
DCF(single_step,"Single steps the game")
DCF(single_step,"Enables single step mode.")
{
if ( Dc_command ) {
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);
if ( Dc_arg_type & ARG_TRUE ) game_single_step = 1;
else if ( Dc_arg_type & ARG_FALSE ) game_single_step = 0;
else if ( Dc_arg_type & ARG_NONE ) game_single_step = !game_single_step;
bool process = true;
if (dc_optional_string_either("help", "--help")) {
dc_printf( "Usage: game_single_step [bool]\nEnables or disables single-step mode. If nothing passed, then toggles it.\nSingle-step mode will freeze the game, and will advance frame by frame with each key press\n");
process = false;
}
last_single_step = 0; // Make so single step waits a frame before stepping
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf( "ai_paused is %s\n", (game_single_step ? "TRUE" : "FALSE") );
process = false;
}
}
if ( Dc_help ) dc_printf( "Usage: single_step [bool]\nSets single_step to true or false. If nothing passed, then toggles it.\n" );
if ( Dc_status ) dc_printf( "single_step is %s\n", (game_single_step?"TRUE":"FALSE") );
if (!process) {
return;
}
if (!dc_maybe_stuff_boolean(&game_single_step)) {
game_single_step = !game_single_step;
}
last_single_step = 0; // Make so single step waits a frame before stepping
}
DCF_BOOL(physics_pause, physics_paused)
@@ -2482,22 +2546,28 @@ int View_percent = 100;
DCF(view, "Sets the percent of the 3d view to render.")
{
if ( Dc_command ) {
dc_get_arg(ARG_INT);
if ( (Dc_arg_int >= 5 ) || (Dc_arg_int <= 100) ) {
View_percent = Dc_arg_int;
} else {
dc_printf( "Illegal value for view. (Must be from 5-100) \n\n");
Dc_help = 1;
}
bool process = true;
int value;
if (dc_optional_string_either("help", "--help")) {
dc_printf("Usage: view [n]\nwhere n is percent of view to show (5-100).\n");
process = false;
}
if ( Dc_help ) {
dc_printf("Usage: view [n]\nwhere n is percent of view to show (5-100).\n");
}
if ( Dc_status ) {
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf("View is set to %d%%\n", View_percent );
process = false;
}
if (!process) {
return;
}
dc_stuff_int(&value);
if ( (value >= 5 ) && (value <= 100) ) {
View_percent = value;
} else {
dc_printf("Error: Outside legal range [5 - 100]");
}
}
@@ -2824,65 +2894,86 @@ void do_timing_test(float frame_time)
DCF(dcf_fov, "Change the field of view of the main camera")
{
camera *cam = Main_camera.getCamera();
if ( Dc_command )
{
if(cam == NULL)
return;
bool process = true;
float value;
dc_get_arg(ARG_FLOAT|ARG_NONE);
if ( Dc_arg_type & ARG_NONE ) {
cam->set_fov(VIEWER_ZOOM_DEFAULT);
dc_printf( "Zoom factor reset\n" );
}
if ( Dc_arg_type & ARG_FLOAT ) {
if (Dc_arg_float < 0.25f) {
cam->set_fov(0.25f);
dc_printf("Zoom factor pinned at 0.25.\n");
} else if (Dc_arg_float > 1.25f) {
cam->set_fov(1.25f);
dc_printf("Zoom factor pinned at 1.25.\n");
} else {
cam->set_fov(Dc_arg_float);
}
}
if (dc_optional_string_either("help", "--help")) {
dc_printf( "Usage: fov [factor]\nFactor is the zoom factor btwn .25 and 1.25\nNo parameter resets it to default.\n" );
process = false;
}
if ( Dc_help )
dc_printf( "Usage: fov [factor]\nFactor is the zoom factor btwn .25 and 1.25\nNo parameter resets it to default.\n" );
if ( Dc_status )
{
if(cam == NULL)
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
if(cam == NULL) {
dc_printf("Camera unavailable.");
else
dc_printf("Zoom factor set to %6.3f (original = 0.5, John = 0.75)", cam->get_fov());
} else {
dc_printf("Zoom factor set to %6.3f (original = 0.5, John = 0.75)\n", cam->get_fov());
}
process = false;
}
if ((cam == NULL) || (!process)) {
return;
}
if (!dc_maybe_stuff_float(&value)) {
// No value passed, use default
cam->set_fov(VIEWER_ZOOM_DEFAULT);
} else {
// Value passed, Clamp it to valid values
if (value < 0.25f) {
value = 0.25f;
dc_printf("Zoom factor clamped to 0.25\n");
} else if (value > 1.25f) {
value = 1.25f;
dc_printf("Zoom factor clamped to 1.25\n");
} else {
dc_printf("Zoom factor set to %6.3f\n", value);
}
cam->set_fov(value);
}
}
DCF(framerate_cap, "Sets the framerate cap")
{
if ( Dc_command ) {
dc_get_arg(ARG_INT);
if ( (Dc_arg_int >= 1 ) || (Dc_arg_int <= 120) ) {
Framerate_cap = Dc_arg_int;
} else {
dc_printf( "Illegal value for framerate cap. (Must be from 1-120) \n\n");
Dc_help = 1;
}
}
bool process = true;
if ( Dc_help ) {
if (dc_optional_string_either("help", "--help")) {
dc_printf("Usage: framerate_cap [n]\nwhere n is the frames per second to cap framerate at.\n");
dc_printf("If n is 0 or omitted, then the framerate cap is removed\n");
dc_printf("[n] must be from 1 to 120.\n");
process = false;
}
if ( Dc_status ) {
if ( Framerate_cap )
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
if ( Framerate_cap ) {
dc_printf("Framerate cap is set to %d fps\n", Framerate_cap );
else
} else {
dc_printf("There is no framerate cap currently active.\n");
}
process = false;
}
if (!process) {
return;
}
if (!dc_maybe_stuff_int(&Framerate_cap)) {
Framerate_cap = 0;
}
if ((Framerate_cap < 0) || (Framerate_cap > 120)) {
dc_printf( "Illegal value for framerate cap. (Must be from 1-120) \n");
Framerate_cap = 0;
}
if (Framerate_cap == 0) {
dc_printf("Framerate cap disabled");
} else {
dc_printf("Framerate cap is set to %d fps\n", Framerate_cap );
}
}
@@ -3784,87 +3875,71 @@ void john_debug_stuff(vec3d *eye_pos, matrix *eye_orient)
#ifndef NDEBUG
// function to toggle state of dumping every frame into PCX when playing the game
DCF(dump_frames, "Starts/stop frame dumping at 15 hz")
DCF(dump_frames, "Toggles On/off frame dumping at 15 hz")
{
if ( Dc_command ) {
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 15;
Debug_dump_trigger = 0;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Frame dumping at 15 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Frame dumping is now OFF\n" );
}
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 15;
Debug_dump_trigger = 0;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Frame dumping at 15 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Frame dumping is now OFF\n" );
}
}
DCF(dump_frames_trigger, "Starts/stop frame dumping at 15 hz")
{
if ( Dc_command ) {
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 15;
Debug_dump_trigger = 1;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Frame dumping at 15 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Frame dumping is now OFF\n" );
}
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 15;
Debug_dump_trigger = 1;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Frame dumping at 15 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Frame dumping is now OFF\n" );
}
}
DCF(dump_frames30, "Starts/stop frame dumping at 30 hz")
{
if ( Dc_command ) {
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 30;
Debug_dump_trigger = 0;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Frame dumping at 30 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Frame dumping is now OFF\n" );
}
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 30;
Debug_dump_trigger = 0;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Frame dumping at 30 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Frame dumping is now OFF\n" );
}
}
DCF(dump_frames30_trigger, "Starts/stop frame dumping at 30 hz")
{
if ( Dc_command ) {
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 30;
Debug_dump_trigger = 1;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Triggered frame dumping at 30 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Triggered frame dumping is now OFF\n" );
}
if ( Debug_dump_frames == 0 ) {
// Turn it on
Debug_dump_frames = 30;
Debug_dump_trigger = 1;
gr_dump_frame_start( Debug_dump_frame_num, DUMP_BUFFER_NUM_FRAMES );
dc_printf( "Triggered frame dumping at 30 hz is now ON\n" );
} else {
// Turn it off
Debug_dump_frames = 0;
Debug_dump_trigger = 0;
gr_dump_frame_stop();
dc_printf( "Triggered frame dumping is now OFF\n" );
}
}
@@ -4463,7 +4538,7 @@ void game_frame(bool paused)
}
Script_system.SetHookObject("Self", Viewer_obj);
if (!hud_disabled_except_messages() && !(Viewer_mode & (VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY)))
if (!(Viewer_mode & (VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY)))
{
Script_system.RunBytecode(Script_hudhook);
Script_system.RunCondition(CHA_HUDDRAW, '\0', NULL, Viewer_obj);
@@ -6930,7 +7005,7 @@ void game_spew_pof_info()
BAIL();
}
DCF(pofspew, "")
DCF(pofspew, "Spews POF info without shutting down the game")
{
game_spew_pof_info();
}
@@ -8007,7 +8082,7 @@ int game_do_cd_check(char *volume_name)
break;
} else {
// no CD found, so prompt user
popup_rval = popup(PF_BODY_BIG, 1, POPUP_OK, XSTR( "FreeSpace 2 CD not found\n\nInsert a FreeSpace 2 CD to continue", 202));
popup_rval = popup(PF_BODY_BIG | PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR( "FreeSpace 2 CD not found\n\nInsert a FreeSpace 2 CD to continue", 202));
refresh_files = 1;
if ( popup_rval != 1 ) {
cd_present = 0;
@@ -8054,7 +8129,7 @@ int game_do_cd_check_specific(char *volume_name, int cdnum)
break;
} else {
// no CD found, so prompt user
popup_rval = popup(PF_BODY_BIG, 1, POPUP_OK, XSTR("Please insert CD %d", 1468), cdnum);
popup_rval = popup(PF_BODY_BIG | PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR("Please insert CD %d", 1468), cdnum);
refresh_files = 1;
if ( popup_rval != 1 ) {
cd_present = 0;
@@ -8361,16 +8436,21 @@ void game_title_screen_display()
int width, height;
bm_get_info(Game_title_bitmap, &width, &height);
// set the screen scale to the bitmap's dimensions
gr_set_screen_scale(width, height);
// draw it in the center of the screen
gr_bitmap((gr_screen.max_w_unscaled - width)/2, (gr_screen.max_h_unscaled - height)/2, GR_RESIZE_MENU);
}
if (Game_title_logo != -1)
{
gr_set_bitmap(Game_title_logo);
if (Game_title_logo != -1)
{
gr_set_bitmap(Game_title_logo);
gr_bitmap(0, 0, GR_RESIZE_MENU);
gr_bitmap(0, 0, GR_RESIZE_MENU);
}
gr_reset_screen_scale();
}
}
@@ -8471,6 +8551,10 @@ void game_pause()
pause_init();
break;
case GS_STATE_FICTION_VIEWER:
fiction_viewer_pause();
break;
default:
audiostream_pause_all();
}
@@ -8533,6 +8617,10 @@ void game_unpause()
case GS_STATE_GAME_PLAY:
break;
case GS_STATE_FICTION_VIEWER:
fiction_viewer_unpause();
break;
default:
audiostream_unpause_all();
}
+3 -3
View File
@@ -336,8 +336,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,7,1,0000
PRODUCTVERSION 3,7,1,0000
FILEVERSION 3,7,1,000000
PRODUCTVERSION 3,7,1,000000
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -354,7 +354,7 @@ BEGIN
BEGIN
VALUE "CompanyName", "Volition Inc."
VALUE "FileDescription", "FreeSpace 2 Open"
VALUE "FileVersion", "3.7.1.0000"
VALUE "FileVersion", "3.7.1.000000"
VALUE "InternalName", "FreeSpace 2 Open"
VALUE "LegalCopyright", "Copyright © 1998"
VALUE "OriginalFilename", "fs2.exe"
+3 -3
View File
@@ -249,7 +249,7 @@ int FS2NetD_GetPlayerData(const char *player_name, player *pl, bool can_create,
}
// make sure that we get the entire packet
while ( (rc_total < (uint)buffer_size) && (rc_total <= sizeof(buffer)) && (timer_get_fixed_seconds() <= end_time) ) {
while ( (rc_total < (uint)buffer_size) && (rc_total < sizeof(buffer)) && (timer_get_fixed_seconds() <= end_time) ) {
if ( FS2NetD_DataReady() ) {
rc = FS2NetD_GetData(buffer+rc_total, sizeof(buffer) - rc_total);
@@ -361,7 +361,7 @@ int FS2NetD_GetBanList(SCP_vector<SCP_string> &mask_list, bool do_send)
}
// make sure that we get the entire packet
while ( (rc_total < (uint)buffer_size) && (rc_total <= sizeof(buffer)) && (timer_get_fixed_seconds() <= end_time) ) {
while ( (rc_total < (uint)buffer_size) && (rc_total < sizeof(buffer)) && (timer_get_fixed_seconds() <= end_time) ) {
if ( FS2NetD_DataReady() ) {
rc = FS2NetD_GetData(buffer+rc_total, sizeof(buffer) - rc_total);
@@ -435,7 +435,7 @@ int FS2NetD_GetMissionsList(SCP_vector<file_record> &m_list, bool do_send)
}
// make sure that we get the entire packet
while ( (rc_total < (uint)buffer_size) && (rc_total <= sizeof(buffer)) && (timer_get_fixed_seconds() <= end_time) ) {
while ( (rc_total < (uint)buffer_size) && (rc_total < sizeof(buffer)) && (timer_get_fixed_seconds() <= end_time) ) {
if ( FS2NetD_DataReady() ) {
rc = FS2NetD_GetData(buffer+rc_total, sizeof(buffer) - rc_total);
File diff suppressed because it is too large. Load diff
+21 -28
View File
@@ -16,44 +16,37 @@
// Help overlays
//
// Adding a help overlay: 1) Add a #define that uniquely identifies your help overlay
// 2) Increment MAX_HELP_OVERLAYS
// 3) Add the filename for the help overlay to Help_overlays[] array in ContextHelp.cpp
//
#define MAX_HELP_OVERLAYS 16 // Must be kept current
#define MAX_HELP_OVERLAYS 30
#define SS_OVERLAY 0 // ship selection help
#define WL_OVERLAY 1 // weapons loadout help
#define BR_OVERLAY 2 // briefing help
#define MH_OVERLAY 3 // main hall help
#define BARRACKS_OVERLAY 4 // barracks help
#define CONTROL_CONFIG_OVERLAY 5 // control config help
#define DEBRIEFING_OVERLAY 6 // debriefing help
#define MULTI_CREATE_OVERLAY 7 // multi create game help
#define MULTI_START_OVERLAY 8 // multi start game help overlay
#define MULTI_JOIN_OVERLAY 9 // join game help overlay
#define MH2_OVERLAY 10 // main hall 2 help overlay
#define HOTKEY_OVERLAY 11 // hotkey assignment help overlay
#define CAMPAIGN_ROOM_OVERLAY 12 // campaign room help overlay
#define SIM_ROOM_OVERLAY 13 // sim room help overlay
#define TECH_ROOM_OVERLAY 14 // tech room (general) help overlay
#define CMD_BRIEF_OVERLAY 15 // command briefing help overlay
//#define FS2OX_OVERLAY 16 // Chat help overlay
#define SS_OVERLAY "ship" // ship selection help
#define WL_OVERLAY "weapon" // weapons loadout help
#define BR_OVERLAY "briefing" // briefing help
#define MH_OVERLAY "main" // main hall help
#define BARRACKS_OVERLAY "barracks" // barracks help
#define CONTROL_CONFIG_OVERLAY "control" // control config help
#define DEBRIEFING_OVERLAY "debrief" // debriefing help
#define MULTI_CREATE_OVERLAY "multicreate" // multi create game help
#define MULTI_START_OVERLAY "multistart" // multi start game help overlay
#define MULTI_JOIN_OVERLAY "multijoin" // join game help overlay
#define MH2_OVERLAY "main2" // main hall 2 help overlay
#define HOTKEY_OVERLAY "hotkey" // hotkey assignment help overlay
#define CAMPAIGN_ROOM_OVERLAY "campaign" // campaign room help overlay
#define SIM_ROOM_OVERLAY "simulator" // sim room help overlay
#define TECH_ROOM_OVERLAY "tech" // tech room (general) help overlay
#define CMD_BRIEF_OVERLAY "command" // command briefing help overlay
// other help overlay constants
#define HELP_MAX_ITEM 50 // max number of screen elements per element type per overlay
#define HELP_PADDING 1 //
#define HELP_MAX_NAME_LENGTH 32 // max string length for overlay name
#define HELP_MAX_STRING_LENGTH 128 // max string length for text overlay element
#define HELP_MAX_PLINE_VERTICES 21 // good for 20 segments, can prolly reduce this (FIXME)
#define HELP_PLINE_THICKNESS 2
#define HELP_OVERLAY_FILENAME "help.tbl"
// help overlay calls
int help_overlay_get_index(const char* overlay_name);
int help_overlay_active(int overlay_id);
void help_overlay_set_state(int overlay_id, int state);
void help_overlay_load(int overlay_id);
void help_overlay_unload(int overlay_id);
void help_overlay_maybe_blit(int overlay_id);
void help_overlay_set_state(int overlay_id, int resolution_index, int state);
void help_overlay_maybe_blit(int overlay_id, int resolution_index);
void context_help_init(); // called once at game startup
void context_help_grey_screen(); // call to grey out a screen (normally when applying a help overlay)
+4 -8
View File
@@ -788,6 +788,9 @@ int event_music_enemy_arrival()
else {
next_pattern = SONG_EARV_1;
}
if ( Current_pattern < 0 )
return 0;
if ( Current_pattern == next_pattern )
return 0; // already playing
@@ -1125,7 +1128,7 @@ int event_music_player_respawn_as_observer()
bool parse_soundtrack_line(int strack_idx, int pattern_idx)
{
char fname[MAX_FILENAME_LEN];
char line_buf[128];
char line_buf[MAX_PATH_LEN];
char *token;
int count = 0;
@@ -1377,12 +1380,8 @@ void event_music_parse_musictbl(const char *filename)
if ((rval = setjmp(parse_abort)) != 0) {
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", filename, rval));
lcl_ext_close();
} else {
// open localization
lcl_ext_open();
read_file_text(filename, CF_TYPE_TABLES);
reset_parse();
@@ -1401,9 +1400,6 @@ void event_music_parse_musictbl(const char *filename)
}
}
}
// close localization
lcl_ext_close();
}
}
-6
View File
@@ -777,16 +777,10 @@ void parse_sound_table(const char* filename)
*/
void gamesnd_parse_soundstbl()
{
// open localization
lcl_ext_open();
parse_sound_table("sounds.tbl");
parse_modular_table("*-snd.tbm", parse_sound_table);
// close localization
lcl_ext_close();
// if we are missing any species then report
if (missingFlybySounds.size() > 0)
{
+2
View File
@@ -38,6 +38,8 @@
#define Color_text_active_hi Color_bright_white
// text drawn as a heading for a section or title, etc
#define Color_text_heading Color_violet_gray
// color of the "more" indicator in briefings/command briefings/debrefings
#define Color_more_indicator Color_red
#define Color_bright Color_bright_blue
#define Color_normal Color_white
+3 -3
View File
@@ -1428,7 +1428,7 @@ char *Default_main_fragment_shader =
" vec3 envReflectNM = envReflect + envOffset;\n"
" vec4 envColour = textureCube(sEnvmap, envReflectNM);\n"
" #endif\n"
" normal.b = sqrt(1.0 - dot(normal.rg, normal.rg));\n"
" normal.b = 1.0;\n"
" normal = tbnMatrix * normal;\n"
" float norm = length(normal);\n"
" // prevent breaking of normal maps\n"
@@ -1543,12 +1543,12 @@ char *Default_main_fragment_shader =
" #endif\n"
" #ifdef FLAG_ANIMATED\n"
" if (effect_num == 0) {\n"
" float shinefactor = 1.0/(1.0 + pow((fract(abs(gl_TexCoord[0].x))-anim_timer) * 1000.0, 2.0)) * 1000.0;\n"
" float shinefactor = 1.0/(1.0 + pow(abs((fract(abs(gl_TexCoord[0].x))-anim_timer) * 1000.0), 2.0)) * 1000.0;\n"
" gl_FragColor.rgb = fragmentColor.rgb + vec3(shinefactor);\n"
" gl_FragColor.a = fragmentColor.a * clamp(shinefactor * (fract(abs(gl_TexCoord[0].x))-anim_timer) * -10000.0,0.0,1.0);\n"
" }\n"
" if (effect_num == 1) {\n"
" float shinefactor = 1.0/(1.0 + pow((position.y-anim_timer), 2.0));\n"
" float shinefactor = 1.0/(1.0 + pow(abs(position.y-anim_timer), 2.0));\n"
" gl_FragColor.rgb = fragmentColor.rgb + vec3(shinefactor);\n"
" #ifdef FLAG_LIGHT\n"
" gl_FragColor.a = fragmentColor.a;\n"
+1 -108
View File
@@ -320,113 +320,6 @@ const int RAND_MAX_2 = (RAND_MAX/2);
extern int Fred_running; // Is Fred running, or FreeSpace?
//======================================================================================
//====== D E B U G C O N S O L E S T U F F ========================
//======================================================================================
// Here is a a sample command to toggle something that would
// be called by doing "toggle it" from the debug console command window/
/*
DCF(toggle_it,"description")
{
if (Dc_command) {
This_var = !This_var;
}
if (Dc_help) {
dc_printf( "Usage: sample\nToggles This_var on/off.\n" );
}
if (Dc_status) {
dc_printf( "The status is %d.\n", This_var );
}
*/
class debug_command {
public:
char *name;
char *help;
void (*func)();
debug_command(char *name,char *help,void (*func)()); // constructor
};
#define DCF(function_name,help_text) \
void dcf_##function_name(); \
debug_command dc_##function_name(#function_name,help_text,dcf_##function_name); \
void dcf_##function_name()
// Starts the debug console
extern void debug_console( void (*func)() = NULL );
// The next three variables tell your function what to do. It should
// only change something if the dc_command is set. A minimal function
// needs to process the dc_command. Usually, these will be called in
// these combinations:
// dc_command=true, dc_status=true means process it and show status
// dc_help=true means show help only
// dc_status=true means show status only
// I would recommend doing this in each function:
// if (dc_command) { process command }
// if (dc_help) { print out help }
// if (dc_status) { print out status }
// with the last two being optional
extern int Dc_command; // If this is set, then process the command
extern int Dc_help; // If this is set, then print out the help text in the form, "usage: ... \nLong description\n" );
extern int Dc_status; // If this is set, then print out the current status of the command.
void dc_get_arg(uint flags); // Gets the next argument. If it doesn't match the flags, this function will print an error and not return.
extern char *Dc_arg; // The (lowercased) string value of the argument retrieved from dc_arg
extern char *Dc_arg_org; // Dc_arg before it got converted to lowercase
extern uint Dc_arg_type; // The type of dc_arg.
extern char *Dc_command_line; // The rest of the command line, from the end of the last processed arg on.
extern int Dc_arg_int; // If Dc_arg_type & ARG_INT or ARG_HEX is set, then this is the value
extern ubyte Dc_arg_ubyte; // If Dc_arg_type & ARG_UBYTE is set, then this is the value
extern float Dc_arg_float; // If Dc_arg_type & ARG_FLOAT is set, then this is the value
// Outputs text to the console
void dc_printf( char *format, ... );
// Each dc_arg_type can have one or more of these flags set.
// This is because some things can fit into two categories.
// Like 1 can be an integer, a float, a string, or a true boolean
// value.
#define ARG_NONE (1<<0) // no argument
#define ARG_ANY 0xFFFFFFFF // Anything.
#define ARG_STRING (1<<1) // any valid string
#define ARG_QUOTE (1<<2) // a quoted string
#define ARG_INT (1<<3) // a valid integer
#define ARG_FLOAT (1<<4) // a valid floating point number
// some specific commonly used predefined types. Can add up to (1<<31)
#define ARG_HEX (1<<5) // a valid hexadecimal integer. Note that ARG_INT will always be set also in this case.
#define ARG_TRUE (1<<6) // on, true, non-zero number
#define ARG_FALSE (1<<7) // off, false, zero
#define ARG_PLUS (1<<8) // Plus sign
#define ARG_MINUS (1<<9) // Minus sign
#define ARG_COMMA (1<<10) // a comma
#define ARG_UBYTE (1<<11) // a valid ubyte
// A shortcut for boolean only variables.
// Example:
// DCF_BOOL( lighting, Show_lighting )
//
#define DCF_BOOL( function_name, bool_variable ) \
void dcf_##function_name(); \
debug_command dc_##function_name(#function_name,"Toggles "#bool_variable,dcf_##function_name ); \
void dcf_##function_name() { \
if ( Dc_command ) { \
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE); \
if ( Dc_arg_type & ARG_TRUE ) bool_variable = 1; \
else if ( Dc_arg_type & ARG_FALSE ) bool_variable = 0; \
else if ( Dc_arg_type & ARG_NONE ) bool_variable ^= 1; \
} \
if ( Dc_help ) dc_printf( "Usage: %s [bool]\nSets %s to true or false. If nothing passed, then toggles it.\n", #function_name, #bool_variable ); \
if ( Dc_status ) dc_printf( "%s is %s\n", #function_name, (bool_variable?"TRUE":"FALSE") ); \
}
//======================================================================================
//======================================================================================
//======================================================================================
@@ -437,7 +330,7 @@ void dc_printf( char *format, ... );
// Some constants for stuff
#define MAX_FILENAME_LEN 32 // Length for filenames, ie "title.pcx"
#define MAX_PATH_LEN 128 // Length for pathnames, ie "c:\bitmaps\title.pcx"
#define MAX_PATH_LEN 256 // Length for pathnames, ie "c:\bitmaps\title.pcx"
// contants and defined for byteswapping routines (useful for mac)
+118 -101
View File
@@ -8,7 +8,7 @@
*/
#include "debugconsole/console.h"
#include "globalincs/pstypes.h"
#include "globalincs/systemvars.h"
#include "io/timer.h"
@@ -245,76 +245,79 @@ monitor::monitor( char *_name )
int Monitor_inited = 0;
char Monitor_filename[128];
char Monitor_filename[MAX_PATH_LEN];
fix monitor_last_time = -1;
DCF(monitor,"Monitors game performace")
DCF(monitor,"Monitors game performace by saving to file")
{
if ( Dc_command ) {
dc_get_arg(ARG_STRING|ARG_NONE);
if ( Dc_arg_type == ARG_NONE ) {
if ( Monitor_inited ) {
Monitor_inited = 0;
SCP_string filename;
if (dc_optional_string_either("help", "--help")) {
dc_printf("Usage: monitor [filename]\n");
dc_printf("Outputs monitoring info to [filename]. No filename turns it off\n" );
return;
}
if (dc_maybe_stuff_string_white(filename)) {
if ( Monitor_inited ) {
dc_printf( "Monitor already on\n" );
} else {
Monitor_inited = 1;
strcpy_s(Monitor_filename, filename.c_str());
// Reset them all
int i;
for (i=0; i<Num_monitors; i++ ) {
Monitor[i]->value = 0;
Monitor[i]->sum = 0;
Monitor[i]->cnt = 0;
Monitor[i]->min = 0;
Monitor[i]->max = 0;
}
FILE *fp = fopen( Monitor_filename, "wt" );
if ( fp ) {
for (i=0; i<Num_monitors; i++ ) {
if ( i > 0 ) {
fprintf( fp, "\t" );
}
fprintf( fp, "%s", Monitor[i]->name );
}
fprintf( fp, "\n" );
fclose(fp);
}
dc_printf( "Monitor outputting to file '%s'\n", Monitor_filename );
monitor_last_time = -1;
}
} else {
// Turn off monitoring
if ( Monitor_inited ) {
Monitor_inited = 0;
/*
FILE *fp = fopen( Monitor_filename, "at" );
if ( fp ) {
fprintf( fp, "\n\n" );
fprintf( fp, "Name\tMin\tMax\tAvg\n" );
for (int i=0; i<Num_monitors; i++ ) {
if ( Monitor[i]->cnt > 0 ) {
fprintf( fp, "%s\t%d\t%d\t%d\n", Monitor[i]->name, Monitor[i]->min, Monitor[i]->max, Monitor[i]->sum / Monitor[i]->cnt );
} else {
fprintf( fp, "%s\t%d\t%d\t?\n", Monitor[i]->name, Monitor[i]->min, Monitor[i]->max );
}
FILE *fp = fopen( Monitor_filename, "at" );
if ( fp ) {
fprintf( fp, "\n\n" );
fprintf( fp, "Name\tMin\tMax\tAvg\n" );
for (int i=0; i<Num_monitors; i++ ) {
if ( Monitor[i]->cnt > 0 ) {
fprintf( fp, "%s\t%d\t%d\t%d\n", Monitor[i]->name, Monitor[i]->min, Monitor[i]->max, Monitor[i]->sum / Monitor[i]->cnt );
} else {
fprintf( fp, "%s\t%d\t%d\t?\n", Monitor[i]->name, Monitor[i]->min, Monitor[i]->max );
}
fclose(fp);
}
fclose(fp);
}
*/
dc_printf( "Monitor to file '%s' turned off\n", Monitor_filename );
} else {
dc_printf( "Monitor isn't on\n" );
}
dc_printf( "Monitor to file '%s' turned off\n", Monitor_filename );
} else {
if ( Monitor_inited ) {
dc_printf( "Monitor already on\n" );
} else {
Monitor_inited = 1;
strcpy_s( Monitor_filename, Dc_arg );
// Reset them all
int i;
for (i=0; i<Num_monitors; i++ ) {
Monitor[i]->value = 0;
Monitor[i]->sum = 0;
Monitor[i]->cnt = 0;
Monitor[i]->min = 0;
Monitor[i]->max = 0;
}
FILE *fp = fopen( Monitor_filename, "wt" );
if ( fp ) {
for (i=0; i<Num_monitors; i++ ) {
if ( i > 0 ) {
fprintf( fp, "\t" );
}
fprintf( fp, "%s", Monitor[i]->name );
}
fprintf( fp, "\n" );
fclose(fp);
}
dc_printf( "Monitor outputting to file '%s'\n", Monitor_filename );
monitor_last_time = -1;
}
dc_printf( "Monitor isn't on\n" );
}
}
if ( Dc_help ) {
dc_printf( "Usage: monitor filename\nOutputs monitoring info to filename. No filename turns it off\n" );
}
}
@@ -508,44 +511,41 @@ int current_detail_level()
#ifndef NDEBUG
DCF(detail_level,"Change the detail level")
{
if ( Dc_command ) {
dc_get_arg(ARG_INT|ARG_NONE);
if ( Dc_arg_type & ARG_NONE ) {
Game_detail_level = 0;
dc_printf( "Detail level reset\n" );
}
if ( Dc_arg_type & ARG_INT ) {
Game_detail_level = Dc_arg_int;
}
int value;
if (dc_optional_string_either("help", "--help")) {
dc_printf( "Usage: detail_level [n]\n");
dc_printf("[n] -- is detail level.\n");
dc_printf("\t0 is 'normal' detail,\n");
dc_printf("\tnegative values are lower, and\n");
dc_printf("\tpositive values are higher.\n\n");
dc_printf("No parameter resets it to default.\n");
return;
}
if ( Dc_help )
dc_printf( "Usage: detail_level [n]\nn is detail level. 0 normal, - lower, + higher, -2 to 2 usually\nNo parameter resets it to default.\n" );
if ( Dc_status )
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf("Detail level set to %d\n", Game_detail_level);
return;
}
if (dc_maybe_stuff_int(&value)) {
Game_detail_level = value;
dc_printf("Detail level set to %i\n", Game_detail_level);
} else {
Game_detail_level = 0;
dc_printf("Detail level reset\n");
}
}
DCF(detail, "Turns on/off parts of the game for speed testing" )
{
if ( Dc_command ) {
dc_get_arg(ARG_INT|ARG_NONE);
if ( Dc_arg_type & ARG_NONE ) {
if ( Game_detail_flags == DETAIL_DEFAULT ) {
Game_detail_flags = DETAIL_FLAG_CLEAR;
dc_printf( "Detail flags set lowest (except has screen clear)\n" );
} else {
Game_detail_flags = DETAIL_DEFAULT;
dc_printf( "Detail flags set highest\n" );
}
}
if ( Dc_arg_type & ARG_INT ) {
Game_detail_flags ^= Dc_arg_int;
}
}
int value;
if ( Dc_help ) {
dc_printf( "Usage: detail [n]\nn is detail bit to toggle.\n" );
if (dc_optional_string_either("help", "--help")) {
dc_printf( "Usage: detail [n]\n");
dc_printf("[n] is detail bit to toggle:\n" );
dc_printf( " 1: draw the stars\n" );
dc_printf( " 2: draw the nebulas\n" );
dc_printf( " 4: draw the motion debris\n" );
@@ -555,21 +555,38 @@ DCF(detail, "Turns on/off parts of the game for speed testing" )
dc_printf( " 64: clear screen background after each frame\n" );
dc_printf( " 128: draw hud stuff\n" );
dc_printf( " 256: draw fireballs\n" );
dc_printf( " 512: do collision detection\n" );
dc_printf( " 512: do collision detection\n\n" );
dc_printf("No argument will toggle between highest/lowest detail settings\n");
return;
}
if ( Dc_status ) {
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf("Detail flags set to 0x%08x\n", Game_detail_flags);
dc_printf( " 1: draw the stars: %s\n", (Game_detail_flags&1?"on":"off") );
dc_printf( " 2: draw the nebulas: %s\n", (Game_detail_flags&2?"on":"off") );
dc_printf( " 4: draw the motion debris: %s\n", (Game_detail_flags&4?"on":"off") );
dc_printf( " 8: draw planets: %s\n", (Game_detail_flags&8?"on":"off") );
dc_printf( " 16: draw models not as blobs: %s\n", (Game_detail_flags&16?"on":"off") );
dc_printf( " 32: draw lasers not as pixels: %s\n", (Game_detail_flags&32?"on":"off") );
dc_printf( " 64: clear screen background after each frame: %s\n", (Game_detail_flags&64?"on":"off") );
dc_printf( " 128: draw hud stuff: %s\n", (Game_detail_flags&128?"on":"off") );
dc_printf( " 256: draw fireballs: %s\n", (Game_detail_flags&256?"on":"off") );
dc_printf( " 512: do collision detection: %s\n", (Game_detail_flags&512?"on":"off") );
dc_printf( " 1: draw the stars: %s\n", ((Game_detail_flags & 1) ? "on" : "off"));
dc_printf( " 2: draw the nebulas: %s\n", ((Game_detail_flags & 2)?"on" : "off"));
dc_printf( " 4: draw the motion debris: %s\n", ((Game_detail_flags & 4) ? "on" : "off"));
dc_printf( " 8: draw planets: %s\n", ((Game_detail_flags & 8) ? "on" : "off"));
dc_printf( " 16: draw models not as blobs: %s\n", ((Game_detail_flags & 16) ? "on" : "off"));
dc_printf( " 32: draw lasers not as pixels: %s\n", ((Game_detail_flags & 32) ? "on" : "off"));
dc_printf( " 64: clear screen background after each frame: %s\n", ((Game_detail_flags & 64) ? "on" : "off"));
dc_printf( " 128: draw hud stuff: %s\n", ((Game_detail_flags & 128) ? "on" : "off"));
dc_printf( " 256: draw fireballs: %s\n", ((Game_detail_flags & 256) ? "on" : "off"));
dc_printf( " 512: do collision detection: %s\n", ((Game_detail_flags & 512) ? "on" : "off"));
return;
}
if (dc_maybe_stuff_int(&value)) {
Game_detail_flags ^= value;
} else {
if (Game_detail_flags == DETAIL_DEFAULT) {
Game_detail_flags = DETAIL_FLAG_CLEAR;
dc_printf( "Detail flags set lowest (except has screen clear)\n" );
} else {
Game_detail_flags = DETAIL_DEFAULT;
dc_printf( "Detail flags set highest\n" );
}
}
}
#endif
+1 -1
View File
@@ -35,7 +35,7 @@
#define FS_VERSION_MAJOR 3 // major version
#define FS_VERSION_MINOR 7 // increase by 1 for minor revs
#define FS_VERSION_BUILD 1 // bugfix release
#define FS_VERSION_REVIS 0000 // SVN revision
#define FS_VERSION_REVIS 000000 // SVN revision
#define VERSION_LOC_FNAME "version.nfo"
#define MOTD_LOC_FNAME "motd.txt"
+5
View File
@@ -8,6 +8,7 @@
#include <map>
#include <string>
#include <queue>
#include <deque>
#if defined __GNUC__
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
@@ -127,6 +128,9 @@ class SCP_multimap : public std::multimap<T, U, std::less<T>, SCP_vm_allocator<s
template< typename T >
class SCP_queue : public std::queue< T, std::deque< T, SCP_vm_allocator< T > > > { };
template< typename T >
class SCP_deque : public std::deque< T, SCP_vm_allocator< T > > { };
template <class T1, class T2>
bool operator==(const SCP_vm_allocator<T1>&, const SCP_vm_allocator<T2>&) throw()
{
@@ -145,6 +149,7 @@ bool operator!=(const SCP_vm_allocator<T1>&, const SCP_vm_allocator<T2>&) throw(
#define SCP_map std::map
#define SCP_multimap std::multimap
#define SCP_queue std::queue
#define SCP_deque std::deque
#define SCP_vector std::vector
#define SCP_list std::list
+2 -1
View File
@@ -33,6 +33,7 @@
#include "cmdline/cmdline.h"
#include "parse/lua.h"
#include "parse/parselo.h"
#include "debugconsole/console.h"
#if defined( SHOW_CALL_STACK ) && defined( PDB_DEBUGGING )
# include "globalincs/mspdb_callstack.h"
@@ -1522,7 +1523,7 @@ void windebug_memwatch_init()
#endif
int Watch_malloc = 0;
DCF_BOOL(watch_malloc, Watch_malloc )
DCF_BOOL(watch_malloc, Watch_malloc );
// Returns 0 if not enough RAM.
int vm_init(int min_heap_size)
+242 -57
View File
@@ -32,6 +32,8 @@
#include "gamesequence/gamesequence.h" //WMC - for scripting hooks in gr_flip()
#include "io/keycontrol.h" // m!m
#include "io/cursor.h"
#include "debugconsole/console.h"
#include "debugconsole/console.h"
#if ( SDL_VERSION_ATLEAST(1, 2, 7) )
@@ -90,50 +92,80 @@ static int GL_cursor_nframes = 0;
static float Gr_full_resize_X = 1.0f, Gr_full_resize_Y = 1.0f;
static float Gr_resize_X = 1.0f, Gr_resize_Y = 1.0f;
static float Gr_menu_offset_X = 0.0f, Gr_menu_offset_Y = 0.0f;
static float Gr_menu_zoomed_offset_X = 0.0f, Gr_menu_zoomed_offset_Y = 0.0f;
float Gr_save_full_resize_X = 1.0f, Gr_save_full_resize_Y = 1.0f;
float Gr_save_resize_X = 1.0f, Gr_save_resize_Y = 1.0f;
float Gr_save_menu_offset_X = 0.0f, Gr_save_menu_offset_Y = 0.0f;
float Gr_save_menu_zoomed_offset_X = 0.0f, Gr_save_menu_zoomed_offset_Y = 0.0f;
bool Save_custom_screen_size;
void gr_set_screen_scale(int w, int h)
void gr_set_screen_scale(int w, int h, int zoom_w, int zoom_h, int max_w, int max_h, bool force_stretch)
{
Gr_full_resize_X = (float)gr_screen.max_w / (float)w;
Gr_full_resize_Y = (float)gr_screen.max_h / (float)h;
bool do_zoom = zoom_w > 0 && zoom_h > 0 && (zoom_w != w || zoom_h != h);
if (!Cmdline_stretch_menu) {
float aspect_quotient = ((float)gr_screen.max_w / (float)gr_screen.max_h) / ((float)w / (float)h);
Gr_full_resize_X = (float)max_w / (float)w;
Gr_full_resize_Y = (float)max_h / (float)h;
Gr_resize_X = Gr_full_resize_X / ((aspect_quotient > 1.0f) ? aspect_quotient : 1.0f);
Gr_resize_Y = Gr_full_resize_Y * ((aspect_quotient < 1.0f) ? aspect_quotient : 1.0f);
if (do_zoom) {
float aspect_quotient = ((float)max_w / (float)max_h) / ((float)zoom_w / (float)zoom_h);
Gr_menu_offset_X = (aspect_quotient > 1.0f) ? ((gr_screen.max_w - gr_screen.max_w / aspect_quotient) / 2.0f) : 0.0f;
Gr_menu_offset_Y = (aspect_quotient < 1.0f) ? ((gr_screen.max_h - gr_screen.max_h * aspect_quotient) / 2.0f) : 0.0f;
Gr_resize_X = (float)max_w / (float)zoom_w / ((aspect_quotient > 1.0f) ? aspect_quotient : 1.0f);
Gr_resize_Y = (float)max_h / (float)zoom_h * ((aspect_quotient < 1.0f) ? aspect_quotient : 1.0f);
Gr_menu_offset_X = (max_w - w * Gr_resize_X) / 2.0f;
Gr_menu_offset_Y = (max_h - h * Gr_resize_Y) / 2.0f;
Gr_menu_zoomed_offset_X = (Gr_menu_offset_X >= 0.0f) ? Gr_menu_offset_X : 0.0f;
Gr_menu_zoomed_offset_Y = (Gr_menu_offset_Y >= 0.0f) ? Gr_menu_offset_Y : 0.0f;
if (force_stretch || Cmdline_stretch_menu) {
if (Gr_menu_offset_X > 0.0f) {
Gr_resize_X = Gr_full_resize_X;
Gr_menu_offset_X = Gr_menu_zoomed_offset_X = 0.0f;
}
if (Gr_menu_offset_Y > 0.0f) {
Gr_resize_Y = Gr_full_resize_Y;
Gr_menu_offset_Y = Gr_menu_zoomed_offset_Y = 0.0f;
}
}
} else {
Gr_resize_X = Gr_full_resize_X;
Gr_resize_Y = Gr_full_resize_Y;
if (force_stretch || Cmdline_stretch_menu) {
Gr_resize_X = Gr_full_resize_X;
Gr_resize_Y = Gr_full_resize_Y;
Gr_menu_offset_X = 0.0f;
Gr_menu_offset_Y = 0.0f;
Gr_menu_offset_X = Gr_menu_zoomed_offset_X = 0.0f;
Gr_menu_offset_Y = Gr_menu_zoomed_offset_Y = 0.0f;
} else {
float aspect_quotient = ((float)max_w / (float)max_h) / ((float)w / (float)h);
Gr_resize_X = Gr_full_resize_X / ((aspect_quotient > 1.0f) ? aspect_quotient : 1.0f);
Gr_resize_Y = Gr_full_resize_Y * ((aspect_quotient < 1.0f) ? aspect_quotient : 1.0f);
Gr_menu_offset_X = Gr_menu_zoomed_offset_X = (aspect_quotient > 1.0f) ? ((max_w - w * Gr_resize_X) / 2.0f) : 0.0f;
Gr_menu_offset_Y = Gr_menu_zoomed_offset_Y = (aspect_quotient < 1.0f) ? ((max_h - h * Gr_resize_Y) / 2.0f) : 0.0f;
}
}
Save_custom_screen_size = gr_screen.custom_size;
gr_screen.custom_size = (w != max_w || h != max_h);
gr_screen.custom_size = true;
}
gr_screen.max_w_unscaled = w;
gr_screen.max_h_unscaled = h;
void gr_set_screen_scale(int w, int h, int max_w, int max_h)
{
Gr_resize_X = Gr_full_resize_X = (float)max_w / (float)w;
Gr_resize_Y = Gr_full_resize_Y = (float)max_h / (float)h;
Gr_menu_offset_X = 0.0f;
Gr_menu_offset_Y = 0.0f;
Save_custom_screen_size = gr_screen.custom_size;
gr_screen.custom_size = true;
if (do_zoom) {
gr_screen.max_w_unscaled_zoomed = gr_screen.max_w_unscaled + fl2i(Gr_menu_offset_X * 2.0f / Gr_resize_X);
gr_screen.max_h_unscaled_zoomed = gr_screen.max_h_unscaled + fl2i(Gr_menu_offset_Y * 2.0f / Gr_resize_Y);
if (gr_screen.max_w_unscaled_zoomed > gr_screen.max_w_unscaled) {
gr_screen.max_w_unscaled_zoomed = gr_screen.max_w_unscaled;
}
if (gr_screen.max_h_unscaled_zoomed > gr_screen.max_h_unscaled) {
gr_screen.max_h_unscaled_zoomed = gr_screen.max_h_unscaled;
}
} else {
gr_screen.max_w_unscaled_zoomed = gr_screen.max_w_unscaled;
gr_screen.max_h_unscaled_zoomed = gr_screen.max_h_unscaled;
}
}
void gr_reset_screen_scale()
@@ -147,7 +179,13 @@ void gr_reset_screen_scale()
Gr_menu_offset_X = Gr_save_menu_offset_X;
Gr_menu_offset_Y = Gr_save_menu_offset_Y;
Gr_menu_zoomed_offset_X = Gr_save_menu_zoomed_offset_X;
Gr_menu_zoomed_offset_Y = Gr_save_menu_zoomed_offset_Y;
gr_screen.custom_size = Save_custom_screen_size;
gr_screen.max_w_unscaled = gr_screen.max_w_unscaled_zoomed = (gr_screen.res == GR_1024) ? 1024 : 640;
gr_screen.max_h_unscaled = gr_screen.max_h_unscaled_zoomed = (gr_screen.res == GR_1024) ? 768 : 480;
}
/**
@@ -163,19 +201,51 @@ void gr_reset_screen_scale()
*/
bool gr_resize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
{
if ( resize_mode == GR_RESIZE_NONE || !gr_screen.custom_size && (gr_screen.rendering_to_texture == -1) ) {
if ( resize_mode == GR_RESIZE_NONE || (!gr_screen.custom_size && (gr_screen.rendering_to_texture == -1)) ) {
return false;
}
float xy_tmp = 0.0f;
if ( x ) {
xy_tmp = (*x) * ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_X : Gr_resize_X) + ((resize_mode == GR_RESIZE_MENU) ? Gr_menu_offset_X : 0.0f);
switch (resize_mode) {
case GR_RESIZE_FULL:
xy_tmp = (*x) * Gr_full_resize_X;
break;
case GR_RESIZE_MENU:
xy_tmp = (*x) * Gr_resize_X + Gr_menu_offset_X;
break;
case GR_RESIZE_MENU_ZOOMED:
xy_tmp = (*x) * Gr_resize_X + Gr_menu_zoomed_offset_X;
break;
case GR_RESIZE_MENU_NO_OFFSET:
xy_tmp = (*x) * Gr_resize_X;
break;
}
(*x) = fl2i(xy_tmp);
}
if ( y ) {
xy_tmp = (*y) * ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_Y : Gr_resize_Y) + ((resize_mode == GR_RESIZE_MENU) ? Gr_menu_offset_Y : 0.0f);
switch (resize_mode) {
case GR_RESIZE_FULL:
xy_tmp = (*y) * Gr_full_resize_Y;
break;
case GR_RESIZE_MENU:
xy_tmp = (*y) * Gr_resize_Y + Gr_menu_offset_Y;
break;
case GR_RESIZE_MENU_ZOOMED:
xy_tmp = (*y) * Gr_resize_Y + Gr_menu_zoomed_offset_Y;
break;
case GR_RESIZE_MENU_NO_OFFSET:
xy_tmp = (*y) * Gr_resize_Y;
break;
}
(*y) = fl2i(xy_tmp);
}
@@ -203,19 +273,51 @@ bool gr_resize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
*/
bool gr_unsize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
{
if ( resize_mode == GR_RESIZE_NONE || !gr_screen.custom_size && (gr_screen.rendering_to_texture == -1) ) {
if ( resize_mode == GR_RESIZE_NONE || (!gr_screen.custom_size && (gr_screen.rendering_to_texture == -1)) ) {
return false;
}
float xy_tmp = 0.0f;
if ( x ) {
xy_tmp = ((*x) - ((resize_mode == GR_RESIZE_MENU) ? Gr_menu_offset_X : 0.0f)) / ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_X : Gr_resize_X);
switch (resize_mode) {
case GR_RESIZE_FULL:
xy_tmp = (*x) / Gr_full_resize_X;
break;
case GR_RESIZE_MENU:
xy_tmp = ((*x) - Gr_menu_offset_X) / Gr_resize_X;
break;
case GR_RESIZE_MENU_ZOOMED:
xy_tmp = ((*x) - Gr_menu_zoomed_offset_X) / Gr_resize_X;
break;
case GR_RESIZE_MENU_NO_OFFSET:
xy_tmp = (*x) / Gr_resize_X;
break;
}
(*x) = fl2i(xy_tmp);
}
if ( y ) {
xy_tmp = ((*y) - ((resize_mode == GR_RESIZE_MENU) ? Gr_menu_offset_Y : 0.0f)) / ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_Y : Gr_resize_Y);
switch (resize_mode) {
case GR_RESIZE_FULL:
xy_tmp = (*y) / Gr_full_resize_Y;
break;
case GR_RESIZE_MENU:
xy_tmp = ((*y) - Gr_menu_offset_Y) / Gr_resize_Y;
break;
case GR_RESIZE_MENU_ZOOMED:
xy_tmp = ((*y) - Gr_menu_zoomed_offset_Y) / Gr_resize_Y;
break;
case GR_RESIZE_MENU_NO_OFFSET:
xy_tmp = (*y) / Gr_resize_Y;
break;
}
(*y) = fl2i(xy_tmp);
}
@@ -245,19 +347,51 @@ bool gr_unsize_screen_pos(int *x, int *y, int *w, int *h, int resize_mode)
*/
bool gr_resize_screen_posf(float *x, float *y, float *w, float *h, int resize_mode)
{
if ( resize_mode == GR_RESIZE_NONE || !gr_screen.custom_size && (gr_screen.rendering_to_texture == -1) ) {
if ( resize_mode == GR_RESIZE_NONE || (!gr_screen.custom_size && (gr_screen.rendering_to_texture == -1)) ) {
return false;
}
float xy_tmp = 0.0f;
if ( x ) {
xy_tmp = (*x) * ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_X : Gr_resize_X) + ((resize_mode == GR_RESIZE_MENU) ? Gr_menu_offset_X : 0.0f);
switch (resize_mode) {
case GR_RESIZE_FULL:
xy_tmp = (*x) * Gr_full_resize_X;
break;
case GR_RESIZE_MENU:
xy_tmp = (*x) * Gr_resize_X + Gr_menu_offset_X;
break;
case GR_RESIZE_MENU_ZOOMED:
xy_tmp = (*x) * Gr_resize_X + Gr_menu_zoomed_offset_X;
break;
case GR_RESIZE_MENU_NO_OFFSET:
xy_tmp = (*x) * Gr_resize_X;
break;
}
(*x) = xy_tmp;
}
if ( y ) {
xy_tmp = (*y) * ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_Y : Gr_resize_Y) + ((resize_mode == GR_RESIZE_MENU) ? Gr_menu_offset_Y : 0.0f);
switch (resize_mode) {
case GR_RESIZE_FULL:
xy_tmp = (*y) * Gr_full_resize_Y;
break;
case GR_RESIZE_MENU:
xy_tmp = (*y) * Gr_resize_Y + Gr_menu_offset_Y;
break;
case GR_RESIZE_MENU_ZOOMED:
xy_tmp = (*y) * Gr_resize_Y + Gr_menu_zoomed_offset_Y;
break;
case GR_RESIZE_MENU_NO_OFFSET:
xy_tmp = (*y) * Gr_resize_Y;
break;
}
(*y) = xy_tmp;
}
@@ -285,19 +419,51 @@ bool gr_resize_screen_posf(float *x, float *y, float *w, float *h, int resize_mo
*/
bool gr_unsize_screen_posf(float *x, float *y, float *w, float *h, int resize_mode)
{
if ( resize_mode == GR_RESIZE_NONE || !gr_screen.custom_size && (gr_screen.rendering_to_texture == -1) ) {
if ( resize_mode == GR_RESIZE_NONE || (!gr_screen.custom_size && (gr_screen.rendering_to_texture == -1)) ) {
return false;
}
float xy_tmp = 0.0f;
if ( x ) {
xy_tmp = ((*x) - ((resize_mode == GR_RESIZE_MENU) ? Gr_menu_offset_X : 0.0f)) / ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_X : Gr_resize_X);
switch (resize_mode) {
case GR_RESIZE_FULL:
xy_tmp = (*x) / Gr_full_resize_X;
break;
case GR_RESIZE_MENU:
xy_tmp = ((*x) - Gr_menu_offset_X) / Gr_resize_X;
break;
case GR_RESIZE_MENU_ZOOMED:
xy_tmp = ((*x) - Gr_menu_zoomed_offset_X) / Gr_resize_X;
break;
case GR_RESIZE_MENU_NO_OFFSET:
xy_tmp = (*x) / Gr_resize_X;
break;
}
(*x) = xy_tmp;
}
if ( y ) {
xy_tmp = ((*y) - ((resize_mode == GR_RESIZE_MENU) ? Gr_menu_offset_Y : 0.0f)) / ((resize_mode == GR_RESIZE_FULL) ? Gr_full_resize_Y : Gr_resize_Y);
switch (resize_mode) {
case GR_RESIZE_FULL:
xy_tmp = (*y) / Gr_full_resize_Y;
break;
case GR_RESIZE_MENU:
xy_tmp = ((*y) - Gr_menu_offset_Y) / Gr_resize_Y;
break;
case GR_RESIZE_MENU_ZOOMED:
xy_tmp = ((*y) - Gr_menu_zoomed_offset_Y) / Gr_resize_Y;
break;
case GR_RESIZE_MENU_NO_OFFSET:
xy_tmp = (*y) / Gr_resize_Y;
break;
}
(*y) = xy_tmp;
}
@@ -347,12 +513,9 @@ DCF(clear_color, "set clear color r, g, b")
{
ubyte r, g, b;
dc_get_arg(ARG_UBYTE);
r = Dc_arg_ubyte;
dc_get_arg(ARG_UBYTE);
g = Dc_arg_ubyte;
dc_get_arg(ARG_UBYTE);
b = Dc_arg_ubyte;
dc_stuff_ubyte(&r);
dc_stuff_ubyte(&g);
dc_stuff_ubyte(&b);
// set the color
gr_set_clear_color(r, g, b);
@@ -421,8 +584,8 @@ void gr_screen_resize(int width, int height)
return;
}
gr_screen.save_max_w = gr_screen.max_w = gr_screen.max_w_unscaled = width;
gr_screen.save_max_h = gr_screen.max_h = gr_screen.max_h_unscaled = height;
gr_screen.save_max_w = gr_screen.max_w = gr_screen.max_w_unscaled = gr_screen.max_w_unscaled_zoomed = width;
gr_screen.save_max_h = gr_screen.max_h = gr_screen.max_h_unscaled = gr_screen.max_h_unscaled_zoomed = height;
gr_screen.offset_x = gr_screen.offset_x_unscaled = 0;
gr_screen.offset_y = gr_screen.offset_y_unscaled = 0;
@@ -437,12 +600,15 @@ void gr_screen_resize(int width, int height)
if (gr_screen.custom_size) {
gr_unsize_screen_pos( &gr_screen.max_w_unscaled, &gr_screen.max_h_unscaled );
gr_unsize_screen_pos( &gr_screen.max_w_unscaled_zoomed, &gr_screen.max_h_unscaled_zoomed );
gr_unsize_screen_pos( &gr_screen.clip_right_unscaled, &gr_screen.clip_bottom_unscaled );
gr_unsize_screen_pos( &gr_screen.clip_width_unscaled, &gr_screen.clip_height_unscaled );
}
gr_screen.save_max_w_unscaled = gr_screen.max_w_unscaled;
gr_screen.save_max_h_unscaled = gr_screen.max_h_unscaled;
gr_screen.save_max_w_unscaled_zoomed = gr_screen.max_w_unscaled_zoomed;
gr_screen.save_max_h_unscaled_zoomed = gr_screen.max_h_unscaled_zoomed;
if (gr_screen.mode == GR_OPENGL) {
extern void opengl_setup_viewport();
@@ -463,7 +629,7 @@ static bool gr_init_sub(int mode, int width, int height, int depth)
gr_screen.custom_size = true;
}
if ( (width >= 1024) && (height >= 600) ) {
if ( (width >= GR_1024_THRESHOLD_WIDTH) && (height >= GR_1024_THRESHOLD_HEIGHT) ) {
res = GR_1024;
} else {
res = GR_640;
@@ -475,6 +641,8 @@ static bool gr_init_sub(int mode, int width, int height, int depth)
mode = GR_OPENGL;
}
Save_custom_screen_size = gr_screen.custom_size;
Gr_save_full_resize_X = Gr_full_resize_X = (float)width / ((res == GR_1024) ? 1024.0f : 640.0f);
Gr_save_full_resize_Y = Gr_full_resize_Y = (float)height / ((res == GR_1024) ? 768.0f : 480.0f);
@@ -493,6 +661,9 @@ static bool gr_init_sub(int mode, int width, int height, int depth)
Gr_save_menu_offset_X = Gr_menu_offset_X = 0.0f;
Gr_save_menu_offset_Y = Gr_menu_offset_Y = 0.0f;
}
Gr_save_menu_zoomed_offset_X = Gr_menu_zoomed_offset_X = Gr_menu_offset_X;
Gr_save_menu_zoomed_offset_Y = Gr_menu_zoomed_offset_Y = Gr_menu_offset_Y;
gr_screen.signature = Gr_signature++;
@@ -505,8 +676,8 @@ static bool gr_init_sub(int mode, int width, int height, int depth)
gr_screen.res = res;
gr_screen.aspect = 1.0f; // Normal PC screen
gr_screen.save_max_w = gr_screen.max_w = gr_screen.max_w_unscaled = width;
gr_screen.save_max_h = gr_screen.max_h = gr_screen.max_h_unscaled = height;
gr_screen.save_max_w = gr_screen.max_w = gr_screen.max_w_unscaled = gr_screen.max_w_unscaled_zoomed = width;
gr_screen.save_max_h = gr_screen.max_h = gr_screen.max_h_unscaled = gr_screen.max_h_unscaled_zoomed = height;
gr_screen.offset_x = gr_screen.offset_x_unscaled = 0;
gr_screen.offset_y = gr_screen.offset_y_unscaled = 0;
@@ -523,13 +694,25 @@ static bool gr_init_sub(int mode, int width, int height, int depth)
if (gr_screen.custom_size) {
gr_unsize_screen_pos( &gr_screen.max_w_unscaled, &gr_screen.max_h_unscaled );
gr_unsize_screen_pos( &gr_screen.max_w_unscaled_zoomed, &gr_screen.max_h_unscaled_zoomed );
gr_unsize_screen_pos( &gr_screen.clip_right_unscaled, &gr_screen.clip_bottom_unscaled );
gr_unsize_screen_pos( &gr_screen.clip_width_unscaled, &gr_screen.clip_height_unscaled );
}
gr_screen.save_max_w_unscaled = gr_screen.max_w_unscaled;
gr_screen.save_max_h_unscaled = gr_screen.max_h_unscaled;
gr_screen.save_max_w_unscaled_zoomed = gr_screen.max_w_unscaled_zoomed;
gr_screen.save_max_h_unscaled_zoomed = gr_screen.max_h_unscaled_zoomed;
#ifdef WIN32
// FRED doesn't need this
if ( !Fred_running && !Is_standalone ) {
// for Windows, we need to do this just before the *_init() calls
extern void win32_create_window(int width, int height);
win32_create_window( width, height );
}
#endif
switch (mode) {
case GR_OPENGL:
rc = gr_opengl_init();
@@ -997,7 +1180,7 @@ void gr_pline_helper(vec3d *out, vec3d *in1, vec3d *in2, int thickness)
* is no more than 90 degrees away from a previous section.
* Moreover, it is _really_ intended for use with 45 degree angles.
*/
void gr_pline_special(vec3d **pts, int num_pts, int thickness,int resize_mode)
void gr_pline_special(SCP_vector<vec3d> *pts, int thickness,int resize_mode)
{
vec3d s1, s2, e1, e2, dir;
vec3d last_e1, last_e2;
@@ -1006,6 +1189,8 @@ void gr_pline_special(vec3d **pts, int num_pts, int thickness,int resize_mode)
int saved_zbuffer_mode, idx;
int started_frame = 0;
int num_pts = pts->size();
// if we have less than 2 pts, bail
if(num_pts < 2) {
return;
@@ -1030,11 +1215,11 @@ void gr_pline_special(vec3d **pts, int num_pts, int thickness,int resize_mode)
int j;
for(idx=0; idx<num_pts-1; idx++) {
// get the start and endpoints
s1 = *pts[idx]; // start 1 (on the line)
gr_pline_helper(&s2, pts[idx], pts[idx+1], thickness); // start 2
e1 = *pts[idx+1]; // end 1 (on the line)
vm_vec_sub(&dir, pts[idx+1], pts[idx]);
vm_vec_add(&e2, &s2, &dir); // end 2
s1 = pts->at(idx); // start 1 (on the line)
e1 = pts->at(idx+1); // end 1 (on the line)
gr_pline_helper(&s2, &s1, &e1, thickness); // start 2
vm_vec_sub(&dir, &e1, &s1);
vm_vec_add(&e2, &s2, &dir); // end 2
// stuff coords
v[0].screen.xyw.x = (float)ceil(s1.xyz.x);
+66 -8
View File
@@ -178,12 +178,63 @@ public:
i_last = j;
}
// Constructor
buffer_data(int n_vrts) :
flags(0), texture(-1), n_verts(n_vrts), index_offset(0),
i_first(1), i_last(0)
{
index = new(std::nothrow) uint[n_verts];
}
// Copy-constructor
buffer_data(const buffer_data& other)
{
index = new(std::nothrow) uint[other.n_verts];
for (size_t i=0; i < (size_t) other.n_verts; i++)
{
index[i] = other.index[i];
}
flags = other.flags;
texture = other.texture;
n_verts = other.n_verts;
i_first = other.i_first;
i_last = other.i_last;
index_offset = other.index_offset;
}
// Copy-assignment operator
buffer_data& operator=(const buffer_data& rhs)
{
if (this != &rhs)
{
delete [] index;
index = new(std::nothrow) uint[rhs.n_verts];
for (size_t i=0; i < (size_t) rhs.n_verts; i++)
{
index[i] = rhs.index[i];
}
flags = rhs.flags;
texture = rhs.texture;
n_verts = rhs.n_verts;
i_first = rhs.i_first;
i_last = rhs.i_last;
index_offset = rhs.index_offset;
}
return *this;
}
// Destructor
~buffer_data()
{
release();
}
private:
uint *index;
@@ -246,9 +297,11 @@ struct light;
typedef struct screen {
uint signature; // changes when mode or palette or width or height changes
int max_w, max_h; // Width and height
int max_w_unscaled, max_h_unscaled; // Width and height, should be 1024x768 or 640x480 in non-standard resolutions
int max_w_unscaled, max_h_unscaled;
int max_w_unscaled_zoomed, max_h_unscaled_zoomed;
int save_max_w, save_max_h; // Width and height
int save_max_w_unscaled, save_max_h_unscaled;
int save_max_w_unscaled_zoomed, save_max_h_unscaled_zoomed;
int res; // GR_640 or GR_1024
int mode; // What mode gr_init was called with.
float aspect, clip_aspect; // Aspect ratio, aspect of clip_width/clip_height
@@ -256,9 +309,9 @@ typedef struct screen {
int bits_per_pixel; // How many bits per pixel it is. (7,8,15,16,24,32)
int bytes_per_pixel; // How many bytes per pixel (1,2,3,4)
int offset_x, offset_y; // The offsets into the screen
int offset_x_unscaled, offset_y_unscaled; // Offsets into the screen, in 1024x768 or 640x480 dimensions
int offset_x_unscaled, offset_y_unscaled; // Offsets into the screen, in unscaled dimensions
int clip_width, clip_height;
int clip_width_unscaled, clip_height_unscaled; // Height and width of clip aread, in 1024x768 or 640x480 dimensions
int clip_width_unscaled, clip_height_unscaled; // Height and width of clip aread, in unscaled dimensions
// center of clip area
float clip_center_x, clip_center_y;
@@ -268,7 +321,7 @@ typedef struct screen {
// actually always 0, but it's nice to have the code work with
// arbitrary clipping regions.
int clip_left, clip_right, clip_top, clip_bottom;
// same as above except in 1024x768 or 640x480 dimensions
// same as above except in unscaled dimensions
int clip_left_unscaled, clip_right_unscaled, clip_top_unscaled, clip_bottom_unscaled;
int current_alphablend_mode; // See GR_ALPHABLEND defines above
@@ -549,6 +602,9 @@ typedef struct screen {
#define GR_640 0 // 640 x 480
#define GR_1024 1 // 1024 x 768
#define GR_1024_THRESHOLD_WIDTH 1024
#define GR_1024_THRESHOLD_HEIGHT 600
extern const char *Resolution_prefixes[GR_NUM_RESOLUTIONS];
extern bool gr_init(int d_mode = GR_DEFAULT, int d_width = GR_DEFAULT, int d_height = GR_DEFAULT, int d_depth = GR_DEFAULT);
@@ -574,10 +630,10 @@ extern screen gr_screen;
#define GR_RESIZE_NONE 0
#define GR_RESIZE_FULL 1
#define GR_RESIZE_MENU 2
#define GR_RESIZE_MENU_NO_OFFSET 3
#define GR_RESIZE_MENU_ZOOMED 3
#define GR_RESIZE_MENU_NO_OFFSET 4
void gr_set_screen_scale(int x, int y);
void gr_set_screen_scale(int x, int y, int max_x, int max_y);
void gr_set_screen_scale(int x, int y, int zoom_x = -1, int zoom_y = -1, int max_x = gr_screen.max_w, int max_y = gr_screen.max_h, bool force_stretch = false);
void gr_reset_screen_scale();
bool gr_unsize_screen_pos(int *x, int *y, int *w = NULL, int *h = NULL, int resize_mode = GR_RESIZE_FULL);
bool gr_resize_screen_pos(int *x, int *y, int *w = NULL, int *h = NULL, int resize_mode = GR_RESIZE_FULL);
@@ -590,6 +646,8 @@ bool gr_resize_screen_posf(float *x, float *y, float *w = NULL, float *h = NULL,
extern void _cdecl gr_printf( int x, int y, const char * format, ... );
// same as gr_printf but positions text correctly in menus
extern void _cdecl gr_printf_menu( int x, int y, const char * format, ... );
// same as gr_printf_menu but accounts for menu zooming
extern void _cdecl gr_printf_menu_zoomed( int x, int y, const char * format, ... );
// same as gr_printf but doesn't resize for non-standard resolutions
extern void _cdecl gr_printf_no_resize( int x, int y, const char * format, ... );
@@ -866,7 +924,7 @@ void gr_opengl_update_texture(int bitmap_handle, int bpp, ubyte* data, int width
// special function for drawing polylines. this function is specifically intended for
// polylines where each section is no more than 90 degrees away from a previous section.
// Moreover, it is _really_ intended for use with 45 degree angles.
void gr_pline_special(vec3d **pts, int num_pts, int thickness,int resize_mode=GR_RESIZE_FULL);
void gr_pline_special(SCP_vector<vec3d> *pts, int thickness,int resize_mode=GR_RESIZE_FULL);
#define VB_FLAG_POSITION (1<<0)
#define VB_FLAG_RHW (1<<1) //incompatable with the next normal
+13
View File
@@ -309,6 +309,19 @@ void _cdecl gr_printf_menu( int x, int y, const char * format, ... )
gr_string(x,y,grx_printf_text,GR_RESIZE_MENU);
}
void _cdecl gr_printf_menu_zoomed( int x, int y, const char * format, ... )
{
va_list args;
if ( !Current_font ) return;
va_start(args, format);
vsprintf(grx_printf_text,format,args);
va_end(args);
gr_string(x,y,grx_printf_text,GR_RESIZE_MENU_ZOOMED);
}
void _cdecl gr_printf_no_resize( int x, int y, const char * format, ... )
{
va_list args;
+1 -1
View File
@@ -581,7 +581,7 @@ void geometry_batcher::render_buffer(int flags)
* Laser batcher
*/
struct batch_item {
batch_item(): texture(-1), tmap_flags(0), alpha(1.0f), laser(false) {};
batch_item(): texture(-1), tmap_flags(0), alpha(1.0f), laser(false) {}
geometry_batcher batch;
+3 -3
View File
@@ -29,7 +29,7 @@ private:
void clone(const geometry_batcher &geo);
public:
geometry_batcher(): n_to_render(0), n_allocated(0), vert(NULL), use_radius(true), radius_list(NULL), buffer_offset(-1) {};
geometry_batcher(): n_to_render(0), n_allocated(0), vert(NULL), use_radius(true), radius_list(NULL), buffer_offset(-1) {}
~geometry_batcher();
geometry_batcher(const geometry_batcher &geo) { clone(geo); }
@@ -69,9 +69,9 @@ public:
void render_buffer(int flags);
// determine if we even need to try and render this (helpful for particle system)
int need_to_render() { return n_to_render; };
int need_to_render() { return n_to_render; }
void operator =(int){};
void operator =(int){}
};
+51 -47
View File
@@ -22,6 +22,7 @@
#include "io/timer.h"
#include "ddsutils/ddsutils.h"
#include "model/model.h"
#include "debugconsole/console.h"
#include "debugconsole/timerbar.h"
#include "graphics/gropenglbmpman.h"
#include "graphics/gropengllight.h"
@@ -490,27 +491,25 @@ void gr_opengl_fog_set(int fog_mode, int r, int g, int b, float fog_near, float
return;
}
if (gr_screen.current_fog_mode != fog_mode) {
if (OGL_fogmode == 3) {
glFogf(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV);
glFogf(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH);
}
// Um.. this is not the correct way to fog in software, probably doesn't matter though
else if ( (OGL_fogmode == 2) && Cmdline_nohtl ) {
glFogf(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
fog_near *= fog_near; // it's faster this way
fog_far *= fog_far;
} else {
glFogf(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH);
}
GL_state.Fog(GL_TRUE);
glFogf(GL_FOG_MODE, GL_LINEAR);
glFogf(GL_FOG_START, fog_near);
glFogf(GL_FOG_END, fog_far);
gr_screen.current_fog_mode = fog_mode;
if (OGL_fogmode == 3) {
glFogf(GL_FOG_DISTANCE_MODE_NV, GL_EYE_RADIAL_NV);
glFogf(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH);
}
// Um.. this is not the correct way to fog in software, probably doesn't matter though
else if ( (OGL_fogmode == 2) && Cmdline_nohtl ) {
glFogf(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);
fog_near *= fog_near; // it's faster this way
fog_far *= fog_far;
} else {
glFogf(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH);
}
GL_state.Fog(GL_TRUE);
glFogf(GL_FOG_MODE, GL_LINEAR);
glFogf(GL_FOG_START, fog_near);
glFogf(GL_FOG_END, fog_far);
gr_screen.current_fog_mode = fog_mode;
if ( (gr_screen.current_fog_color.red != r) ||
(gr_screen.current_fog_color.green != g) ||
@@ -1683,56 +1682,61 @@ bool gr_opengl_init()
DCF(ogl_minimize, "Minimizes opengl")
{
bool minimize_ogl = false;
if ( gr_screen.mode != GR_OPENGL ) {
dc_printf("Command only available in OpenGL mode.\n");
return;
}
if (Dc_command) {
dc_get_arg(ARG_TRUE);
if ( Dc_arg_type & ARG_TRUE ) {
opengl_minimize();
}
if (dc_optional_string_either("help", "--help")) {
dc_printf("[bool] If true is passed, then the OpenGL window will minimize.\n");
return;
}
dc_stuff_boolean(&minimize_ogl);
if (Dc_help)
dc_printf("If set to true then the OpenGL window will minimize.\n");
if (minimize_ogl) {
opengl_minimize();
}
}
DCF(ogl_anisotropy, "toggles anisotropic filtering")
{
bool process = true;
int value;
if ( gr_screen.mode != GR_OPENGL ) {
dc_printf("Can only set anisotropic filter in OpenGL mode.\n");
return;
}
if ( Dc_command && !Is_Extension_Enabled(OGL_EXT_TEXTURE_FILTER_ANISOTROPIC) ) {
if (dc_optional_string_either("help", "--help")) {
dc_printf("Sets OpenGL anisotropic filtering level.\n");
dc_printf("GL_anisotropy [int] Valid values are 0 to %i. 0 turns off anisotropic filtering.\n", (int)opengl_get_max_anisotropy());
process = false;
}
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf("Current anisotropic filter value is %i\n", (int)GL_anisotropy);
process = false;
}
if (!process) {
return;
}
if ( !Is_Extension_Enabled(OGL_EXT_TEXTURE_FILTER_ANISOTROPIC) ) {
dc_printf("Error: Anisotropic filter is not settable!\n");
return;
}
if ( Dc_command ) {
dc_get_arg(ARG_INT | ARG_NONE);
if ( Dc_arg_type & ARG_NONE ) {
if (!dc_maybe_stuff_int(&value)) {
// No arg passed, set to default
GL_anisotropy = 1.0f;
// opengl_set_anisotropy();
dc_printf("Anisotropic filter value reset to default level.\n");
}
if ( Dc_arg_type & ARG_INT ) {
GL_anisotropy = (GLfloat)Dc_arg_float;
} else {
GL_anisotropy = (GLfloat)value;
// opengl_set_anisotropy( (float)Dc_arg_float );
}
}
if ( Dc_status ) {
dc_printf("Current anisotropic filter value is %i\n", (int)GL_anisotropy);
}
if (Dc_help) {
dc_printf("Sets OpenGL anisotropic filtering level.\n");
dc_printf("Valid values are 1 to %i, or 0 to turn off.\n", (int)opengl_get_max_anisotropy());
}
}
+1 -1
View File
@@ -2110,7 +2110,7 @@ void gr_opengl_bitmap_ex(int x, int y, int w, int h, int sx, int sy, int resize_
}
if ( dy1 < clip_top ) {
sy += clip_top-dx1;
sy += clip_top-dy1;
dy1 = clip_top;
}
+1 -1
View File
@@ -416,7 +416,7 @@ void opengl_extensions_init()
Use_GLSL = 0;
mprintf((" OpenGL Shading Language version %s is not sufficient to use GLSL mode in FSO. Defaulting to fixed-function renderer.\n", glGetString(GL_SHADING_LANGUAGE_VERSION_ARB) ));
#ifdef NDEBUG
popup(0, 1, POPUP_OK, "GLSL support not available on this GPU. Disabling shader support and defaulting to fixed-function rendering.\n");
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, "GLSL support not available on this GPU. Disabling shader support and defaulting to fixed-function rendering.\n");
#endif
}
}
+7
View File
@@ -407,6 +407,7 @@ void gr_opengl_set_center_alpha(int type)
glight.Ambient[1] = 0.0f;
glight.Ambient[2] = 0.0f;
}
glight.type = type;
glight.Specular[0] = 0.0f;
glight.Specular[1] = 0.0f;
@@ -422,9 +423,15 @@ void gr_opengl_set_center_alpha(int type)
glight.Position[3] = 0.0f;
// defaults
glight.SpotDir[0] = 0.0f;
glight.SpotDir[1] = 0.0f;
glight.SpotDir[2] = -1.0f;
glight.SpotExp = Cmdline_ogl_spec * 0.5f;
glight.SpotCutOff = 180.0f;
glight.ConstantAtten = 1.0f;
glight.LinearAtten = 0.0f;
glight.QuadraticAtten = 0.0f;
glight.occupied = false;
// first light
memcpy( &opengl_lights[Num_active_gl_lights], &glight, sizeof(opengl_light) );
-1
View File
@@ -35,7 +35,6 @@ struct opengl_light
float ConstantAtten, LinearAtten, QuadraticAtten;
bool occupied;
int priority;
int type;
};
+5 -5
View File
@@ -109,11 +109,11 @@ struct bitmap_2d_list{
//from 0,0 in the upper left to 1,1 in the lowwer right
//out of range values are valid
struct texture_rect_list{
texture_rect_list(float X=0, float Y=0, float W=1.0f, float H=1.0f):x(X),y(Y),w(W),h(H){}
float x;
float y;
float w;
float h;
texture_rect_list(float u0In=0.0f, float v0In=0.0f, float u1In=1.0f, float v1In=1.0f):u0(u0In),v0(v0In),u1(u1In),v1(v1In){}
float u0;
float v0;
float u1;
float v1;
};
struct bitmap_rect_list{
+14 -14
View File
@@ -398,10 +398,10 @@ disabled_views(VM_EXTERNAL | VM_DEAD_VIEW | VM_WARP_CHASE | VM_PADLOCK_ANY), cus
}
}
HudGauge::~HudGauge() {};
void HudGauge::initPosition(int x, int y)
{
Assert(x >= 0 && y >= 0);
position[0] = x;
position[1] = y;
}
@@ -713,7 +713,7 @@ void HudGauge::renderString(int x, int y, const char *str)
int nx = 0, ny = 0;
if ( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
} else {
if ( reticle_follow ) {
nx = HUD_nose_x;
@@ -736,7 +736,7 @@ void HudGauge::renderString(int x, int y, int gauge_id, const char *str)
int nx = 0, ny = 0;
if ( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
} else {
if ( reticle_follow ) {
nx = HUD_nose_x;
@@ -804,7 +804,7 @@ void HudGauge::renderBitmapColor(int frame, int x, int y)
emp_hud_jitter(&x, &y);
if ( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
} else {
if ( reticle_follow ) {
nx = HUD_nose_x;
@@ -834,7 +834,7 @@ void HudGauge::renderBitmap(int x, int y)
emp_hud_jitter(&x, &y);
if ( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
} else {
if ( reticle_follow ) {
nx = HUD_nose_x;
@@ -872,7 +872,7 @@ void HudGauge::renderBitmapEx(int frame, int x, int y, int w, int h, int sx, int
gr_set_bitmap(frame);
if( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
} else {
if ( reticle_follow ) {
nx = HUD_nose_x;
@@ -896,7 +896,7 @@ void HudGauge::renderLine(int x1, int y1, int x2, int y2)
int nx = 0, ny = 0;
if ( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
} else {
if ( reticle_follow ) {
nx = HUD_nose_x;
@@ -919,7 +919,7 @@ void HudGauge::renderGradientLine(int x1, int y1, int x2, int y2)
int nx = 0, ny = 0;
if ( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
} else {
if(reticle_follow) {
nx = HUD_nose_x;
@@ -942,7 +942,7 @@ void HudGauge::renderRect(int x, int y, int w, int h)
int nx = 0, ny = 0;
if ( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
} else {
if ( reticle_follow ) {
nx = HUD_nose_x;
@@ -965,7 +965,7 @@ void HudGauge::renderCircle(int x, int y, int diameter)
int nx = 0, ny = 0;
if ( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
} else {
if ( reticle_follow ) {
nx = HUD_nose_x;
@@ -989,7 +989,7 @@ void HudGauge::setClip(int x, int y, int w, int h)
int hy = fl2i(HUD_offset_y);
if ( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
hx = display_offset_x;
hy = display_offset_y;
@@ -1025,7 +1025,7 @@ void HudGauge::resetClip()
int w, h;
if ( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
hx = display_offset_x;
hy = display_offset_y;
@@ -1583,7 +1583,7 @@ void hud_update_frame(float frametime)
}
// Make sure that the player isn't targeting a 3rd stage local ssm
if (Objects[Player_ai->target_objnum].type == OBJ_WEAPON)
if (Player_ai->target_objnum >= 0 && Objects[Player_ai->target_objnum].type == OBJ_WEAPON)
{
if (Weapons[Objects[Player_ai->target_objnum].instance].lssm_stage==3)
{
+1
View File
@@ -247,6 +247,7 @@ public:
HudGauge(int _gauge_object, int _gauge_config, bool _slew, bool _message, int _disabled_views, int r, int g, int b);
// constructor for custom gauges
HudGauge(int _gauge_config, bool _slew, int r, int g, int b, char* _custom_name, char* _custom_text, char* frame_fname, int txtoffset_x, int txtoffset_y);
virtual ~HudGauge();
void initPosition(int x, int y);
void initBaseResolution(int w, int h);
+2 -1
View File
@@ -26,6 +26,7 @@
#include "mission/missionparse.h"
#include "iff_defs/iff_defs.h"
#include "network/multi.h"
#include "debugconsole/console.h"
vec3d lock_world_pos;
@@ -333,7 +334,7 @@ int hud_lock_has_homing_point()
}
int Nebula_sec_range = 0;
DCF_BOOL(nebula_sec_range, Nebula_sec_range)
DCF_BOOL(nebula_sec_range, Nebula_sec_range);
int hud_lock_world_pos_in_range(vec3d *target_world_pos, vec3d *vec_to_target)
{
+2
View File
@@ -35,6 +35,8 @@ void hud_draw_navigation()
vec3d *target_pos = Navs[CurrentNav].GetPosition();
color NavColor;
memset(&target_point, 0, sizeof(target_point));
unsigned int alpha = HUD_COLOR_ALPHA_MAX * 16;
-7
View File
@@ -174,12 +174,8 @@ void parse_hud_gauges_tbl(const char *filename)
color *ship_clr_p = NULL;
bool scale_gauge = true;
// open localization
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0) {
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", filename, rval));
lcl_ext_close();
return;
}
@@ -455,9 +451,6 @@ void parse_hud_gauges_tbl(const char *filename)
required_string("$End Gauges");
required_string("#End");
}
// close localization
lcl_ext_close();
}
void hud_positions_init()
+1 -1
View File
@@ -855,7 +855,7 @@ void HudGaugeShield::renderShieldIcon(coord2d coords[6])
int nx = 0, ny = 0, i;
if ( gr_screen.rendering_to_texture != -1 ) {
gr_set_screen_scale(canvas_w, canvas_h, target_w, target_h);
gr_set_screen_scale(canvas_w, canvas_h, -1, -1, target_w, target_h, true);
} else {
if ( reticle_follow ) {
nx = HUD_nose_x;
+1 -1
View File
@@ -112,7 +112,7 @@ typedef struct squadmsg_history {
int order_from; // ship that sent the order
int special_index; // any extra data the order might need (subsystem names for instance)
fix order_time; // when this order was sent (or received by the server in multiplayer)
squadmsg_history(): order_to(-1), order(-1), target(-1), order_from(-1), special_index(-1), order_time(0) {};
squadmsg_history(): order_to(-1), order(-1), target(-1), order_from(-1), special_index(-1), order_time(0) {}
} squadmsg_history;
extern SCP_vector<squadmsg_history> Squadmsg_history;
+8 -4
View File
@@ -2722,8 +2722,6 @@ void hud_target_subsystem_in_reticle()
if ( best_dot > MIN_DOT_FOR_TARGET )
nearest_subsys = subsys;
}
Assert(best_dot <= 1.0f);
} // end for
if ( nearest_subsys != NULL ) {
@@ -2830,7 +2828,7 @@ void hud_tri(float x1,float y1,float x2,float y2,float x3,float y3)
// zero verts[] out, this is a faster way (nods to Kazan) to make sure that
// the specular colors are set to 0 to avoid rendering problems - taylor
memset(verts, 0, sizeof(vertex)*3);
memset(verts, 0, sizeof(verts));
for (i=0; i<3; i++ )
vertlist[i] = &verts[i];
@@ -3230,6 +3228,8 @@ void hud_process_remote_detonate_missile()
missile_obj *mo;
object *mobjp;
vertex target_point;
memset(&target_point, 0, sizeof(target_point));
// check for currently locked missiles (highest precedence)
for ( mo = GET_FIRST(&Missile_obj_list); mo != END_OF_LIST(&Missile_obj_list); mo = GET_NEXT(mo) ) {
@@ -3301,6 +3301,8 @@ void hud_show_message_sender()
Message_shipnum = -1;
return;
}
memset(&target_point, 0, sizeof(target_point));
// find the current target vertex
g3_rotate_vertex(&target_point, &targetp->pos);
@@ -3404,6 +3406,8 @@ void hud_show_selection_set()
Players[Player_num].current_hotkey_set = -1;
return;
}
memset(&target_point, 0, sizeof(target_point));
for ( hitem = GET_FIRST(plist); hitem != END_OF_LIST(plist); hitem = GET_NEXT(hitem) ) {
targetp = hitem->objp;
@@ -7217,7 +7221,7 @@ void HudGaugeHardpoints::render(float frametime)
//primary weapons
if ( draw_primary_models ) {
for ( i = 0; i < swp->num_primary_banks; i++ ) {
w_bank *bank = &model_get(sip->model_num)->gun_banks[i];
bank = &model_get(sip->model_num)->gun_banks[i];
for ( k = 0; k < bank->num_slots; k++ ) {
if ( ( Weapon_info[swp->primary_bank_weapons[i]].external_model_num == -1 || !sip->draw_primary_models[i] ) ) {
-1
View File
@@ -84,7 +84,6 @@ class HudGaugeTargetBox: public HudGauge // HUD_TARGET_MONITOR
// first element is time flashing expires, second element is time of next flash
int Next_flash_timers[NUM_TBOX_FLASH_TIMERS];
int Last_ts;
int flash_flags;
public:
HudGaugeTargetBox();
+7 -1
View File
@@ -93,6 +93,7 @@ CFtpGet::CFtpGet(char *URL, char *localfile, char *Username, char *Password)
}
else
{
memset(&listensockaddr, 0, sizeof(SOCKADDR_IN));
listensockaddr.sin_family = AF_INET;
listensockaddr.sin_port = 0;
listensockaddr.sin_addr.s_addr = INADDR_ANY;
@@ -186,6 +187,8 @@ CFtpGet::~CFtpGet()
{
if (thread_id)
SDL_WaitThread(thread_id, NULL);
fclose(LOCALFILE);
if(m_ListenSock != INVALID_SOCKET)
{
@@ -392,8 +395,11 @@ int CFtpGet::ConnectControlSocket()
//m_ControlSock
if(m_Aborting)
return 0;
se = getservbyname("ftp", NULL);
memset(&hostaddr, 0, sizeof(SOCKADDR_IN));
se = getservbyname("ftp", NULL);
if(se == NULL)
{
hostaddr.sin_port = htons(21);
+2
View File
@@ -169,6 +169,8 @@ ChttpGet::~ChttpGet()
if (thread_id)
SDL_WaitThread(thread_id, NULL);
fclose(LOCALFILE);
if (m_DataSock != INVALID_SOCKET) {
shutdown(m_DataSock, 2);
closesocket(m_DataSock);
+3 -2
View File
@@ -74,7 +74,7 @@ class factor_table
{
public:
factor_table();
~factor_table(){ delete[] table; };
~factor_table(){ delete[] table; }
int getNextSlots( int slots_on_ship, int cur_slots );
private:
@@ -636,6 +636,7 @@ void process_debug_keys(int k)
switch (k) {
case KEY_DEBUGGED + KEY_Q:
case KEY_DEBUGGED1 + KEY_Q:
Snapshot_all_events = true;
break;
@@ -2500,7 +2501,7 @@ int button_function(int n)
control_used(n);
if ( hud_sensors_ok(Player_ship) ) {
int keyHasBeenUsed = TRUE;
keyHasBeenUsed = TRUE;
switch(n) {
// target next
case TARGET_NEXT:
+12 -1
View File
@@ -909,7 +909,7 @@ void labviewer_render_model(float frametime)
//render weapon models if selected
if (Lab_mode == LAB_MODE_SHIP && (Lab_viewer_flags & LAB_FLAG_SHOW_WEAPONS)) {
int j,k,l;
int k,l;
g3_start_instance_matrix(&vmd_zero_vector, &Lab_viewer_orient, true);
l = 0;
@@ -2116,6 +2116,14 @@ void labviewer_show_tech_model(Tree *caller)
labviewer_change_model(Weapon_info[weap_index].tech_model, caller->GetSelectedItem()->GetData(), weap_index);
}
void labviewer_show_external_model(Tree *caller)
{
int weap_index = (int)(caller->GetSelectedItem()->GetParentItem()->GetData());
Assert( weap_index >= 0 );
labviewer_change_model(Weapon_info[weap_index].external_model_name, caller->GetSelectedItem()->GetData(), weap_index);
}
extern void weapon_load_bitmaps(int weapon_index);
void labviewer_change_weapon(Tree *caller)
{
@@ -2215,6 +2223,9 @@ void labviewer_make_weap_window(Button* caller)
if (Weapon_info[i].tech_model[0] != '\0') {
cmp->AddItem(cwip, "Tech Model", 0, false, labviewer_show_tech_model);
}
if (Weapon_info[i].external_model_name[0] != '\0') {
cmp->AddItem(cwip, "External Model", 0, false, labviewer_show_external_model);
}
}
// Get rid of any empty nodes
-7
View File
@@ -149,12 +149,8 @@ void GUISystem::ParseClassInfo(char* filename)
DestroyClassInfo();
}
// open localization
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0) {
mprintf(("WMCGUI: Unable to parse '%s'! Error code = %i.\n", filename, rval));
lcl_ext_close();
return;
}
@@ -171,9 +167,6 @@ void GUISystem::ParseClassInfo(char* filename)
}
} while(flag);
// close localization
lcl_ext_close();
ClassInfoParsed = true;
}
-3
View File
@@ -306,8 +306,6 @@ private:
GUISystem* OwnerSystem;
bool Active; //Is this screen active?
ScreenClassInfoEntry* ScreenClassInfo;
GUIObject Guiobjects;
SCP_vector<GUIObject*> DeletionCache;
@@ -513,7 +511,6 @@ class Tree : public GUIObject
TreeItem Items;
void *AssociatedItem;
int StartLine;
TreeItem *SelectedItem;
TreeItem *HighlightedItem;
+63 -51
View File
@@ -15,6 +15,7 @@
#include "globalincs/systemvars.h"
#include "graphics/2d.h"
#include "cmdline/cmdline.h"
#include "debugconsole/console.h"
@@ -62,52 +63,11 @@ int Lighting_flag = 1;
DCF(light,"Changes lighting parameters")
{
if ( Dc_command ) {
dc_get_arg(ARG_STRING);
if ( !strcmp( Dc_arg, "ambient" )) {
dc_get_arg(ARG_FLOAT);
if ( (Dc_arg_float < 0.0f) || (Dc_arg_float > 1.0f) ) {
Dc_help = 1;
} else {
Ambient_light = Dc_arg_float;
}
} else if ( !strcmp( Dc_arg, "reflect" )) {
dc_get_arg(ARG_FLOAT);
if ( (Dc_arg_float < 0.0f) || (Dc_arg_float > 1.0f) ) {
Dc_help = 1;
} else {
Reflective_light = Dc_arg_float;
}
} else if ( !strcmp( Dc_arg, "default" )) {
Lighting_mode = LM_BRIGHTEN;
Ambient_light = AMBIENT_LIGHT_DEFAULT;
Reflective_light = REFLECTIVE_LIGHT_DEFAULT;
Lighting_flag = 0;
} else if ( !strcmp( Dc_arg, "mode" )) {
dc_get_arg(ARG_STRING);
if ( !strcmp(Dc_arg, "light") ) {
Lighting_mode = LM_BRIGHTEN;
} else if ( !strcmp(Dc_arg, "darken")) {
Lighting_mode = LM_DARKEN;
} else {
Dc_help = 1;
}
} else if ( !strcmp( Dc_arg, "dynamic" )) {
dc_get_arg(ARG_TRUE|ARG_FALSE|ARG_NONE);
if ( Dc_arg_type & ARG_TRUE ) Lighting_flag = 1;
else if ( Dc_arg_type & ARG_FALSE ) Lighting_flag = 0;
else if ( Dc_arg_type & ARG_NONE ) Lighting_flag ^= 1;
} else if ( !strcmp( Dc_arg, "on" ) ) {
Lighting_off = 0;
} else if ( !strcmp( Dc_arg, "off" ) ) {
Lighting_off = 1;
} else {
// print usage, not stats
Dc_help = 1;
}
}
SCP_string arg_str;
float val_f;
bool val_b;
if ( Dc_help ) {
if (dc_optional_string_either("help", "--help")) {
dc_printf( "Usage: light keyword\nWhere keyword can be in the following forms:\n" );
dc_printf( "light on|off Turns all lighting on/off\n" );
dc_printf( "light default Resets lighting to all default values\n" );
@@ -117,18 +77,70 @@ DCF(light,"Changes lighting parameters")
dc_printf( "light mode [light|darken] Changes the lighting mode.\n" );
dc_printf( " Where 'light' means the global light adds light.\n");
dc_printf( " and 'darken' means the global light subtracts light.\n");
Dc_status = 0; // don't print status if help is printed. Too messy.
return;
}
if ( Dc_status ) {
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf( "Ambient light is set to %.2f\n", Ambient_light );
dc_printf( "Reflective light is set to %.2f\n", Reflective_light );
dc_printf( "Dynamic lighting is: %s\n", (Lighting_flag?"on":"off") );
switch( Lighting_mode ) {
case LM_BRIGHTEN: dc_printf( "Lighting mode is: light\n" ); break;
case LM_DARKEN: dc_printf( "Lighting mode is: darken\n" ); break;
default: dc_printf( "Lighting mode is: UNKNOWN\n" ); break;
switch( Lighting_mode ) {
case LM_BRIGHTEN:
dc_printf( "Lighting mode is: light\n" );
break;
case LM_DARKEN:
dc_printf( "Lighting mode is: darken\n" );
break;
default:
dc_printf( "Lighting mode is: UNKNOWN\n" );
}
return;
}
if (dc_optional_string("ambient")) {
dc_stuff_float(&val_f);
if ((val_f < 0.0f) || (val_f > 1.0f)) {
dc_printf(" Error: ambient value must be between 0.0 and 1.0\n");
} else {
Ambient_light = val_f;
}
} else if (dc_optional_string("reflect")) {
dc_stuff_float(&val_f);
if ( (val_f < 0.0f) || (val_f > 1.0f)) {
dc_printf(" Error: reflect value mus be between 0.0 and 1.0\n");
} else {
Reflective_light = val_f;
}
} else if (dc_optional_string("default")) {
Lighting_mode = LM_BRIGHTEN;
Ambient_light = AMBIENT_LIGHT_DEFAULT;
Reflective_light = REFLECTIVE_LIGHT_DEFAULT;
Lighting_flag = 0;
} else if (dc_optional_string("mode")) {
dc_stuff_string_white(arg_str);
if (arg_str == "light") {
Lighting_mode = LM_BRIGHTEN;
} else if (arg_str == "darken") {
Lighting_mode = LM_DARKEN;
} else {
dc_printf(" Error: unknown light mode: '%s'\n", arg_str.c_str());
}
} else if (dc_optional_string("dynamic")) {
dc_stuff_boolean(&val_b);
Lighting_flag = val_b;
} else if(dc_maybe_stuff_boolean(&Lighting_off)) {
Lighting_off = !Lighting_off;
} else {
dc_stuff_string_white(arg_str);
dc_printf("Error: Unknown argument '%s'\n", arg_str.c_str());
}
}
+138 -563
View File
@@ -58,7 +58,7 @@ int Lcl_english = 1;
// the english version (in the code) to a foreign version (in the table). Thus, if you
// add a new string to the code, you must assign it a new index. Use the number below for
// that index and increase the number below by one.
#define XSTR_SIZE 1636
#define XSTR_SIZE 1638
// struct to allow for strings.tbl-determined x offset
@@ -75,45 +75,16 @@ int Xstr_inited = 0;
// table/mission externalization stuff --------------------
#define TABLE_STRING_FILENAME "tstrings.tbl"
// filename of the file to use when localizing table strings
char *Lcl_ext_filename = NULL;
CFILE *Lcl_ext_file = NULL;
// for scanning/parsing tstrings.tbl (from ExStr)
#define PARSE_TEXT_BUF_SIZE PARSE_BUF_SIZE
#define PARSE_ID_BUF_SIZE 5
#define TS_SCANNING 0 // scanning for a line of text
#define TS_ID_STRING 1 // reading in an id string
#define TS_OPEN_QUOTE 2 // looking for an open quote
#define TS_STRING 3 // reading in the text string itself
int Ts_current_state = 0;
char Ts_text[PARSE_TEXT_BUF_SIZE]; // string we're currently working with
char Ts_id_text[PARSE_ID_BUF_SIZE]; // id string we're currently working with
size_t Ts_text_size;
size_t Ts_id_text_size;
// file pointers for optimized string lookups
// some example times for FreeSpace2 startup with granularities (mostly .tbl files, ~500 strings in the table file, many looked up more than once)
// granularity 20 : 13 secs
// granularity 10 : 11 secs
// granularity 5 : 9 secs
// granularity 2 : 7-8 secs
#define LCL_GRANULARITY 1 // how many strings between each pointer (lower granularities should give faster lookup times)
#define LCL_MAX_POINTERS 4500 // max # of pointers
#define LCL_MAX_STRINGS (LCL_GRANULARITY * LCL_MAX_POINTERS)
int Lcl_pointers[LCL_MAX_POINTERS];
int Lcl_pointer_count = 0;
#define LCL_MAX_STRINGS 4500
char *Lcl_ext_str[LCL_MAX_STRINGS];
// ------------------------------------------------------------------------------------------------------------
// LOCALIZE FORWARD DECLARATIONS
//
// associate table file externalization with the specified input file
void lcl_ext_associate(const char *filename);
// given a valid XSTR() tag piece of text, extract the string portion, return it in out, nonzero on success
int lcl_ext_get_text(const char *xstr, char *out);
int lcl_ext_get_text(const SCP_string &xstr, SCP_string &out);
@@ -122,23 +93,9 @@ int lcl_ext_get_text(const SCP_string &xstr, SCP_string &out);
int lcl_ext_get_id(const char *xstr, int *out);
int lcl_ext_get_id(const SCP_string &xstr, int *out);
// given a valid XSTR() id#, lookup the string in tstrings.tbl, filling in out if found, nonzero on success
int lcl_ext_lookup(char *out, int id);
// if the char is a valid char for a signed integer value string
int lcl_is_valid_numeric_char(char c);
// sub-parse function for individual lines of tstrings.tbl (from Exstr)
// returns : integer with the low bits having the following values :
// 0 on fail, 1 on success, 2 if found a matching id/string pair, 3 if end of language has been found
// for cases 1 and 2 : the high bit (1<<31) will be set if the parser detected the beginning of a new string id on this line
// so be sure to mask this value out to get the low portion of the return value
//
int lcl_ext_lookup_sub(const char *text, char *out, int id);
// initialize the pointer array into tstrings.tbl (call from lcl_ext_open() ONLY)
void lcl_ext_setup_pointers();
// parses the string.tbl and reports back only on the languages it found
void parse_stringstbl_quick(const char *filename);
@@ -211,24 +168,8 @@ void lcl_init(int lang_init)
lang = lang_init;
}
// language markers
Lcl_pointer_count = 0;
// associate the table string file
lcl_ext_associate(TABLE_STRING_FILENAME);
// set the language (this function takes care of setting up file pointers)
lcl_set_language(lang);
}
// added 2.2.99 by NeilK to take care of fs2 launcher memory leaks
// shutdown localization
void lcl_close()
{
// if the filename exists, free it up
if(Lcl_ext_filename != NULL){
vm_free(Lcl_ext_filename);
}
lcl_set_language(lang);
}
// determine what language we're running in, see LCL_* defines above
@@ -244,18 +185,15 @@ void parse_stringstbl_quick(const char *filename)
int lang_idx;
int i;
// make sure localization is NOT running
lcl_ext_close();
read_file_text(filename, CF_TYPE_TABLES);
reset_parse();
if (optional_string("#Supported Languages")) {
while (required_string_either("#End","$Language:")) {
required_string("$Language:");
stuff_string(language.lang_name, F_NAME, LCL_LANG_NAME_LEN + 1);
stuff_string(language.lang_name, F_RAW, LCL_LANG_NAME_LEN + 1);
required_string("+Extension:");
stuff_string(language.lang_ext, F_NAME, LCL_LANG_NAME_LEN + 1);
stuff_string(language.lang_ext, F_RAW, LCL_LANG_NAME_LEN + 1);
required_string("+Special Character Index:");
stuff_ubyte(&language.special_char_indexes[0]);
for (i = 1; i < MAX_FONTS; ++i) {
@@ -288,7 +226,9 @@ void parse_stringstbl_quick(const char *filename)
}
}
void parse_stringstbl(const char *filename)
// Unified function for loading strings.tbl and tstrings.tbl (and their modular versions).
// The "external" parameter controls which format to load: true for tstrings.tbl, false for strings.tbl
void parse_stringstbl_common(const char *filename, const bool external)
{
char chr, buf[4096];
char language_tag[512];
@@ -296,16 +236,17 @@ void parse_stringstbl(const char *filename)
char *p_offset = NULL;
int offset_lo = 0, offset_hi = 0;
// make sure localization is NOT running
lcl_ext_close();
read_file_text(filename, CF_TYPE_TABLES);
reset_parse();
// move down to the proper section
memset(language_tag, 0, sizeof(language_tag));
strcpy_s(language_tag, "#");
strcat_s(language_tag, Lcl_languages[Lcl_current_lang].lang_name);
if (external && Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE){
strcat_s(language_tag, "default");
} else {
strcat_s(language_tag, Lcl_languages[Lcl_current_lang].lang_name);
}
if ( skip_to_string(language_tag) != 1 ) {
mprintf(("Current language not found in %s\n", filename));
@@ -317,44 +258,41 @@ void parse_stringstbl(const char *filename)
int num_offsets_on_this_line = 0;
stuff_int(&index);
stuff_string(buf, F_NAME, sizeof(buf));
if (external) {
ignore_white_space();
get_string(buf, sizeof(buf));
drop_trailing_white_space(buf);
} else {
stuff_string(buf, F_RAW, sizeof(buf));
}
if (index < 0 || index >= XSTR_SIZE) {
if (external && (index < 0 || index >= LCL_MAX_STRINGS)) {
Error(LOCATION, "Invalid tstrings table index specified (%i). Please increment LCL_MAX_STRINGS in localize.cpp.", index);
} else if (!external && (index < 0 || index >= XSTR_SIZE)) {
Error(LOCATION, "Invalid strings table index specified (%i)", index);
}
if (Lcl_pl)
lcl_fix_polish(buf);
if (!external) {
i = strlen(buf);
i = strlen(buf);
while (i--) {
if ( !isspace(buf[i]) )
break;
}
// trim unneccesary end of string
if (i >= 0) {
// Assert(buf[i] == '"');
if (buf[i] != '"') {
// probably an offset on this entry
// drop down a null terminator (prolly unnecessary)
buf[i+1] = 0;
// back up over the potential offset
while ( !is_white_space(buf[i]) )
i--;
// now back up over intervening spaces
while ( is_white_space(buf[i]) )
i--;
num_offsets_on_this_line = 1;
while (i--) {
if ( !isspace(buf[i]) )
break;
}
// trim unnecessary end of string
if (i >= 0) {
// Assert(buf[i] == '"');
if (buf[i] != '"') {
// could have a 2nd offset value (one for 640, one for 1024)
// so back up again
// probably an offset on this entry
// drop down a null terminator (prolly unnecessary)
buf[i+1] = 0;
// back up over the potential offset
while ( !is_white_space(buf[i]) )
i--;
@@ -362,48 +300,79 @@ void parse_stringstbl(const char *filename)
while ( is_white_space(buf[i]) )
i--;
num_offsets_on_this_line = 2;
num_offsets_on_this_line = 1;
if (buf[i] != '"') {
// could have a 2nd offset value (one for 640, one for 1024)
// so back up again
while ( !is_white_space(buf[i]) )
i--;
// now back up over intervening spaces
while ( is_white_space(buf[i]) )
i--;
num_offsets_on_this_line = 2;
}
p_offset = &buf[i+1]; // get ptr to string section with offset in it
if (buf[i] != '"')
Error(LOCATION, "%s is corrupt", filename); // now its an error
}
p_offset = &buf[i+1]; // get ptr to string section with offset in it
if (buf[i] != '"')
Error(LOCATION, "%s is corrupt", filename); // now its an error
buf[i] = 0;
}
buf[i] = 0;
}
// copy string into buf
z = 0;
for (i = 1; buf[i]; i++) {
chr = buf[i];
// copy string into buf
z = 0;
for (i = 1; buf[i]; i++) {
chr = buf[i];
if (chr == '\\') {
chr = buf[++i];
if (chr == '\\') {
chr = buf[++i];
if (chr == 'n')
chr = '\n';
else if (chr == 'r')
chr = '\r';
}
if (chr == 'n')
chr = '\n';
else if (chr == 'r')
chr = '\r';
buf[z++] = chr;
}
buf[z++] = chr;
// null terminator on buf
buf[z] = 0;
}
// null terminator on buf
buf[z] = 0;
// write into Xstr_table
if ( Parsing_modular_table && (Xstr_table[index].str != NULL) ) {
vm_free((void *) Xstr_table[index].str);
Xstr_table[index].str = NULL;
// write into Xstr_table (for strings.tbl) or Lcl_ext_str (for tstrings.tbl)
if (Parsing_modular_table) {
if ( external && (Lcl_ext_str[index] != NULL) ) {
vm_free((void *) Lcl_ext_str[index]);
Lcl_ext_str[index] = NULL;
} else if ( !external && (Xstr_table[index].str != NULL) ) {
vm_free((void *) Xstr_table[index].str);
Xstr_table[index].str = NULL;
}
}
if (Xstr_table[index].str != NULL)
if (external && (Lcl_ext_str[index] != NULL)) {
Warning(LOCATION, "Tstrings table index %d used more than once", index);
} else if (!external && (Xstr_table[index].str != NULL)) {
Warning(LOCATION, "Strings table index %d used more than once", index);
}
Xstr_table[index].str = vm_strdup(buf);
if (external) {
Lcl_ext_str[index] = vm_strdup(buf);
} else {
Xstr_table[index].str = vm_strdup(buf);
}
// the rest of this loop applies only to strings.tbl,
// so we can move on to the next line if we're reading from tstrings.tbl
if (external) {
continue;
}
// read offset information, assume 0 if nonexistant
if (p_offset != NULL) {
@@ -427,14 +396,29 @@ void parse_stringstbl(const char *filename)
}
}
void parse_stringstbl(const char *filename)
{
parse_stringstbl_common(filename, false);
}
void parse_tstringstbl(const char *filename)
{
parse_stringstbl_common(filename, true);
}
// initialize the xstr table
void lcl_xstr_init()
{
int i, rval;
for (i = 0; i < XSTR_SIZE; i++)
Xstr_table[i].str = NULL;
for (i = 0; i < LCL_MAX_STRINGS; i++)
Lcl_ext_str[i] = NULL;
if ( (rval = setjmp(parse_abort)) != 0 )
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", "strings.tbl", rval));
else
@@ -442,6 +426,15 @@ void lcl_xstr_init()
parse_modular_table(NOX("*-lcl.tbm"), parse_stringstbl);
if ( (rval = setjmp(parse_abort)) != 0 )
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", "tstrings.tbl", rval));
else
parse_tstringstbl("tstrings.tbl");
parse_modular_table(NOX("*-tlc.tbm"), parse_tstringstbl);
Xstr_inited = 1;
}
@@ -455,7 +448,13 @@ void lcl_xstr_close()
Xstr_table[i].str = NULL;
}
}
vm_free(Lcl_ext_filename);
for (int i=0; i<LCL_MAX_STRINGS; i++){
if (Lcl_ext_str[i] != NULL) {
vm_free((void *) Lcl_ext_str[i]);
Lcl_ext_str[i] = NULL;
}
}
}
@@ -483,14 +482,6 @@ void lcl_set_language(int lang)
} else if (!strcmp(Lcl_languages[Lcl_current_lang].lang_name, Lcl_builtin_languages[LCL_POLISH].lang_name)) {
Lcl_pl = 1;
}
// set to 0, so lcl_ext_open() knows to reset file pointers
Lcl_pointer_count = 0;
// reset file pointers to the proper language-section
if(Lcl_current_lang != FS2_OPEN_DEFAULT_LANGUAGE){
lcl_ext_setup_pointers();
}
}
ubyte lcl_get_font_index(int font_num)
@@ -571,42 +562,6 @@ int lcl_add_dir_to_path_with_filename(char *current_path, size_t path_max)
// externalization of table/mission files -----------------------
// open the externalization file for use during parsing (call before parsing a given file)
void lcl_ext_open()
{
// if the file is already open, do nothing
Assert(Lcl_ext_file == NULL);
// if we're running in the default language, do nothing
if(Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE){
return;
}
// otherwise open the file
Lcl_ext_file = cfopen(Lcl_ext_filename, "rt");
if(Lcl_ext_file == NULL){
return;
}
}
// close the externalization file (call after parsing a given file)
void lcl_ext_close()
{
// if the file is not open, do nothing
if(Lcl_ext_file == NULL){
return;
}
// if we're running in the default language, do nothing
if(Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE){
return;
}
// otherwise close it
cfclose(Lcl_ext_file);
Lcl_ext_file = NULL;
}
void lcl_replace_stuff(char *text, size_t max_len)
{
if (Fred_running)
@@ -681,7 +636,6 @@ void lcl_fred_replace_stuff(SCP_string &text)
void lcl_ext_localize_sub(const char *in, char *out, size_t max_len, int *id)
{
char text_str[PARSE_BUF_SIZE]="";
char lookup_str[PARSE_BUF_SIZE]="";
int str_id;
size_t str_len;
@@ -747,7 +701,7 @@ void lcl_ext_localize_sub(const char *in, char *out, size_t max_len, int *id)
}
// if the localization file is not open, or we're running in the default language, return the original string
if ( (Lcl_ext_file == NULL) || (str_id < 0) || (Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE) ) {
if ( !Xstr_inited || (str_id < 0) || (Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE) ) {
if ( strlen(text_str) > max_len )
error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", text_str, strlen(text_str), max_len);
@@ -759,13 +713,13 @@ void lcl_ext_localize_sub(const char *in, char *out, size_t max_len, int *id)
return;
}
// attempt to find the string
if (lcl_ext_lookup(lookup_str, str_id)) {
// get the string if it exists
if (Lcl_ext_str[str_id] != NULL) {
// copy to the outgoing string
if ( strlen(lookup_str) > max_len )
error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", lookup_str, strlen(lookup_str), max_len);
if ( strlen(Lcl_ext_str[str_id]) > max_len )
error_display(0, "Token too long: [%s]. Length = %i. Max is %i.\n", Lcl_ext_str[str_id], strlen(Lcl_ext_str[str_id]), max_len);
strncpy(out, lookup_str, max_len);
strncpy(out, Lcl_ext_str[str_id], max_len);
}
// otherwise use what we have - probably should Int3() or assert here
else {
@@ -785,7 +739,6 @@ void lcl_ext_localize_sub(const char *in, char *out, size_t max_len, int *id)
void lcl_ext_localize_sub(const SCP_string &in, SCP_string &out, int *id)
{
SCP_string text_str = "";
char lookup_str[PARSE_BUF_SIZE]="";
int str_id;
// default (non-external string) value
@@ -833,7 +786,7 @@ void lcl_ext_localize_sub(const SCP_string &in, SCP_string &out, int *id)
}
// if the localization file is not open, or we're running in the default language, return the original string
if ( (Lcl_ext_file == NULL) || (str_id < 0) || (Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE) ) {
if ( !Xstr_inited || (str_id < 0) || (Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE) ) {
out = text_str;
if (id != NULL)
@@ -843,9 +796,9 @@ void lcl_ext_localize_sub(const SCP_string &in, SCP_string &out, int *id)
}
// attempt to find the string
if (lcl_ext_lookup(lookup_str, str_id)) {
if (Lcl_ext_str[str_id] != NULL) {
// copy to the outgoing string
out = lookup_str;
out = Lcl_ext_str[str_id];
}
// otherwise use what we have - probably should Int3() or assert here
else {
@@ -916,18 +869,6 @@ int lcl_get_xstr_offset(int index, int res)
// LOCALIZE FORWARD DEFINITIONS
//
// associate table file externalization with the specified input file
void lcl_ext_associate(const char *filename)
{
// if the filename already exists, free it up
if(Lcl_ext_filename != NULL){
vm_free(Lcl_ext_filename);
}
// set the new filename
Lcl_ext_filename = vm_strdup(filename);
}
// given a valid XSTR() tag piece of text, extract the string portion, return it in out, nonzero on success
int lcl_ext_get_text(const char *xstr, char *out)
{
@@ -1162,192 +1103,6 @@ int lcl_ext_get_id(const SCP_string &xstr, int *out)
return 1;
}
// given a valid XSTR() id#, lookup the string in tstrings.tbl, filling in out if found, nonzero on success
int lcl_ext_lookup(char *out, int id)
{
char text[1024];
int ret;
int pointer;
Assert(Lcl_pointer_count >= 0);
Assert(Lcl_pointers[0] >= 0);
Assert(Lcl_pointers[Lcl_pointer_count - 1] >= 0);
Assert(Lcl_ext_file != NULL);
Assert(id >= 0);
// seek to the closest pointer <= the id# we're looking for
pointer = id / LCL_GRANULARITY;
cfseek(Lcl_ext_file, Lcl_pointers[pointer], CF_SEEK_SET);
// reset parsing vars and go to town
Ts_current_state = TS_SCANNING;
Ts_id_text_size = 0;
// Ts_text_size;
memset(Ts_text, 0, PARSE_TEXT_BUF_SIZE);
memset(Ts_id_text, 0, PARSE_ID_BUF_SIZE);
while((cftell(Lcl_ext_file) < Lcl_pointers[Lcl_pointer_count - 1]) && cfgets(text, 1024, Lcl_ext_file)){
ret = lcl_ext_lookup_sub(text, out, id);
// run the line parse function
switch(ret & 0x0fffffff){
// error
case 0 :
Int3(); // should never get here - it means the string doens't exist in the table!!
return 0;
// success parsing the line - please continue
case 1 :
break;
// found a matching string/id pair
case 2 :
// success
if (Lcl_gr) {
// this is because tstrings.tbl reads in as ANSI for some reason
// opening tstrings with "rb" mode didnt seem to help, so its now still "rt" like before
lcl_fix_umlauts(out, LCL_TO_ASCII);
}
return 1;
// end of language found
case 3 :
Int3(); // should never get here - it means the string doens't exist in the table!!
return 0;
}
}
Int3(); // should never get here - it means the string doens't exist in the table!!
return 0;
}
// sub-parse function for individual lines of tstrings.tbl (from Exstr)
// returns : integer with the low bits having the following values :
// 0 on fail, 1 on success, 2 if found a matching id/string pair, 3 if end of language has been found
// for cases 1 and 2 : the high bit (1<<31) will be set if the parser detected the beginning of a new string id on this line
//
int lcl_ext_lookup_sub(const char *text, char *out, int id)
{
const char *p; // current ptr
int len = strlen(text);
int count;
char text_copy[1024];
char *tok;
int found_new_string_id = 0;
p = text;
count = 0;
while(count < len){
// do something useful
switch(Ts_current_state){
// scanning for a line of text
case TS_SCANNING:
// if the first word is #end, we're done with the file altogether
strcpy_s(text_copy, text);
tok = strtok(text_copy, " \n");
if((tok != NULL) && !stricmp(tok, "#end")){
return 3;
}
// if its a commented line, skip it
else if((text[0] == ';') || (text[0] == ' ') || (text[0] == '\n')){
return 1;
}
// otherwise we should have an ID #, so stuff it and move to the proper state
else {
if(lcl_is_valid_numeric_char(*p)){
memset(Ts_id_text, 0, PARSE_ID_BUF_SIZE);
Ts_id_text_size = 0;
Ts_id_text[Ts_id_text_size++] = *p;
Ts_current_state = TS_ID_STRING;
found_new_string_id = 1;
}
// error
else {
Int3();
return 0;
}
}
break;
// scanning in an id string
case TS_ID_STRING:
// if we have another valid char
if(lcl_is_valid_numeric_char(*p)) {
if (Ts_id_text_size >= PARSE_ID_BUF_SIZE - 1) {
error_display(0, "XSTR id %s too long!\n", Ts_id_text);
return 0;
}
Ts_id_text[Ts_id_text_size++] = *p;
}
// if we found a comma, our id# is finished, look for the open quote
else if(*p == ','){
Ts_current_state = TS_OPEN_QUOTE;
} else {
Int3();
return 0;
}
break;
case TS_OPEN_QUOTE:
// valid space or an open quote
if((*p == ' ') || (*p == '\"')){
if(*p == '\"'){
memset(Ts_text, 0, PARSE_TEXT_BUF_SIZE);
Ts_text_size = 0;
Ts_current_state = TS_STRING;
}
} else {
Int3();
return 0;
}
break;
case TS_STRING:
// if we have an end quote, we need to look for a comma
if((*p == '\"') /*&& (Ts_text_size > 0)*/ && (Ts_text[Ts_text_size - 1] != '\\')){
// we're now done - we have a string
Ts_current_state = TS_SCANNING;
// if the id#'s match, copy the string and return "string found"
if((atoi(Ts_id_text) == id) && (out != NULL)){
// this is redundant to the PARSE_TEXT_BUF_SIZE, but let's be future proof
if (strlen(Ts_text) > PARSE_BUF_SIZE - 1) {
error_display(0, "XSTR text result exceeds output buffer size!\n\n%s\n", Ts_text);
return 0;
}
strcpy(out, Ts_text);
return found_new_string_id ? (1<<1) | (1<<31) : (1<<1);
}
// otherwise, just continue parsing
return found_new_string_id ? (1<<0) | (1<<31) : (1<<0);
}
// otherwise add to the string
else {
if (Ts_text_size >= PARSE_TEXT_BUF_SIZE - 1) {
error_display(0, "XSTR text too long!\n\n%s\n", Ts_text);
return 0;
}
Ts_text[Ts_text_size++] = *p;
}
break;
}
// if we have a newline, return success, we're done with this line
if(*p == '\n'){
return found_new_string_id ? (1<<0) | (1<<31) : (1<<0);
}
// next char in the line
p++;
count++;
}
// success
return found_new_string_id ? (1<<0) | (1<<31) : (1<<0);
}
// if the char is a valid char for a signed integer value
int lcl_is_valid_numeric_char(char c)
{
@@ -1355,98 +1110,6 @@ int lcl_is_valid_numeric_char(char c)
(c == '5') || (c == '6') || (c == '7') || (c == '8') || (c == '9') ) ? 1 : 0;
}
// initialize the pointer array into tstrings.tbl (call from lcl_ext_open() ONLY)
void lcl_ext_setup_pointers()
{
char language_string[128];
char line[1024];
char *tok;
int string_count;
int ret;
int found_start = 0;
// open the localization file
lcl_ext_open();
if(Lcl_ext_file == NULL){
error_display(0, "Error opening externalization file! File likely does not exist or could not be found\n");
return;
}
// seek to the currently active language
memset(language_string, 0, 128);
strcpy_s(language_string, "#");
if(Lcl_current_lang == FS2_OPEN_DEFAULT_LANGUAGE){
strcat_s(language_string, "default");
} else {
strcat_s(language_string, Lcl_languages[Lcl_current_lang].lang_name);
}
memset(line, 0, 1024);
// reset seek variables and begin
Lcl_pointer_count = 0;
while(cfgets(line, 1024, Lcl_ext_file)){
tok = strtok(line, " \n");
if(tok == NULL){
continue;
}
// if the language matches, we're good to start parsing strings
if(!stricmp(language_string, tok)){
found_start = 1;
break;
}
}
// if we didn't find the language specified, error
if(found_start <= 0){
error_display(0, "Could not find specified language in tstrings.tbl!\n");
lcl_ext_close();
return;
}
string_count = 0;
while(cfgets(line, 1024, Lcl_ext_file)){
ret = lcl_ext_lookup_sub(line, NULL, -1);
// do stuff
switch(ret & 0x0fffffff){
// error
case 0 :
lcl_ext_close();
return;
// end of language found
case 3 :
// mark one final pointer
Lcl_pointers[Lcl_pointer_count++] = cftell(Lcl_ext_file) - strlen(line) - 1;
lcl_ext_close();
return;
}
// the only other case we care about is the beginning of a new id#
if(ret & (1<<31)){
if((string_count % LCL_GRANULARITY) == 0){
// mark the pointer down
Lcl_pointers[Lcl_pointer_count++] = cftell(Lcl_ext_file) - strlen(line) - 1;
// if we're out of pointer slots
if(Lcl_pointer_count >= LCL_MAX_POINTERS){
error_display(0, "Out of pointers for tstrings.tbl lookup. Please increment LCL_MAX_POINTERS in localize.cpp\n");
lcl_ext_close();
return;
}
}
// increment string count
string_count++;
}
}
// should never get here. we should always be exiting through case 3 (end of language section) of the above switch
// statement
Int3();
lcl_ext_close();
}
void lcl_get_language_name(char *lang_name)
{
Assert(Lcl_current_lang < (int)Lcl_languages.size());
@@ -1454,94 +1117,6 @@ void lcl_get_language_name(char *lang_name)
strcpy(lang_name, Lcl_languages[Lcl_current_lang].lang_name);
}
// converts german umlauted chars from ASCII to ANSI
// so they appear in the launcher
// how friggin lame is this
// pass in a null terminated string, foo!
// returns ptr to string you sent in
char* lcl_fix_umlauts(char *str, int which_way)
{
int i=0;
if (which_way == LCL_TO_ANSI) {
// moving to ANSI charset
// run thru string and perform appropriate conversions
while (str[i] != '\0') {
switch (str[i]) {
case '\x81':
// lower umlaut u
str[i] = '\xFC';
break;
case '\x84':
// lower umlaut a
str[i] = '\xE4';
break;
case '\x94':
// lower umlaut o
str[i] = '\xF6';
break;
case '\x9A':
// upper umlaut u
str[i] = '\xDC';
break;
case '\x8E':
// upper umlaut a
str[i] = '\xC4';
break;
case '\x99':
// upper umlaut o
str[i] = '\xD6';
break;
case '\xE1':
// beta-lookin thing that means "ss"
str[i] = '\xDF';
break;
}
i++;
}
} else {
// moving to ASCII charset
// run thru string and perform appropriate conversions
while (str[i] != '\0') {
switch (str[i]) {
case '\xFC':
// lower umlaut u
str[i] = '\x81';
break;
case '\xE4':
// lower umlaut a
str[i] = '\x84';
break;
case '\xF6':
// lower umlaut o
str[i] = '\x94';
break;
case '\xDC':
// upper umlaut u
str[i] = '\x9A';
break;
case '\xC4':
// upper umlaut a
str[i] = '\x8E';
break;
case '\xD6':
// upper umlaut o
str[i] = '\x99';
break;
case '\xDF':
// beta-lookin thing that means "ss"
str[i] = '\xE1';
break;
}
i++;
}
}
return str;
}
// convert some of the polish characters
void lcl_fix_polish(char *str)
{
-19
View File
@@ -92,12 +92,6 @@ void lcl_add_dir(char *current_path);
// maybe add localized directory to full path with file name when opening a localized file
int lcl_add_dir_to_path_with_filename(char *current_path, size_t path_max);
// open the externalization file for use during parsing (call before parsing a given file)
void lcl_ext_open();
// close the externalization file (call after parsing a given file)
void lcl_ext_close();
// Goober5000
void lcl_replace_stuff(char *text, size_t max_len);
void lcl_replace_stuff(SCP_string &text);
@@ -120,23 +114,10 @@ void lcl_ext_localize(const SCP_string &in, SCP_string &out, int *id = NULL);
const char *XSTR(const char *str, int index);
int lcl_get_xstr_offset(int index, int res);
// translate umlauted chars from ascii to ansi codes
// used in launcher
#define LCL_TO_ANSI 0
#define LCL_TO_ASCII 1
char* lcl_fix_umlauts(char *str, int which_way);
// covert some polish characters
void lcl_fix_polish(char *str);
void lcl_fix_polish(SCP_string &str);
// macro for launcher xstrs
#if defined(GERMAN_BUILD)
#define LXSTR(str, i) (lcl_fix_umlauts(XSTR(str, i), LCL_TO_ANSI))
#else
#define LXSTR(str, i) (XSTR(str, i))
#endif // defined(GERMAN_BUILD)
void lcl_translate_wep_name_gr(char *name);
void lcl_translate_ship_name_gr(char *name);
void lcl_translate_brief_icon_name_gr(char *name);
+1 -1
View File
@@ -2514,7 +2514,7 @@ void vm_find_bounding_sphere(vec3d *pnts, int num_pnts, vec3d *center, float *ra
dia2 = ymax;
}
if ( zspan > maxspan ) {
maxspan = yspan;
maxspan = zspan;
dia1 = zmin;
dia2 = zmax;
}
+36 -17
View File
@@ -290,6 +290,8 @@ static int Pilot_squad_images[MAX_PILOT_IMAGES];
static int Rank_pips_bitmaps;
static int Rank_pips_count;
int Barracks_overlay_id;
void barracks_squad_change_popup();
@@ -308,6 +310,7 @@ void barracks_init_stats(scoring_struct *stats)
int Max_stat_lines = Num_ship_classes + 23;
int i;
float f;
int score_from_kills = 0;
//Set up variables
if(Stat_labels != NULL)
@@ -470,9 +473,18 @@ void barracks_init_stats(scoring_struct *stats)
sprintf(Stat_labels[Num_stat_lines], NOX("%s:"), Ship_info[i].name);
sprintf(Stats[Num_stat_lines], "%d", stats->kills[i]);
Num_stat_lines++;
// work out the total score from ship kills
score_from_kills += stats->kills[i] * Ship_info[i].score;
}
}
// add the score from kills
Assert((Num_stat_lines + 1) < Max_stat_lines);
STRCPY1(Stat_labels[Num_stat_lines], XSTR( "Score from kills only:", 1636));
sprintf(Stats[Num_stat_lines], "%d", score_from_kills);
Num_stat_lines++;
for (i=0; i<Num_stat_lines; i++) {
gr_force_fit_string(Stat_labels[i], Stat_column1_w[gr_screen.res], Barracks_stats_coords[gr_screen.res][BARRACKS_W_COORD]);
gr_force_fit_string(Stats[i], Stat_column2_w[gr_screen.res], Barracks_stats2_coords[gr_screen.res][BARRACKS_W_COORD]);
@@ -629,6 +641,15 @@ int barracks_pilot_accepted()
return -1;
}
// check that pilot language is OK
if (!valid_pilot_lang(Cur_pilot->callsign)) {
popup(PF_USE_AFFIRMATIVE_ICON,1,POPUP_OK,XSTR(
"Selected pilot was created with a different language\n"
"to the currently active language.\n\n"
"Please select a different pilot or change the language", 1637));
return -1;
}
// set pilot image
if (Game_mode & GM_MULTIPLAYER) {
player_set_squad_bitmap(Cur_pilot, Cur_pilot->m_squad_filename, true);
@@ -899,12 +920,6 @@ void barracks_init_player_stuff(int mode)
// determine if we should be looking for single or multiplayers at the outset
Player_sel_mode = mode;
// get the list of pilots based upon whether we're in single or multiplayer mode
Num_pilots = 0;
Get_file_list_filter = barracks_pilot_filter;
Num_pilots = cf_get_file_list_preallocated(MAX_PILOTS, Pilots_arr, Pilots, CF_TYPE_PLAYERS, NOX("*.plr"), CF_SORT_TIME);
// single player specific stuff
if (mode == PLAYER_SELECT_MODE_SINGLE) {
Game_mode &= ~GM_MULTIPLAYER;
@@ -930,6 +945,13 @@ void barracks_init_player_stuff(int mode)
Buttons[gr_screen.res][B_SQUAD_NEXT_BUTTON].button.unhide();
}
// get the list of pilots based upon whether we're in single or multiplayer mode
// moved down here so pilotfile::verify knows which Game_mode to get ranks for
Num_pilots = 0;
Get_file_list_filter = barracks_pilot_filter;
Num_pilots = cf_get_file_list_preallocated(MAX_PILOTS, Pilots_arr, Pilots, CF_TYPE_PLAYERS, NOX("*.plr"), CF_SORT_TIME);
int ranks[MAX_PILOTS];
for (i=0; i<Num_pilots; i++) {
@@ -1371,8 +1393,8 @@ void barracks_init()
Inputbox.hide();
// load in help overlay bitmap
help_overlay_load(BARRACKS_OVERLAY);
help_overlay_set_state(BARRACKS_OVERLAY,0);
Barracks_overlay_id = help_overlay_get_index(BARRACKS_OVERLAY);
help_overlay_set_state(Barracks_overlay_id,gr_screen.res,0);
// other init stuff
Barracks_callsign_enter_mode = 0;
@@ -1423,8 +1445,8 @@ void barracks_do_frame(float frametime)
int k = Ui_window.process();
if ( k > 0 ) {
if ( help_overlay_active(BARRACKS_OVERLAY) ) {
help_overlay_set_state(BARRACKS_OVERLAY,0);
if ( help_overlay_active(Barracks_overlay_id) ) {
help_overlay_set_state(Barracks_overlay_id,gr_screen.res,0);
k = 0;
}
}
@@ -1466,7 +1488,7 @@ void barracks_do_frame(float frametime)
break;
case KEY_ESC: // cancel
if (!help_overlay_active(BARRACKS_OVERLAY)) {
if (!help_overlay_active(Barracks_overlay_id)) {
if (Num_pilots && !barracks_pilot_accepted()) {
gameseq_post_event(GS_EVENT_MAIN_MENU);
} else {
@@ -1474,7 +1496,7 @@ void barracks_do_frame(float frametime)
}
} else {
// kill the overlay
help_overlay_set_state(BARRACKS_OVERLAY,0);
help_overlay_set_state(Barracks_overlay_id,gr_screen.res,0);
}
break;
@@ -1531,7 +1553,7 @@ void barracks_do_frame(float frametime)
// check mouse over help
if (mouse_down(MOUSE_LEFT_BUTTON)) {
help_overlay_set_state(BARRACKS_OVERLAY, 0);
help_overlay_set_state(Barracks_overlay_id, gr_screen.res, 0);
}
// do pilot pic stuff
@@ -1601,7 +1623,7 @@ void barracks_do_frame(float frametime)
barracks_display_pilot_stats();
// blit help overlay if active
help_overlay_maybe_blit(BARRACKS_OVERLAY);
help_overlay_maybe_blit(Barracks_overlay_id, gr_screen.res);
// flip the page
gr_flip();
@@ -1628,9 +1650,6 @@ void barracks_close()
}
}
// unload the overlay bitmap
help_overlay_unload(BARRACKS_OVERLAY);
if(Stat_labels != NULL)
{
delete[] Stat_labels;
+2
View File
@@ -12,6 +12,8 @@
#ifndef _BARRACKS_H
#define _BARRACKS_H
extern int Barracks_overlay_id;
// initialize the barracks
void barracks_init();
-6
View File
@@ -415,17 +415,11 @@ void credits_parse_table(const char* filename)
void credits_parse()
{
// open localization
lcl_ext_open();
// Parse main table
credits_parse_table("credits.tbl");
// Parse modular tables
parse_modular_table("*-crd.tbm", credits_parse_table);
// close localization
lcl_ext_close();
}
void credits_init()
+4 -4
View File
@@ -73,11 +73,11 @@ void fish_generate()
// start location
if(f->left){
f->x = gr_screen.max_w_unscaled + frand_range(0.0f, 50.0f);
f->x = gr_screen.max_w_unscaled_zoomed + frand_range(0.0f, 50.0f);
} else {
f->x = frand_range(0.0f, -50.0f) - FISH_ANIM_WIDTH;
}
f->y = frand_range(-40.0f, (float)gr_screen.max_h_unscaled + 40.0f);
f->y = frand_range(-40.0f, (float)gr_screen.max_h_unscaled_zoomed + 40.0f);
// speed
if(f->left){
@@ -225,8 +225,8 @@ void fishtank_process()
// is he currently onscreen ?
onscreen = 0;
if( (f->x < (float)gr_screen.max_w_unscaled) && ((f->x + FISH_ANIM_WIDTH) >= 0.0f) &&
(f->y < (float)gr_screen.max_h_unscaled) && ((f->y + FISH_ANIM_HEIGHT) >= 0.0f) ){
if( (f->x < (float)gr_screen.max_w_unscaled_zoomed) && ((f->x + FISH_ANIM_WIDTH) >= 0.0f) &&
(f->y < (float)gr_screen.max_h_unscaled_zoomed) && ((f->y + FISH_ANIM_HEIGHT) >= 0.0f) ){
onscreen = 1;
}
+228 -91
View File
@@ -74,6 +74,10 @@ int Main_hall_music_handle = -1;
// background bitmap handle
int Main_hall_bitmap;
// background bitmap dimensions
int Main_hall_bitmap_w;
int Main_hall_bitmap_h;
// background bitmap mask handle
int Main_hall_mask;
@@ -251,7 +255,7 @@ void main_hall_maybe_blit_tooltips();
shader Main_hall_tooltip_shader;
// num pixels shader is above/below tooltip text
static int Main_hall_tooltip_padding[GR_NUM_RESOLUTIONS] = {
static int Main_hall_default_tooltip_padding[GR_NUM_RESOLUTIONS] = {
4, // GR_640
7, // GR_1024
};
@@ -282,24 +286,24 @@ void main_hall_do_multi_ready()
error = psnet_get_network_status();
switch( error ) {
case NETWORK_ERROR_NO_TYPE:
popup( PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have not defined your type of Internet connection. Please run the Launcher, hit the setup button, and go to the Network tab and choose your connection type.", 360));
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have not defined your type of Internet connection. Please run the Launcher, hit the setup button, and go to the Network tab and choose your connection type.", 360));
break;
case NETWORK_ERROR_NO_WINSOCK:
popup( PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "Winsock is not installed. You must have TCP/IP and Winsock installed to play multiplayer FreeSpace.", 361));
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "Winsock is not installed. You must have TCP/IP and Winsock installed to play multiplayer FreeSpace.", 361));
break;
case NETWORK_ERROR_NO_PROTOCOL:
if (Multi_options_g.protocol == NET_TCP) {
popup( PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "TCP/IP protocol not found. This protocol is required for multiplayer FreeSpace.", 1602));
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "TCP/IP protocol not found. This protocol is required for multiplayer FreeSpace.", 1602));
} else {
Assert(Multi_options_g.protocol == NET_IPX);
popup( PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "IPX protocol not found. This protocol is required for multiplayer FreeSpace.", 1603));
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "IPX protocol not found. This protocol is required for multiplayer FreeSpace.", 1603));
}
break;
case NETWORK_ERROR_CONNECT_TO_ISP:
popup( PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have selected Dial Up Networking as your type of connection to the Internet. You are not currently connected. You must connect to your ISP before continuing on past this point.", 363));
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have selected Dial Up Networking as your type of connection to the Internet. You are not currently connected. You must connect to your ISP before continuing on past this point.", 363));
break;
case NETWORK_ERROR_LAN_AND_RAS:
popup( PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have indicated that you use a LAN for networking. You also appear to be dialed into your ISP. Please disconnect from your service provider, or choose Dial Up Networking.", 364));
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have indicated that you use a LAN for networking. You also appear to be dialed into your ISP. Please disconnect from your service provider, or choose Dial Up Networking.", 364));
break;
case NETWORK_ERROR_NONE:
@@ -310,15 +314,15 @@ void main_hall_do_multi_ready()
// if our selected protocol is not active
if ((Multi_options_g.protocol == NET_TCP) && !Tcp_active) {
if (Tcp_failure_code == WSAEADDRINUSE) {
popup( PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have selected TCP/IP for multiplayer FreeSpace, but the TCP socket is already in use. Check for another instance and/or use the \"-port <port_num>\" command line option to select an available port.", 1604));
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have selected TCP/IP for multiplayer FreeSpace, but the TCP socket is already in use. Check for another instance and/or use the \"-port <port_num>\" command line option to select an available port.", 1604));
} else {
popup( PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have selected TCP/IP for multiplayer FreeSpace, but the TCP/IP protocol was not detected on your machine.", 362));
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have selected TCP/IP for multiplayer FreeSpace, but the TCP/IP protocol was not detected on your machine.", 362));
}
return;
}
if ((Multi_options_g.protocol == NET_IPX) && !Ipx_active) {
popup( PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have selected IPX for multiplayer FreeSpace, but the IPX protocol was not detected on your machine.", 1402));
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You have selected IPX for multiplayer FreeSpace, but the IPX protocol was not detected on your machine.", 1402));
return;
}
@@ -329,7 +333,7 @@ void main_hall_do_multi_ready()
// 7/9/98 -- MWA. Deal with the connection speed issue. make a call to the multiplayer code to
// determine is a valid connection setting exists
if (Multi_connection_speed == CONNECTION_SPEED_NONE) {
popup( PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You must define your connection speed. Please run the Launcher, hit the setup button, and go to the Network tab and choose your connection speed.", 986) );
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "You must define your connection speed. Please run the Launcher, hit the setup button, and go to the Network tab and choose your connection speed.", 986) );
return;
}
@@ -350,23 +354,15 @@ void main_hall_do_multi_ready()
// blit some small color indicators to show whether ships.tbl and weapons.tbl are valid
// green == valid, red == invalid.
// ships.tbl will be on the left, weapons.tbl on the right
int Mh_ship_table_status[GR_NUM_RESOLUTIONS][2] = {
{ 1, 479 },
{ 1, 767 }
};
int Mh_weapon_table_status[GR_NUM_RESOLUTIONS][2] = {
{ 3, 479 },
{ 3, 767 }
};
void main_hall_blit_table_status()
{
// blit ship table status
gr_set_color_fast(Game_ships_tbl_valid ? &Color_bright_green : &Color_bright_red);
gr_line(Mh_ship_table_status[gr_screen.res][0], Mh_ship_table_status[gr_screen.res][1], Mh_ship_table_status[gr_screen.res][0], Mh_ship_table_status[gr_screen.res][1], GR_RESIZE_MENU);
gr_line(1, gr_screen.max_h_unscaled_zoomed - 1, 1, gr_screen.max_h_unscaled_zoomed - 1, GR_RESIZE_MENU_ZOOMED);
// blit weapon table status
gr_set_color_fast(Game_weapons_tbl_valid ? &Color_bright_green : &Color_bright_red);
gr_line(Mh_weapon_table_status[gr_screen.res][0], Mh_weapon_table_status[gr_screen.res][1], Mh_weapon_table_status[gr_screen.res][0], Mh_ship_table_status[gr_screen.res][1], GR_RESIZE_MENU);
gr_line(3, gr_screen.max_h_unscaled_zoomed - 1, 3, gr_screen.max_h_unscaled_zoomed - 1, GR_RESIZE_MENU_ZOOMED);
}
/**
@@ -408,7 +404,7 @@ void main_hall_init(const SCP_string &main_hall_name)
}
// sanity checks
if (Main_hall_defines.at(0).size() == 0) {
if (Main_hall_defines.size() == 0) {
Error(LOCATION, "No main halls were loaded to initialize.");
} else if (main_hall_name == "") {
Warning(LOCATION, "main_hall_init() was passed a blank main hall name; loading first available main hall.");
@@ -468,10 +464,15 @@ void main_hall_init(const SCP_string &main_hall_name)
}
}
Main_hall_bitmap_w = -1;
Main_hall_bitmap_h = -1;
// load the background bitmap
Main_hall_bitmap = bm_load(Main_hall->bitmap);
if (Main_hall_bitmap < 0) {
nprintf(("General","WARNING! Couldn't load main hall background bitmap %s\n", Main_hall->bitmap.c_str()));
} else {
bm_get_info(Main_hall_bitmap, &Main_hall_bitmap_w, &Main_hall_bitmap_h);
}
bg_type = bm_get_type(Main_hall_bitmap);
@@ -494,6 +495,23 @@ void main_hall_init(const SCP_string &main_hall_name)
bm_get_info(Main_hall_mask, &Main_hall_mask_w, &Main_hall_mask_h);
}
// make sure the zoom area is completely within the background bitmap
if (Main_hall->zoom_area_width > Main_hall_bitmap_w) {
Main_hall->zoom_area_width = Main_hall_bitmap_w;
}
if (Main_hall->zoom_area_height > Main_hall_bitmap_h) {
Main_hall->zoom_area_height = Main_hall_bitmap_h;
}
// get the default value for tooltip padding if necessary
if (Main_hall->tooltip_padding == -1) {
if (Main_hall_bitmap_w >= GR_1024_THRESHOLD_WIDTH && Main_hall_bitmap_h >= GR_1024_THRESHOLD_HEIGHT) {
Main_hall->tooltip_padding = Main_hall_default_tooltip_padding[GR_1024];
} else {
Main_hall->tooltip_padding = Main_hall_default_tooltip_padding[GR_640];
}
}
// In case we're re-entering the mainhall
Main_hall_misc_anim.clear();
@@ -535,13 +553,14 @@ void main_hall_init(const SCP_string &main_hall_name)
}
// load in help overlay bitmap
if (Main_hall == &Main_hall_defines.at(gr_screen.res).at(0)) {
Main_hall_overlay_id = MH_OVERLAY;
if (!Main_hall->help_overlay_name.empty()) {
Main_hall_overlay_id = help_overlay_get_index(Main_hall->help_overlay_name.c_str());
} else if (main_hall_id() == 0) {
Main_hall_overlay_id = help_overlay_get_index(MH_OVERLAY);
} else {
Main_hall_overlay_id = MH2_OVERLAY;
Main_hall_overlay_id = help_overlay_get_index(MH2_OVERLAY);
}
help_overlay_load(Main_hall_overlay_id);
help_overlay_set_state(Main_hall_overlay_id,0);
help_overlay_set_state(Main_hall_overlay_id,gr_screen.res,0);
// check to see if the "very first pilot" flag is set, and load the overlay if so
if (!F1_text_done) {
@@ -620,6 +639,9 @@ void main_hall_do(float frametime)
{
int code, key, snazzy_action;
// set the screen scale to the main hall's dimensions
gr_set_screen_scale(Main_hall_bitmap_w, Main_hall_bitmap_h, Main_hall->zoom_area_width, Main_hall->zoom_area_height);
// need to ensure ambient is playing, since it may be stopped by a playing movie
main_hall_start_ambient();
@@ -774,7 +796,7 @@ void main_hall_do(float frametime)
gamesnd_play_iface(SND_IFACE_MOUSE_CLICK);
main_hall_exit_game();
} else { // kill the overlay
help_overlay_set_state(Main_hall_overlay_id,0);
help_overlay_set_state(Main_hall_overlay_id,gr_screen.res,0);
}
break;
} // END switch (code)
@@ -791,7 +813,7 @@ void main_hall_do(float frametime)
} // END switch (snazzy_action)
if (mouse_down(MOUSE_LEFT_BUTTON)) {
help_overlay_set_state(Main_hall_overlay_id, 0);
help_overlay_set_state(Main_hall_overlay_id, main_hall_get_overlay_resolution_index(), 0);
}
// draw the background bitmap
@@ -823,7 +845,7 @@ void main_hall_do(float frametime)
}
// blit help overlay if active
help_overlay_maybe_blit(Main_hall_overlay_id);
help_overlay_maybe_blit(Main_hall_overlay_id, main_hall_get_overlay_resolution_index());
// blit the freespace version #
main_hall_blit_version();
@@ -834,6 +856,7 @@ void main_hall_do(float frametime)
#endif
gr_flip();
gr_reset_screen_scale();
// see if we have a missing campaign and force the player to select a new campaign if so
extern bool Campaign_room_no_campaigns;
@@ -925,9 +948,6 @@ void main_hall_close()
}
}
// unload the overlay bitmap
help_overlay_unload(Main_hall_overlay_id);
// close any snazzy menu details
snazzy_menu_close();
@@ -956,7 +976,7 @@ int main_hall_get_music_index(int main_hall_num)
return -1;
}
hall = &Main_hall_defines.at(gr_screen.res).at(main_hall_num);
hall = &Main_hall_defines.at(main_hall_num).at(main_hall_get_resolution_index(main_hall_num));
// Goober5000 - try substitute first
index = event_music_get_spooled_music_index(hall->substitute_music_name);
@@ -1341,6 +1361,20 @@ void main_hall_handle_right_clicks()
int mx = Main_hall->door_anim_coords.at(new_region).at(2);
int my = Main_hall->door_anim_coords.at(new_region).at(3);
gr_resize_screen_pos( &mx, &my, NULL, NULL, GR_RESIZE_MENU );
if (mx < 0) {
mx = 0;
}
if (mx >= gr_screen.max_w) {
mx = gr_screen.max_w - 1;
}
if (my < 0) {
my = 0;
}
if (my >= gr_screen.max_h) {
my = gr_screen.max_h - 1;
}
mouse_set_pos( mx, my );
main_hall_handle_mouse_location(new_region);
@@ -1455,10 +1489,16 @@ void main_hall_notify_do()
Main_hall_notify_stamp = -1;
} else {
int w,h;
int old_font = gr_get_current_fontnum();
gr_set_color_fast(&Color_bright);
gr_set_font(Main_hall->font);
gr_get_string_size(&w,&h,Main_hall_notify_text);
gr_printf_menu((gr_screen.max_w_unscaled - w)/2, gr_screen.max_h_unscaled - 40, Main_hall_notify_text);
gr_printf_menu_zoomed((gr_screen.max_w_unscaled_zoomed - w)/2, gr_screen.max_h_unscaled_zoomed - (h * 4 + 4), Main_hall_notify_text);
gr_set_font(old_font);
}
}
}
@@ -1515,18 +1555,23 @@ void main_hall_reset_ambient_vol()
*/
void main_hall_blit_version()
{
int w;
int w, h;
char version_string[100];
// format the version string
get_version_string(version_string, sizeof(version_string));
int old_font = gr_get_current_fontnum();
gr_set_font(Main_hall->font);
// get the length of the string
gr_get_string_size(&w,NULL,version_string);
gr_get_string_size(&w,&h,version_string);
// print the string near the lower left corner
gr_set_color_fast(&Color_bright_white);
gr_string(5, gr_screen.max_h_unscaled - 24, version_string, GR_RESIZE_MENU);
gr_string(5, gr_screen.max_h_unscaled_zoomed - (h * 2 + 6), version_string, GR_RESIZE_MENU_ZOOMED);
gr_set_font(old_font);
}
/**
@@ -1534,7 +1579,7 @@ void main_hall_blit_version()
*/
void main_hall_maybe_blit_tooltips()
{
int w, text_index;
int w, h, text_index;
// if we're over no region - don't blit anything
if (Main_hall_mouse_region < 0) {
@@ -1555,15 +1600,25 @@ void main_hall_maybe_blit_tooltips()
// set the color and blit the string
if (!help_overlay_active(Main_hall_overlay_id)) {
int shader_y = (Main_hall->region_yval) - Main_hall_tooltip_padding[gr_screen.res]; // subtract more to pull higher
int old_font = gr_get_current_fontnum();
gr_set_font(Main_hall->font);
// get the width of the string
gr_get_string_size(&w, NULL, Main_hall->region_descript.at(text_index));
gr_get_string_size(&w, &h, Main_hall->region_descript.at(text_index));
int text_y;
if (Main_hall->region_yval == -1) {
text_y = gr_screen.max_h_unscaled - ((gr_screen.max_h_unscaled - gr_screen.max_h_unscaled_zoomed) / 2) - Main_hall->tooltip_padding - h;
} else {
text_y = Main_hall->region_yval;
}
int shader_y = text_y - (Main_hall->tooltip_padding); // subtract more to pull higher
gr_set_shader(&Main_hall_tooltip_shader);
gr_shade(0, shader_y, gr_screen.clip_width_unscaled, (gr_screen.clip_height_unscaled - shader_y), GR_RESIZE_MENU);
gr_shade(0, shader_y, gr_screen.max_w_unscaled, (gr_screen.max_h_unscaled - shader_y), GR_RESIZE_MENU);
gr_set_color_fast(&Color_bright_white);
gr_string((gr_screen.max_w_unscaled - w)/2, Main_hall->region_yval, Main_hall->region_descript.at(text_index), GR_RESIZE_MENU);
gr_string((gr_screen.max_w_unscaled - w)/2, text_y, Main_hall->region_descript.at(text_index), GR_RESIZE_MENU);
gr_set_font(old_font);
}
}
@@ -1585,6 +1640,9 @@ void main_hall_process_help_stuff()
Main_hall_f1_text_frame++;
}
int old_font = gr_get_current_fontnum();
gr_set_font(Main_hall->font);
// otherwise print out the message
strcpy_s(str, XSTR( "Press F1 for help", 371));
gr_get_string_size(&w, &h, str);
@@ -1592,7 +1650,7 @@ void main_hall_process_help_stuff()
int y_anim_offset = Main_hall_f1_text_frame;
// if anim is off the screen finally, stop altogether
if ( (y_anim_offset >= (2*Main_hall_tooltip_padding[gr_screen.res]) + h) || (help_overlay_active(Main_hall_overlay_id)) ) {
if ( (y_anim_offset >= (2*Main_hall->tooltip_padding) + h) || (help_overlay_active(Main_hall_overlay_id)) ) {
Main_hall_f1_text_frame = -1;
Main_hall_help_stamp = -1;
F1_text_done = 1;
@@ -1602,8 +1660,10 @@ void main_hall_process_help_stuff()
// set the color and print out text and shader
gr_set_color_fast(&Color_bright_white);
gr_set_shader(&Main_hall_tooltip_shader);
gr_shade(0, 0, gr_screen.max_w_unscaled, (2*Main_hall_tooltip_padding[gr_screen.res]) + h - y_anim_offset, GR_RESIZE_MENU);
gr_string((gr_screen.max_w_unscaled - w)/2, Main_hall_tooltip_padding[gr_screen.res] /*- y_anim_offset*/, str, GR_RESIZE_MENU);
gr_shade(0, 0, gr_screen.max_w_unscaled_zoomed, (2*Main_hall->tooltip_padding) + h - y_anim_offset, GR_RESIZE_MENU_ZOOMED);
gr_string((gr_screen.max_w_unscaled_zoomed - w)/2, Main_hall->tooltip_padding - y_anim_offset, str, GR_RESIZE_MENU_ZOOMED);
gr_set_font(old_font);
}
/**
@@ -1617,9 +1677,9 @@ main_hall_defines* main_hall_get_pointer(const SCP_string &name_to_find)
{
unsigned int i;
for (i = 0; i < Main_hall_defines.at(gr_screen.res).size(); i++) {
if (Main_hall_defines.at(gr_screen.res).at(i).name == name_to_find) {
return &Main_hall_defines.at(gr_screen.res).at(i);
for (i = 0; i < Main_hall_defines.size(); i++) {
if (Main_hall_defines.at(i).at(0).name == name_to_find) {
return &Main_hall_defines.at(i).at(main_hall_get_resolution_index(i));
}
}
return NULL;
@@ -1637,20 +1697,52 @@ int main_hall_get_index(const SCP_string &name_to_find)
{
unsigned int i;
for (i = 0; i < Main_hall_defines.at(gr_screen.res).size(); i++) {
if (Main_hall_defines.at(gr_screen.res).at(i).name == name_to_find) {
for (i = 0; i < Main_hall_defines.size(); i++) {
if (Main_hall_defines.at(i).at(0).name == name_to_find) {
return i;
}
}
return -1;
}
int main_hall_get_resolution_index(int main_hall_num)
{
unsigned int i;
float aspect_ratio = (float)gr_screen.max_w / (float)gr_screen.max_h;
for (i = Main_hall_defines.at(main_hall_num).size() - 1; i >= 1; i--) {
main_hall_defines* m = &Main_hall_defines.at(main_hall_num).at(i);
if (gr_screen.max_w >= m->min_width && gr_screen.max_h >= m->min_height && aspect_ratio >= m->min_aspect_ratio) {
return i;
}
}
return 0;
}
void main_hall_get_name(SCP_string &name, unsigned int index)
{
if (index>Main_hall_defines.at(gr_screen.res).size()) {
if (index>=Main_hall_defines.size()) {
name = "";
} else {
name = Main_hall_defines.at(gr_screen.res).at(index).name;
name = Main_hall_defines.at(index).at(0).name;
}
}
int main_hall_get_overlay_id()
{
if (Main_hall==NULL) {
return -1;
} else {
return Main_hall_overlay_id;
}
}
int main_hall_get_overlay_resolution_index()
{
if (Main_hall==NULL) {
return -1;
} else {
return Main_hall->help_overlay_resolution_index;
}
}
@@ -1664,25 +1756,6 @@ int main_hall_id()
}
}
// helper function for initialising the Main_hall_defines vector
// call before parsing mainhall.tbl
void main_hall_defines_init()
{
int i;
// if we're parsing a modular table (ie Main_hall_defines already has GR_NUM_RESOLUTIONS vectors in it),
// we can skip this.
if (Main_hall_defines.size() >= GR_NUM_RESOLUTIONS) {
return;
}
SCP_vector<main_hall_defines> temp;
// for each resolution we just want to put in a blank vector
for (i = 0; i < GR_NUM_RESOLUTIONS; i++) {
Main_hall_defines.push_back(temp);
}
}
// CommanderDJ - helper function for initialising intercom sounds vectors based on number of sounds
// To be called after num_intercom_sounds has been parsed
void intercom_sounds_init(main_hall_defines &m)
@@ -1841,6 +1914,9 @@ void door_anim_init(main_hall_defines &m)
*/
void main_hall_table_init()
{
// clear the main hall entries
Main_hall_defines.clear();
// if mainhall.tbl exists, parse it
if (cf_exists_full("mainhall.tbl", CF_TYPE_TABLES)) {
parse_main_hall_table("mainhall.tbl");
@@ -1856,6 +1932,7 @@ void parse_main_hall_table(const char* filename)
SCP_vector<main_hall_defines> temp_vector;
main_hall_defines *m, temp;
int idx, s_idx, m_idx, rval;
int num_resolutions = 2;
unsigned int count;
char temp_string[MAX_FILENAME_LEN];
@@ -1868,21 +1945,28 @@ void parse_main_hall_table(const char* filename)
reset_parse();
main_hall_defines_init();
if (optional_string("$Num Resolutions:")) {
stuff_int(&num_resolutions);
}
if (num_resolutions < 1) {
Error(LOCATION, "$Num Resolutions in %s is %d. (Must be 1 or greater)", filename, num_resolutions);
}
// go for it
count = Main_hall_defines.at(0).size();
count = Main_hall_defines.size();
while (!optional_string("#end")) {
// read in 2 resolutions
for (m_idx = 0; m_idx < GR_NUM_RESOLUTIONS; m_idx++) {
Main_hall_defines.at(m_idx).push_back(temp);
m = &Main_hall_defines.at(m_idx).at(count);
Main_hall_defines.push_back(temp_vector);
// read in all resolutions
for (m_idx = 0; m_idx < num_resolutions; m_idx++) {
Main_hall_defines.at(count).push_back(temp);
m = &Main_hall_defines.at(count).at(m_idx);
// ready
required_string("$Main Hall");
// Parse the 640 entry name, checking for duplicates and erroring if necessary
if (m_idx == GR_640) {
// Parse the entry name for the first resolution, checking for duplicates and erroring if necessary
if (m_idx == 0) {
if (optional_string("+Name:")) {
stuff_string(temp_string, F_RAW, MAX_FILENAME_LEN);
@@ -1896,7 +1980,7 @@ void parse_main_hall_table(const char* filename)
snprintf(temp_string, MAX_FILENAME_LEN, "%d", count);
m->name = temp_string;
}
} else if (m_idx == GR_1024) {
} else {
if (optional_string("+Name:")) {
stuff_string(temp_string, F_RAW, MAX_FILENAME_LEN);
@@ -1905,15 +1989,31 @@ void parse_main_hall_table(const char* filename)
* it is very likely the user would get the wrong mainhall loaded since their campaign files
* may still refer to the entry with the incorrect name
*/
if (strcmp(temp_string, Main_hall_defines.at(GR_640).at(count).name.c_str()) != 0) {
Error(LOCATION, "The mainhall '%s' has different names for different resolutions. Both resolutions must have the same name. Either remove the hi-res entry's name entirely or set it to match the lo-res entry's name.", Main_hall_defines.at(GR_640).at(count).name.c_str());
if (strcmp(temp_string, Main_hall_defines.at(count).at(0).name.c_str()) != 0) {
Error(LOCATION, "The mainhall '%s' has different names for different resolutions. All resolutions must have the same name. Either remove the hi-res entries' names entirely or set them to match the first resolution entry's name.", Main_hall_defines.at(0).at(count).name.c_str());
}
}
m->name = Main_hall_defines.at(GR_640).at(count).name;
m->name = Main_hall_defines.at(count).at(0).name;
}
// minimum resolution
if (optional_string("+Min Resolution:")) {
stuff_int(&m->min_width);
stuff_int(&m->min_height);
} else if (m_idx == 0) {
m->min_width = 0;
m->min_height = 0;
} else {
// bad things happened somewhere
Error(LOCATION, "Invalid value of m_idx, was expecting either GR_640 or GR_1024, got %d! Notify a coder.", m_idx);
m->min_width = GR_1024_THRESHOLD_WIDTH;
m->min_height = GR_1024_THRESHOLD_HEIGHT;
}
// minimum aspect ratio
if (optional_string("+Min Aspect Ratio:")) {
stuff_float(&m->min_aspect_ratio);
} else {
m->min_aspect_ratio = 0.0f;
}
// bitmap and mask
@@ -1935,6 +2035,26 @@ void parse_main_hall_table(const char* filename)
m->substitute_music_name = temp_string;
}
if (optional_string("+Help Overlay:")) {
stuff_string(temp_string, F_NAME, MAX_FILENAME_LEN);
m->help_overlay_name = temp_string;
}
if (optional_string("+Help Overlay Resolution Index:")) {
stuff_int(&m->help_overlay_resolution_index);
} else {
m->help_overlay_resolution_index = m_idx;
}
// zoom area
if (optional_string("+Zoom To:")) {
stuff_int(&m->zoom_area_width);
stuff_int(&m->zoom_area_height);
} else {
m->zoom_area_width = -1;
m->zoom_area_height = -1;
}
// intercom sounds
required_string("+Num Intercom Sounds:");
stuff_int(&m->num_random_intercom_sounds);
@@ -2018,9 +2138,9 @@ void parse_main_hall_table(const char* filename)
for (idx = 0; idx < m->num_misc_animations; idx++) {
// anim sound triggers
required_string("+Misc anim trigger:");
int temp = 0;
stuff_int(&temp);
for (s_idx = 0; s_idx < temp; s_idx++) {
int temp_int = 0;
stuff_int(&temp_int);
for (s_idx = 0; s_idx < temp_int; s_idx++) {
m->misc_anim_special_trigger.at(idx).push_back(0);
stuff_int(&m->misc_anim_special_trigger.at(idx).at(s_idx));
}
@@ -2080,9 +2200,26 @@ void parse_main_hall_table(const char* filename)
stuff_float(&m->door_sound_pan[idx]);
}
// font for tooltips and other text
if (optional_string("+Font:")) {
stuff_int(&m->font);
} else {
m->font = FONT1;
}
// tooltip padding
if (optional_string("+Tooltip Padding:")) {
stuff_int(&m->tooltip_padding);
} else {
m->tooltip_padding = -1; // we'll get the default value later
}
// tooltip y location
required_string("+Tooltip Y:");
stuff_int(&m->region_yval);
if (optional_string("+Tooltip Y:")) {
stuff_int(&m->region_yval);
} else {
m->region_yval = -1;
}
}
count++;
+24
View File
@@ -20,6 +20,11 @@ typedef struct main_hall_defines {
// mainhall name identifier
SCP_string name;
// minimum resolution and aspect ratio needed to display this main hall
int min_width;
int min_height;
float min_aspect_ratio;
// bitmap and mask
SCP_string bitmap;
SCP_string mask;
@@ -28,6 +33,14 @@ typedef struct main_hall_defines {
SCP_string music_name;
SCP_string substitute_music_name;
// help overlay
SCP_string help_overlay_name;
int help_overlay_resolution_index;
// zoom area
int zoom_area_width;
int zoom_area_height;
// intercom defines -------------------
// # of intercom sounds
@@ -99,9 +112,15 @@ typedef struct main_hall_defines {
// region descriptions ----------------
// font used for the tooltips, version number, etc.
int font;
// text (tooltip) description
SCP_vector<const char*> region_descript;
// num pixels shader is above/below tooltip text
int tooltip_padding;
// y coord of where to draw tooltip text
int region_yval;
@@ -138,8 +157,13 @@ main_hall_defines* main_hall_get_pointer(const SCP_string &name_to_find);
int main_hall_get_index(const SCP_string &name_to_find);
int main_hall_get_resolution_index(int main_hall_num);
void main_hall_get_name(SCP_string &name, unsigned int index);
int main_hall_get_overlay_id();
int main_hall_get_overlay_resolution_index();
// what main hall we're on
int main_hall_id();
+56 -35
View File
@@ -31,6 +31,7 @@
#include "parse/parselo.h"
#include "cfile/cfile.h"
#include "network/multi.h"
#include "debugconsole/console.h"
// --------------------------------------------------------------------------------------------------------
@@ -202,6 +203,27 @@ void player_select_cancel_create();
extern int delete_pilot_file(char *pilot_name);
/*
* validate that a pilot/player was created with the same language FSO is currently using
*
* @param pilots callsign
* @note not longer needed if intel entry "primary keys" change to a non-translated value
*/
bool valid_pilot_lang(char *callsign)
{
char pilot_lang[LCL_LANG_NAME_LEN+1], current_lang[LCL_LANG_NAME_LEN+1];
SCP_string filename = callsign;
filename += ".plr";
lcl_get_language_name(current_lang);
if (Pilot.verify(filename.c_str(), NULL, pilot_lang)) {
if (!strcmp(current_lang, pilot_lang)) {
return true;
}
}
return false;
}
// basically, gray out all controls (gray == 1), or ungray the controls (gray == 0)
void player_select_set_controls(int gray)
@@ -329,7 +351,7 @@ void player_select_do()
if ((Global_warning_count > 10 || Global_error_count > 0) && !Startup_warning_dialog_displayed) {
char text[512];
sprintf(text, "Warning!\n\nThe currently active mod has generated %d warnings and/or errors during program startup. These could have been caused by anything from incorrectly formated table files to corrupt models. While FreeSpace Open will attempt to compensate for these issues, it cannot guarantee a trouble-free gameplay experience. Source Code Project staff cannot provide assistance or support for these problems, as they are caused by the mod's data files, not FreeSpace Open's source code.", Global_warning_count + Global_error_count);
popup(PF_TITLE_BIG | PF_TITLE_RED, 1, POPUP_OK, text);
popup(PF_TITLE_BIG | PF_TITLE_RED | PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, text);
Startup_warning_dialog_displayed = true;
}
@@ -538,7 +560,14 @@ void player_select_button_pressed(int n)
if (Player_select_pilot < 0) {
popup(PF_USE_AFFIRMATIVE_ICON,1,POPUP_OK,XSTR( "You must select a valid pilot first", 378));
} else {
player_select_commit();
if (valid_pilot_lang(Pilots[Player_select_pilot])) {
player_select_commit();
} else {
popup(PF_USE_AFFIRMATIVE_ICON,1,POPUP_OK,XSTR(
"Selected pilot was created with a different language\n"
"to the currently active language.\n\n"
"Please select a different pilot or change the language", 1637));
}
}
break;
@@ -1237,39 +1266,38 @@ void player_select_cancel_create()
DCF(bastion,"Sets the player to be on the bastion (or any other main hall)")
{
int idx;
if(gameseq_get_state() != GS_STATE_INITIAL_PLAYER_SELECT) {
dc_printf("This command can only be run in the initial player select screen.\n");
dc_printf("This command can only be run while in the initial player select screen.\n");
return;
}
if (Dc_command) {
dc_get_arg(ARG_INT | ARG_NONE);
if (Dc_arg_type & ARG_INT) {
int idx = Dc_arg_int;
Assert(Main_hall_defines.at(gr_screen.res).size() < INT_MAX);
if (idx < 0 || idx >= (int) Main_hall_defines.at(gr_screen.res).size()) {
dc_printf("Main hall index out of range\n");
} else {
main_hall_get_name(Player_select_force_main_hall, idx);
dc_printf("Player is now on main hall '%d'\n", Player_select_force_main_hall.c_str());
}
} else {
Player_select_force_main_hall = "1";
dc_printf("Player is now on the Bastion... hopefully\n");
}
Dc_status = 0;
}
if (Dc_help) {
if (dc_optional_string_either("help", "--help")) {
dc_printf("Usage: bastion [index]\n");
dc_printf(" [index] -- optional main hall index; if not supplied, defaults to 1\n");
Dc_status = 0;
dc_printf(" [index] -- optional main hall index; if not supplied, defaults to 1\n");
return;
}
if (Dc_status) {
dc_printf("There is no current main hall, as the player has not been selected yet!\n");
if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
dc_printf("Player is on main hall '%s'\n", Player_select_force_main_hall.c_str());
return;
}
if (dc_maybe_stuff_int(&idx)) {
Assert(Main_hall_defines.size() < INT_MAX);
if ((idx < 0) || (idx >= (int) Main_hall_defines.size())) {
dc_printf("Main hall index out of range\n");
} else {
main_hall_get_name(Player_select_force_main_hall, idx);
dc_printf("Player is now on main hall '%d'\n", Player_select_force_main_hall.c_str());
}
} else {
// No argument passed
Player_select_force_main_hall = "1";
dc_printf("Player is now on the Bastion... hopefully\n");
}
}
@@ -1286,12 +1314,8 @@ void player_tips_init()
Num_player_tips = 0;
// begin external localization stuff
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0) {
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", "tips.tbl", rval));
lcl_ext_close();
return;
}
@@ -1306,9 +1330,6 @@ void player_tips_init()
}
Player_tips[Num_player_tips++] = stuff_and_malloc_string(F_NAME, NULL);
}
// stop externalizing, homey
lcl_ext_close();
}
// close out player tips - *only call from game_shutdown()*
+3
View File
@@ -38,4 +38,7 @@ void player_tips_close();
// select screen but let us not overwrite current values with defaults when we aren't - taylor
extern int Player_select_screen_active;
// check the pilots language
bool valid_pilot_lang(char *callsign);
#endif
+20 -23
View File
@@ -221,6 +221,9 @@ static int Background_bitmap;
static UI_WINDOW Ui_window;
static UI_BUTTON List_buttons[LIST_BUTTONS_MAX]; // buttons for each line of text in list
int Sim_room_overlay_id;
int Campaign_room_overlay_id;
// globals
bool Campaign_room_no_campaigns = false;
@@ -873,13 +876,13 @@ int readyroom_continue_campaign()
if (mc_rval == -1)
{ // is campaign and next mission valid?
gamesnd_play_iface(SND_GENERAL_FAIL);
popup(0, 1, POPUP_OK, XSTR( "The campaign is over. To replay the campaign, either create a new pilot or restart the campaign in the campaign room.", 112) );
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR( "The campaign is over. To replay the campaign, either create a new pilot or restart the campaign in the campaign room.", 112) );
return -1;
}
else if(mc_rval == -2)
{
gamesnd_play_iface(SND_GENERAL_FAIL);
popup(0, 1, POPUP_OK, NOX("The current campaign has no missions") );
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, NOX("The current campaign has no missions") );
return -1;
}
@@ -928,7 +931,7 @@ int sim_room_button_pressed(int n)
case CAMPAIGN_TAB:
if ( !strlen(Campaign.filename) ) {
popup( PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "The currently active campaign cannot be found, unable to switch to campaign mode!", 1612));
popup( PF_USE_AFFIRMATIVE_ICON | PF_NO_NETWORKING, 1, POPUP_OK, XSTR( "The currently active campaign cannot be found, unable to switch to campaign mode!", 1612));
break;
}
@@ -1049,8 +1052,8 @@ void sim_room_init()
Background_bitmap = bm_load(Sim_filename[gr_screen.res]);
// load in help overlay bitmap
help_overlay_load(SIM_ROOM_OVERLAY);
help_overlay_set_state(SIM_ROOM_OVERLAY,0);
Sim_room_overlay_id = help_overlay_get_index(SIM_ROOM_OVERLAY);
help_overlay_set_state(Sim_room_overlay_id,gr_screen.res,0);
Scroll_offset = Selected_line = 0;
@@ -1151,9 +1154,6 @@ void sim_room_close()
// free global Campaign_* list stuff
mission_campaign_free_list();
// unload the overlay bitmap
help_overlay_unload(SIM_ROOM_OVERLAY);
campaign_mission_hash_table_delete();
Ui_window.destroy();
@@ -1183,7 +1183,7 @@ void sim_room_do_frame(float frametime)
break;
}
if ( help_overlay_active(SIM_ROOM_OVERLAY) ) {
if ( help_overlay_active(Sim_room_overlay_id) ) {
Buttons[gr_screen.res][HELP_BUTTON].button.reset_status();
Ui_window.set_ignore_gadgets(1);
}
@@ -1191,14 +1191,14 @@ void sim_room_do_frame(float frametime)
k = Ui_window.process() & ~KEY_DEBUGGED;
if ( (k > 0) || B1_JUST_RELEASED ) {
if ( help_overlay_active(SIM_ROOM_OVERLAY) ) {
help_overlay_set_state(SIM_ROOM_OVERLAY, 0);
if ( help_overlay_active(Sim_room_overlay_id) ) {
help_overlay_set_state(Sim_room_overlay_id, gr_screen.res, 0);
Ui_window.set_ignore_gadgets(0);
k = 0;
}
}
if ( !help_overlay_active(SIM_ROOM_OVERLAY) ) {
if ( !help_overlay_active(Sim_room_overlay_id) ) {
Ui_window.set_ignore_gadgets(0);
}
@@ -1355,7 +1355,7 @@ void sim_room_do_frame(float frametime)
List_buttons[i++].disable();
// blit help overlay if active
help_overlay_maybe_blit(SIM_ROOM_OVERLAY);
help_overlay_maybe_blit(Sim_room_overlay_id, gr_screen.res);
gr_flip();
}
@@ -1680,8 +1680,8 @@ void campaign_room_init()
Background_bitmap = bm_load(Campaign_filename[gr_screen.res]);
// load in help overlay bitmap
help_overlay_load(CAMPAIGN_ROOM_OVERLAY);
help_overlay_set_state(CAMPAIGN_ROOM_OVERLAY,0);
Campaign_room_overlay_id = help_overlay_get_index(CAMPAIGN_ROOM_OVERLAY);
help_overlay_set_state(Campaign_room_overlay_id,gr_screen.res,0);
Num_desc_lines = 0;
Desc_scroll_offset = Scroll_offset = 0;
@@ -1723,9 +1723,6 @@ void campaign_room_close()
// free the global Campaign_* list stuff
mission_campaign_free_list();
// unload the overlay bitmap
help_overlay_unload(CAMPAIGN_ROOM_OVERLAY);
Ui_window.destroy();
common_free_interface_palette(); // restore game palette
Pilot.save_player();
@@ -1739,7 +1736,7 @@ void campaign_room_do_frame(float frametime)
int font_height = gr_get_font_height();
int select_tease_line = -1; // line mouse is down on, but won't be selected until button released
if ( help_overlay_active(CAMPAIGN_ROOM_OVERLAY) ) {
if ( help_overlay_active(Campaign_room_overlay_id) ) {
// Cr_buttons[gr_screen.res][CR_HELP_BUTTON].button.reset_status();
Ui_window.set_ignore_gadgets(1);
}
@@ -1747,14 +1744,14 @@ void campaign_room_do_frame(float frametime)
k = Ui_window.process() & ~KEY_DEBUGGED;
if ( (k > 0) || B1_JUST_RELEASED ) {
if ( help_overlay_active(CAMPAIGN_ROOM_OVERLAY) ) {
help_overlay_set_state(CAMPAIGN_ROOM_OVERLAY, 0);
if ( help_overlay_active(Campaign_room_overlay_id) ) {
help_overlay_set_state(Campaign_room_overlay_id, gr_screen.res, 0);
Ui_window.set_ignore_gadgets(0);
k = 0;
}
}
if ( !help_overlay_active(CAMPAIGN_ROOM_OVERLAY) ) {
if ( !help_overlay_active(Campaign_room_overlay_id) ) {
Ui_window.set_ignore_gadgets(0);
}
@@ -1875,7 +1872,7 @@ void campaign_room_do_frame(float frametime)
}
// blit help overlay if active
help_overlay_maybe_blit(CAMPAIGN_ROOM_OVERLAY);
help_overlay_maybe_blit(Campaign_room_overlay_id, gr_screen.res);
gr_flip();
}
+3
View File
@@ -9,6 +9,9 @@
extern int Sim_room_overlay_id;
extern int Campaign_room_overlay_id;
void sim_room_init();
void sim_room_close();
void sim_room_do_frame(float frametime);
-15
View File
@@ -188,16 +188,10 @@ void read_menu_tbl(char* menu_name, char* bkg_filename, char* mask_filename, MEN
*num_regions=0;
// open localization
lcl_ext_open();
fp = cfopen( NOX("menu.tbl"), "rt" );
if (fp == NULL) {
Error(LOCATION, "menu.tbl could not be opened\n");
// close localization
lcl_ext_close();
return;
}
@@ -208,9 +202,6 @@ void read_menu_tbl(char* menu_name, char* bkg_filename, char* mask_filename, MEN
p1 = p3 = strchr( tmp_line, '[' );
if (p3 && state == 1) {
// close localization
lcl_ext_close();
cfclose(fp);
return;
}
@@ -234,9 +225,6 @@ void read_menu_tbl(char* menu_name, char* bkg_filename, char* mask_filename, MEN
if (!p2) {
nprintf(("Warning","Error parsing menu file\n"));
// close localization
lcl_ext_close();
return;
}
*p2 = 0;
@@ -279,9 +267,6 @@ void read_menu_tbl(char* menu_name, char* bkg_filename, char* mask_filename, MEN
}
}
cfclose(fp);
// close localization
lcl_ext_close();
}
// snazzy_menu_close() is called when the menu using a snazzy interface is exited
+10 -14
View File
@@ -214,6 +214,8 @@ static int Ships_loaded = 0;
static int Weapons_loaded = 0;
static int Intel_loaded = 0;
int Techroom_overlay_id;
// out entry data struct & vars
typedef struct {
int index; // index into the master table that its in (ie Ship_info[])
@@ -394,7 +396,7 @@ void techroom_render_desc(int xo, int yo, int ho)
gr_get_string_size(&w, &h, XSTR("more", 1469), strlen(XSTR("more", 1469)));
gr_set_color_fast(&Color_black);
gr_rect(more_txt_x-2, more_txt_y, w+3, h, GR_RESIZE_MENU);
gr_set_color_fast(&Color_red);
gr_set_color_fast(&Color_more_indicator);
gr_string(more_txt_x, more_txt_y, XSTR("more", 1469), GR_RESIZE_MENU); // base location on the input x and y?
}
@@ -1030,12 +1032,8 @@ void techroom_intel_init()
if (inited)
return;
// open localization
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0) {
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", "species.tbl", rval));
lcl_ext_close();
return;
}
@@ -1073,9 +1071,6 @@ void techroom_intel_init()
}
inited = 1;
// close localization
lcl_ext_close();
}
void techroom_init()
@@ -1155,7 +1150,8 @@ void techroom_init()
Buttons[gr_screen.res][SCROLL_LIST_DOWN].button.set_hotkey(KEY_PAGEDOWN);
// init help overlay states
help_overlay_set_state(TECH_ROOM_OVERLAY, 0);
Techroom_overlay_id = help_overlay_get_index(TECH_ROOM_OVERLAY);
help_overlay_set_state(Techroom_overlay_id, gr_screen.res, 0);
// setup slider
Tech_slider.create(&Ui_window, Tech_slider_coords[gr_screen.res][SHIP_X_COORD], Tech_slider_coords[gr_screen.res][SHIP_Y_COORD], Tech_slider_coords[gr_screen.res][SHIP_W_COORD], Tech_slider_coords[gr_screen.res][SHIP_H_COORD], Num_ship_classes, Tech_slider_filename[gr_screen.res], &tech_scroll_list_up, &tech_scroll_list_down, &tech_ship_scroll_capture);
@@ -1250,7 +1246,7 @@ void techroom_do_frame(float frametime)
int i, k;
// turn off controls when overlay is on
if ( help_overlay_active(TECH_ROOM_OVERLAY) ) {
if ( help_overlay_active(Techroom_overlay_id) ) {
Buttons[gr_screen.res][HELP_BUTTON].button.reset_status();
Ui_window.set_ignore_gadgets(1);
}
@@ -1265,14 +1261,14 @@ void techroom_do_frame(float frametime)
k = Ui_window.process() & ~KEY_DEBUGGED;
if ( (k > 0) || B1_JUST_RELEASED ) {
if ( help_overlay_active(TECH_ROOM_OVERLAY) ) {
help_overlay_set_state(TECH_ROOM_OVERLAY, 0);
if ( help_overlay_active(Techroom_overlay_id) ) {
help_overlay_set_state(Techroom_overlay_id, gr_screen.res, 0);
Ui_window.set_ignore_gadgets(0);
k = 0;
}
}
if ( !help_overlay_active(TECH_ROOM_OVERLAY) ) {
if ( !help_overlay_active(Techroom_overlay_id) ) {
Ui_window.set_ignore_gadgets(0);
}
@@ -1391,7 +1387,7 @@ void techroom_do_frame(float frametime)
}
// blit help overlay if active
help_overlay_maybe_blit(TECH_ROOM_OVERLAY);
help_overlay_maybe_blit(Techroom_overlay_id, gr_screen.res);
gr_flip();
}
+2
View File
@@ -29,6 +29,8 @@ typedef struct {
#define IIF_IN_TECH_DATABASE (1 << 0) // in tech database? - Goober5000
#define IIF_DEFAULT_IN_TECH_DATABASE (1 << 1) // in tech database by default? - Goober5000
extern int Techroom_overlay_id;
extern intel_data Intel_info[MAX_INTEL_ENTRIES];
extern int Intel_info_size;
+50 -60
View File
@@ -32,6 +32,7 @@
#include "sound/fsspeech.h"
#include "species_defs/species_defs.h"
#include "iff_defs/iff_defs.h"
#include "mod_table/mod_table.h"
// --------------------------------------------------------------------------------------
@@ -135,6 +136,8 @@ int Cur_brief_id;
const char BRIEF_META_CHAR = '$';
const int HIGHEST_COLOR_STACK_INDEX = 9;
// camera related
static vec3d Current_cam_pos; // current camera position
static vec3d Target_cam_pos; // desired camera position
@@ -185,28 +188,6 @@ typedef SCP_vector<colored_char> briefing_line;
typedef SCP_vector<briefing_line> briefing_stream;
static briefing_stream Colored_stream[MAX_TEXT_STREAMS];
#define MAX_BRIEF_TEXT_COLORS 20
#define BRIEF_TEXT_WHITE 0
#define BRIEF_TEXT_BRIGHT_WHITE 1
#define BRIEF_TEXT_RED 2
#define BRIEF_TEXT_GREEN 3
#define BRIEF_TEXT_YELLOW 4
#define BRIEF_TEXT_BLUE 5
#define BRIEF_TEXT_FRIENDLY 6
#define BRIEF_TEXT_HOSTILE 7
#define BRIEF_TEXT_NEUTRAL 8
#define BRIEF_TEXT_BRIGHT_BLUE 9
#define BRIEF_TEXT_BRIGHT_GREEN 10
#define BRIEF_TEXT_BRIGHT_RED 11
#define BRIEF_TEXT_BRIGHT_YELLOW 12
#define BRIEF_TEXT_BLACK 13
#define BRIEF_TEXT_GREY 14
#define BRIEF_TEXT_SILVER 15
#define BRIEF_TEXT_VIOLET_GRAY 16
#define BRIEF_TEXT_VIOLET 17
#define BRIEF_TEXT_PINK 18
#define BRIEF_TEXT_LIGHT_PINK 19
color Brief_color_red, Brief_color_green, Brief_color_legacy_neutral;
color *Brief_text_colors[MAX_BRIEF_TEXT_COLORS] =
@@ -241,7 +222,6 @@ static int Max_briefing_line_len;
static int Voice_started_time;
static int Voice_ended_time;
const float BRIEF_TEXT_WIPE_TIME = 1.5f; // time in seconds for wipe to occur
static int Brief_text_wipe_snd; // sound handle of sound effect for text wipe
static int Play_brief_voice;
@@ -325,12 +305,8 @@ void brief_parse_icon_tbl()
Assert(!Species_info.empty());
const size_t max_icons = Species_info.size() * MIN_BRIEF_ICONS;
// open localization
lcl_ext_open();
if ((rval = setjmp(parse_abort)) != 0) {
mprintf(("TABLES: Unable to parse '%s'! Error code = %i.\n", "icons.tbl", rval));
lcl_ext_close();
return;
}
@@ -371,9 +347,6 @@ void brief_parse_icon_tbl()
}
required_string("#End");
// close localization
lcl_ext_close();
// now assign the icons to their species
const size_t num_species_covered = Briefing_icon_info.size() / MIN_BRIEF_ICONS;
@@ -1155,7 +1128,7 @@ void brief_render_map(int stage_num, float frametime)
Assert(Briefing);
g3_start_frame(0);
g3_set_view_matrix(&Current_cam_pos, &Current_cam_orient, 0.5f);
g3_set_view_matrix(&Current_cam_pos, &Current_cam_orient, Briefing_window_FOV);
brief_maybe_create_new_grid(The_grid, &Current_cam_pos, &Current_cam_orient);
brief_render_grid(The_grid);
@@ -1519,9 +1492,6 @@ ubyte brief_return_color_index(char c)
case 'P':
return BRIEF_TEXT_LIGHT_PINK;
case '|': //This is not a duplicate, but a Non-Breaking Space case. Do not remove.
return BRIEF_TEXT_WHITE;
default: //Zacam: Changed fron an Int3() in order to provide better feedback while still allowing play.
Warning(LOCATION, "Unrecognized or undefined case character: '$%c' used in Briefing in mission: '%s'. Tell Zacam.", c, Mission_filename);
} // end switch
@@ -1555,23 +1525,19 @@ bool is_a_word_separator(char character)
*
* @param src a not null pointer to a C string terminated by a /0 char.
* @param instance index into Colored_stream where the result should be placed. Value is 0 unless multiple text streams are required.
* @param[in,out] default_color_stack pointer to an array containing a stack of default colors (for color spans)
* @param[in,out] color_stack_index pointer to the current index in the above stack
* @return number of character of the resulting sequence.
*/
int brief_text_colorize(char *src, int instance)
int brief_text_colorize(char *src, int instance, ubyte default_color_stack[], int &color_stack_index)
{
Assert(src);
Assert((0 <= instance) && (instance < (int)(sizeof(Colored_stream) / sizeof(*Colored_stream))));
// manage different default colors (don't use a SCP_ stack because eh)
const int HIGHEST_COLOR_STACK_INDEX = 9;
ubyte default_color_stack[10];
int color_stack_index = 0;
briefing_line dest_line; //the resulting vector of colored character
ubyte active_color_index; //the current drawing color
// start off with white
default_color_stack[0] = active_color_index = BRIEF_TEXT_WHITE;
active_color_index = default_color_stack[color_stack_index];
int src_len = strlen(src);
for (int i = 0; i < src_len; i++)
@@ -1592,29 +1558,34 @@ int brief_text_colorize(char *src, int instance)
}
i++; // consume the }
}
// breaking character
else if (src[i] == '|')
{
active_color_index = default_color_stack[color_stack_index];
i++; // consume the |
}
// normal $c or $c{
else
{
active_color_index = brief_return_color_index(src[i]);
i++; // Consume the color identifier and focus on the white character (if any)
// special case: color spans (different default color within braces)
// (there's a slim chance that src[i] could be the null-terminator, but that's okay here)
if (src[i] == '{')
{
if (color_stack_index < HIGHEST_COLOR_STACK_INDEX)
{
color_stack_index++;
default_color_stack[color_stack_index] = active_color_index;
}
i++; // consume the {
}
}
// special case: color spans (different default color within braces)
// (there's a slim chance that src[i] could be the null-terminator, but that's okay here)
if (src[i] == '{')
{
if (color_stack_index < HIGHEST_COLOR_STACK_INDEX)
{
color_stack_index++;
default_color_stack[color_stack_index] = active_color_index;
}
i++; // consume the {
}
// Skip every whitespace until the next word is reached
while ( (i < src_len) && is_white_space(src[i]) )
i++;
//The next character is not a whitespace, let's process it as usual
//(subtract 1 because the for loop will add it again)
i--;
@@ -1643,14 +1614,23 @@ int brief_text_colorize(char *src, int instance)
* @param w max width of line in pixels
* @param instance optional parameter, used when multiple text streams are required (default value is 0)
* @param max_lines maximum number of lines
* @param[in] default_color default color for this text (defaults to BRIEF_TEXT_WHITE)
* @param[in] append add on to the existing lines instead of replacing them (defaults to false)
*/
int brief_color_text_init(const char* src, int w, int instance, int max_lines)
int brief_color_text_init(const char* src, int w, int instance, int max_lines, const ubyte default_color, const bool append)
{
int i, n_lines, len;
SCP_vector<int> n_chars;
SCP_vector<const char*> p_str;
char brief_line[MAX_BRIEF_LINE_LEN];
// manage different default colors (don't use a SCP_ stack because eh)
ubyte default_color_stack[HIGHEST_COLOR_STACK_INDEX + 1];
int color_stack_index = 0;
// start off with white, or whatever our default is
default_color_stack[0] = default_color;
Assert(src != NULL);
n_lines = split_str(src, w, n_chars, p_str, BRIEF_META_CHAR);
Assert(n_lines >= 0);
@@ -1660,14 +1640,20 @@ int brief_color_text_init(const char* src, int w, int instance, int max_lines)
n_lines = max_lines;
}
Max_briefing_line_len = 1;
Colored_stream[instance].clear();
if (!append) {
Max_briefing_line_len = 1;
Colored_stream[instance].clear();
} else if (n_lines == 0 && !strcmp(src, "\n")) { // Silly hack to allow inserting blank lines for debriefings -MageKing17
n_lines = 1;
p_str.push_back(0);
n_chars.push_back(0);
}
for (i=0; i<n_lines; i++) {
Assert(n_chars[i] < MAX_BRIEF_LINE_LEN);
strncpy(brief_line, p_str[i], n_chars[i]);
brief_line[n_chars[i]] = 0;
drop_leading_white_space(brief_line);
len = brief_text_colorize(&brief_line[0], instance);
len = brief_text_colorize(&brief_line[0], instance, default_color_stack, color_stack_index);
if (len > Max_briefing_line_len)
Max_briefing_line_len = len;
}
@@ -1675,7 +1661,11 @@ int brief_color_text_init(const char* src, int w, int instance, int max_lines)
Brief_text_wipe_time_elapsed = 0.0f;
Play_brief_voice = 0;
Num_brief_text_lines[instance] = n_lines;
if (append) {
Num_brief_text_lines[instance] += n_lines;
} else {
Num_brief_text_lines[instance] = n_lines;
}
return n_lines;
}
Loaded 100 of 233 files, more files were not shown because too many files have changed in this diff. Show more