Compare commits

..
718 changed files with 44793 additions and 140738 deletions

No files matched your search

-15
View File
@@ -1,15 +0,0 @@
# The "checkoutlist" file is used to support additional version controlled
# administrative files in $CVSROOT/CVSROOT, such as template files.
#
# The first entry on a line is a filename which will be checked out from
# the corresponding RCS file in the $CVSROOT/CVSROOT directory.
# The remainder of the line is an error message to use if the file cannot
# be checked out.
#
# File format:
#
# [<whitespace>]<filename><whitespace><error message><end-of-line>
#
# comment lines begin with '#'
new_commit_prep Error checking out/updating CVSROOT/new_commit_prep
new_log_accum Error checking out/updating CVSROOT/new_log_accum
-17
View File
@@ -1,17 +0,0 @@
# The "commitinfo" file is used to control pre-commit checks.
# The filter on the right is invoked with the repository and a list
# of files to check. A non-zero exit of the filter program will
# cause the commit to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT. For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
DEFAULT $CVSROOT/CVSROOT/new_commit_prep
CVSROOT $CVSROOT/CVSROOT/new_commit_prep
-14
View File
@@ -1,14 +0,0 @@
# Set this to "no" if pserver shouldn't check system users/passwords
#SystemAuth=no
# Put CVS lock files in this directory rather than directly in the repository.
LockDir=/var/lock/cvs
# Set `TopLevelAdmin' to `yes' to create a CVS directory at the top
# level of the new working directory when using the `cvs checkout'
# command.
#TopLevelAdmin=no
# Set `LogHistory' to `all' or `TOFEWGCMAR' to log all transactions to the
# history file, or a subset as needed (ie `TMAR' logs all write operations)
#LogHistory=TOFEWGCMAR
-23
View File
@@ -1,23 +0,0 @@
# This file affects handling of files based on their names.
#
# The -t/-f options allow one to treat directories of files
# as a single file, or to transform a file in other ways on
# its way in and out of CVS.
#
# The -m option specifies whether CVS attempts to merge files.
#
# The -k option specifies keyword expansion (e.g. -kb for binary).
#
# Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers)
#
# wildcard [option value][option value]...
#
# where option is one of
# -f from cvs filter value: path to filter
# -t to cvs filter value: path to filter
# -m update methodology value: MERGE or COPY
# -k expansion mode value: b, o, kkv, &c
#
# and value is a single-quote delimited value.
# For example:
#*.gif -k 'b'
-21
View File
@@ -1,21 +0,0 @@
# The "editinfo" file is used to allow verification of logging
# information. It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure. Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
# Making sure that the entered bug-id number is correct.
# Validating that the code that was reviewed is indeed the code being
# checked in (using the bug-id number or a seperate review
# number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported. There can be only one entry that matches a given
# repository.
-30
View File
@@ -1,30 +0,0 @@
# The "loginfo" file controls where "cvs commit" log information
# is sent. The first entry on a line is a regular expression which must match
# the directory that the change is being made to, relative to the
# $CVSROOT. If a match is found, then the remainder of the line is a filter
# program that should expect log information on its standard input.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name ALL appears as a regular expression it is always used
# in addition to the first matching regex or DEFAULT.
#
# You may specify a format string as part of the
# filter. The string is composed of a `%' followed
# by a single format character, or followed by a set of format
# characters surrounded by `{' and `}' as separators. The format
# characters are:
#
# s = file name
# V = old version number (pre-checkin)
# v = new version number (post-checkin)
#
# For example:
#DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog
# or
#DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog
DEFAULT $CVSROOT/CVSROOT/new_log_accum -m [email protected] %{sVv}
CVSROOT $CVSROOT/CVSROOT/new_log_accum -m [email protected] %{sVv}
-26
View File
@@ -1,26 +0,0 @@
# Three different line formats are valid:
# key -a aliases...
# key [options] directory
# key [options] directory files...
#
# Where "options" are composed of:
# -i prog Run "prog" on "cvs commit" from top-level of module.
# -o prog Run "prog" on "cvs checkout" of module.
# -e prog Run "prog" on "cvs export" of module.
# -t prog Run "prog" on "cvs rtag" of module.
# -u prog Run "prog" on "cvs update" of module.
# -d dir Place module in directory "dir" instead of module name.
# -l Top-level directory only -- do not recurse.
#
# NOTE: If you change any of the "Run" options above, you'll have to
# release and re-checkout any working directories of these modules.
#
# And "directory" is a path to a directory relative to $CVSROOT.
#
# The "-a" option specifies an alias. An alias is interpreted as if
# everything on the right of the "-a" had been typed on the command line.
#
# You can encode a module within a module by using the special '&'
# character to interpose another module into the current module. This
# can be useful for creating a module that consists of many directories
# spread out over the entire source repository.
-104
View File
@@ -1,104 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2000 by Kevin L. Mitchell <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
# Script to store the last visited directory for newlogaccum.pl.
#
# $Id: new_commit_prep,v 1.1 2002-08-11 23:05:15 drevil Exp $
use strict;
# This routine removes everything in a directory
sub clear_dir {
my ($dir) = @_;
my ($file);
opendir(DIR, $dir) || die "Cannot clear directory $dir: $!";
while ($file = readdir(DIR)) {
next
if ($file eq "." || $file eq "..");
$file = "$dir/$file";
if (-d $file) {
# It's a directory, recurse into it, then delete it.
clear_dir($file);
rmdir($file);
} else {
# It's a file, delete it.
unlink($file);
}
}
closedir(DIR);
}
# This routine prepares a temporary directory, hopefully in a secure
# fashion; it uses the process group to make secondary programs be able
# to find it.
sub tmpdir (;$) {
my ($clear) = @_;
my ($pgrp, $own, $mode, $tmpdir);
$pgrp = getpgrp();
die "Don't run $0 setuid!"
unless ($< == $>);
# Decide on the directory name, using various environment variables
$tmpdir = ($ENV{TMPDIR} || $ENV{TMP} || $ENV{TEMP} || "/tmp") .
"/.#cvs.$pgrp";
# Doesn't exist, but we can't create it...
die "Can't create temporary directory $tmpdir: $!"
unless (-e $tmpdir || mkdir($tmpdir, 0700));
die "Temporary directory $tmpdir is not a directory"
unless (-d $tmpdir);
# Check ownership and permissions
(undef, undef, $mode, undef, $own, undef) = stat($tmpdir);
die "Temporary directory $tmpdir not owned by $< (owned by $own)"
unless ($own == $<);
die "Temporary directory $tmpdir group-writable"
if ($mode & 0020);
die "Temporary directory $tmpdir other-writable"
if ($mode & 0002);
# If we're supposed to clear the directory, do so...
clear_dir($tmpdir)
if ($clear);
return $tmpdir;
}
# This routine writes a single line to a file
sub write_line ($$) {
my ($fname, $line) = @_;
open(FILE, ">$fname") || die "Cannot open file $fname for writing";
print FILE "$line\n";
close(FILE);
}
# Create and empty the temporary directory
my ($tmpdir) = (tmpdir(1));
# Store the directory name
write_line("$tmpdir/lastdir", shift(@ARGV));
-757
View File
@@ -1,757 +0,0 @@
#!/usr/bin/perl -w
#
# Copyright (C) 2000 by Kevin L. Mitchell <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#
# Script to accumulate log messages for an entire tree and send them along
# with the diffs; deals correctly with all manner of branching (I hope)
#
# $Id: new_log_accum,v 1.3 2003-09-07 12:46:59 drevil Exp $
#
use strict;
use vars qw($MAILER $CVS $debug $boundary);
use Digest::MD5;
# Set this to the full path of a mailer that takes a list
# of email addresses as arguments...
$MAILER = "/usr/sbin/sendmail -oi -oeq";
# Set this to the path of the CVS binary responsible for this tree...
$CVS = "/usr/bin/cvs";
# Don't touch this; use the -d command line option
$debug = 0;
# This is initialized by build_mailheader()
$boundary = '';
use POSIX qw(setsid);
# We have to dissociate from our parent, so that the CVS commit can
# complete, before we try to extract the diffs
sub daemonize {
defined(my $pid = fork()) || die "Can't fork: $!";
exit(0)
if $pid;
setsid() || die "Can't start a new session: $!";
}
# Debugging output
sub debug (@) {
print STDERR @_
if ($debug);
}
# Constants used in the FSM below for parsing the log message
sub STATE_NONE { 0 }
sub STATE_MODIFIED { 1 }
sub STATE_ADDED { 2 }
sub STATE_REMOVED { 3 }
sub STATE_LOG1 { 4 }
sub STATE_LOG2 { 5 }
# This routine removes everything in a directory
sub clear_dir {
my ($dir) = @_;
my ($file);
opendir(DIR, $dir) || die "Cannot clear directory $dir: $!";
while ($file = readdir(DIR)) {
next
if ($file eq "." || $file eq "..");
$file = "$dir/$file";
if (-d $file) {
# It's a directory, recurse into it, then delete it.
clear_dir($file);
rmdir($file);
} else {
# It's a file, delete it.
unlink($file);
}
}
closedir(DIR);
}
# This routine prepares a temporary directory, hopefully in a secure
# fashion; it uses the process group to make secondary programs be able
# to find it.
sub tmpdir (;$) {
my ($clear) = @_;
my ($pgrp, $own, $mode, $tmpdir);
$pgrp = getpgrp();
die "Don't run $0 setuid!"
unless ($< == $>);
# Decide on the directory name, using various environment variables
$tmpdir = ($ENV{TMPDIR} || $ENV{TMP} || $ENV{TEMP} || "/tmp") .
"/.#cvs.$pgrp";
# Doesn't exist, but we can't create it...
die "Can't create temporary directory $tmpdir: $!"
unless (-e $tmpdir || mkdir($tmpdir, 0700));
die "Temporary directory $tmpdir is not a directory"
unless (-d $tmpdir);
# Check ownership and permissions
(undef, undef, $mode, undef, $own, undef) = stat($tmpdir);
die "Temporary directory $tmpdir not owned by $< (owned by $own)"
unless ($own == $<);
die "Temporary directory $tmpdir group-writable"
if ($mode & 0020);
die "Temporary directory $tmpdir other-writable"
if ($mode & 0002);
# If we're supposed to clear the directory, do so...
clear_dir($tmpdir)
if ($clear);
return $tmpdir;
}
# Routine to remove the temporary directory when done
sub cleanup_dir ($) {
# If we're debugging, we may want to look at the contents...
return
if ($debug);
clear_dir($_[0]);
rmdir($_[0]);
}
# Retrieve a single line from a specified file
sub get_line ($) {
my ($fname) = @_;
open(FILE, "<$fname") || die "Cannot open file $fname for reading";
my $line = <FILE>;
close(FILE);
# Chomp off the \n
chomp $line;
return $line;
}
# Routine that only allows one value to be pushed on the array;
# implemented by making the first element of the array a hash-reference.
# When we add a new value, we also increment the count of an element in
# the hash with the key being the array value...
sub push_once (\@@) {
my ($array, @values) = @_;
# If the array is empty, create our hash ref
push @{$array}, {}
if (@{$array} == 0);
foreach my $value (@values) {
push @{$array}, $value
if (!exists($array->[0]{$value}));
$array->[0]{$value}++;
}
return @{$array} - 1;
}
# Filter //, /./, and remove leading ./ or / from filenames
sub fname_filter ($) {
my ($fname) = @_;
$fname =~ s,//,/,g;
$fname =~ s,/\./,/,g;
$fname =~ s,^\.?/,,g;
return $fname;
}
# Store file data in a temporary file
sub names_to_file ($$@) {
my ($fname, $dir, @names) = @_;
if (@names > 0) {
open(FILE, ">>$fname") || die "Cannot open file $fname for appending";
# Store the directory data
print FILE "D $dir\n";
foreach my $name (@names) {
# Mark record as a file...
print FILE "F ";
# Store the tag, if there is one...
print FILE "$name->{tag}"
if (defined($name->{tag}));
# Then store old revision, new revision, and file name
print FILE ":$name->{old}:$name->{new}:$name->{file}\n";
}
close(FILE);
}
}
# Retrieve file data from temporary file; updates branch tags with what it
# reads
sub file_to_names (\@$) {
my ($btags, $fname) = @_;
my ($dir) = (undef);
my (@names) = ();
debug "Reading file names from $fname...\n";
# We may not have, say, added a file in this subdirectory...
return ()
if (!-e $fname);
open(FILE, "<$fname");
while(<FILE>) {
chomp;
# Get record type...
my ($type, $data) = split(' ', $_, 2);
# ok, it's a directory, remember that...
if ($type eq "D") {
$dir = $data;
debug "Read directory $dir\n";
next;
}
debug "Read file $data\n";
# Get all the information about the file
my ($tag, $old, $new, $file) = split(':', $data);
# and store it all
push(@names, { tag => $tag, old => $old, new => $new, file => $file,
dir => $dir, name => fname_filter("$dir/$file") });
# Remember the tags...
push_once(@{$btags}, $tag)
if (defined($tag) && $tag ne "");
}
close(FILE);
return @names;
}
# Create a text-formatted list of names
sub name_to_list (\@@) {
my ($btags, @names) = @_;
my (@nlist, @nline) = ();
debug "Tags:", join(':', @{$btags}), "\n";
# We group them by tag
foreach my $tag ("", @{$btags}[1..$#{$btags}]) {
debug "Processing tag $tag...\n";
@nlist = ();
# Get a list of files by the tag...
foreach my $name (@names) {
debug "Processing $name->{file}...\n";
next
if ($name->{tag} ne $tag);
debug "Pushing $name->{name} on \@nlist...\n";
push(@nlist, $name->{name});
}
# If the tag is not the empty string, list the tag...
push(@nline, " Tag: $tag", " ")
if ($tag ne "");
# Now list each file name
foreach my $name (@nlist) {
# indent if we run past the end of line limit
push(@nline, " ")
if (@nline == 0 || ($nline[$#nline] ne " " &&
length($nline[$#nline]) + length($name) + 1 > 70));
# add the file name to the list
debug "Adding $name to \@nline...\n";
$nline[$#nline] .= " $name";
}
}
return @nline;
}
# write the log message to a temporary file
sub write_log ($@) {
my ($fname, @text) = @_;
open(FILE, ">$fname") || die "Cannot open file $fname for writing";
print FILE join("\n", @text), "\n";
close(FILE);
}
# Build the header of the commit message: CVSROOT, module name, any
# branch tags, and the commit time
sub build_header ($@) {
my ($module, $subject, $mailto, @branch_tags) = @_;
my (@text, @mailto);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time());
my ($user, $dummy);
my ($digest);
($user, $dummy, $dummy, $dummy, $dummy, $dummy, $dummy) = getpwuid($<);
@mailto = @{$mailto};
# generate a unique boundary by calculating the md5sum of the
# current time
$digest = new Digest::MD5;
$digest->reset();
$digest->add(time() . rand());
$boundary = "----=MIME." . unpack("H*", $digest->digest());
# Build the mail header
push(@text, 'From: [email protected]');
push(@text, "To: " . join(' ', @mailto));
push(@text, "Subject: $subject");
push(@text, "MIME-Version: 1.0");
push(@text, "Content-Type: multipart/mixed; boundary=\"$boundary\"");
push(@text, "");
push(@text, "This is a multipart message as defined by RFC2049 (MIME)");
push(@text, "");
push(@text, "--$boundary");
push(@text, "Content-Type: text/plain; charset=us-ascii");
push(@text, "Content-Disposition: inline");
push(@text, "");
# Build the commit message header
push(@text, "Commiter : $user");
push(@text, "CVSROOT : $ENV{CVSROOT}");
push(@text, "Module : $module");
push(@text, "Branch tags: " . join(' ', @branch_tags[1..$#branch_tags]))
if (@branch_tags > 0);
push(@text, sprintf("Commit time: %04d-%02d-%02d %02d:%02d:%02d UTC",
$year + 1900, $mon + 1, $mday, $hour, $min, $sec));
return @text, "";
}
# Send the mail message
sub send_mail {
my ($mailto, $text) = @_;
my (@mailto, @text);
# I <heart> perl
@mailto = @{$mailto};
@text = @{$text};
open(MAIL, "|$MAILER " . join(' ', @mailto));
push(@text, "--$boundary--", "");
print MAIL join("\n", @text), "\n";
close(MAIL);
}
# Find the tmp directory
my ($tmpdir) = (tmpdir());
my (@mailto) = ();
my (@files) = ();
my (@path) = ();
my ($modname, $repdir, $dir) = (undef, undef, undef);
# Process command line arguments
while (@ARGV > 0) {
my ($arg) = (shift(@ARGV));
if ($arg eq '-d') {
# Turn on debugging
$debug++;
} elsif ($arg eq '-M') {
# Module name explicitly set -- XXX Not tested, use at your own risk
die "Argument for -M missing"
unless (@ARGV > 0);
$modname = shift(@ARGV);
} elsif ($arg eq '-m') {
# An address to mail the notification to
die "Argument for -m missing"
unless (@ARGV > 0);
push(@mailto, shift(@ARGV));
} else {
# the list of filenames passed by CVS--you *must* use %{sVv}!
die "Too many arguments!"
unless (@files == 0);
@files = split(" ", $arg);
}
}
die "Nobody to mail to"
unless (@mailto > 0);
die "No files to process"
unless (@files > 1);
# The repository directory
$repdir = shift(@files);
# break it appart...
@path = split("/", $repdir);
# Now we know the module name, if it wasn't explicitly set
$modname = $path[0]
unless (defined($modname));
# Figure out what our directory is
if (@path == 1) {
$dir = ".";
} else {
$dir = join("/", @path[1..$#path]);
}
# append a / to it...
$dir .= "/";
debug "module = $modname\n";
debug "dir = $dir\n";
debug "path = ", join(":", @path), "\n";
debug "files = ", join(":", @files), "\n";
debug "tmpdir = $tmpdir\n";
my (%fversions);
# Unless its a new directory or imported sources, create file records
unless (defined($files[1]) && defined($files[2]) &&
(($files[1] eq "New" && $files[2] eq "directory") ||
($files[1] eq "Imported" && $files[2] eq "sources"))) {
foreach my $fname (@files) {
# You *must* use %{sVv} in the call in loginfo!
die "Invalid filenames"
unless ($fname =~ /^(.*),([0-9.]+|NONE),([0-9.]+|NONE)$/);
$fversions{$1} = {
old => ($2 eq "NONE" ? "0" : $2),
new => ($3 eq "NONE" ? "0" : $3),
};
}
}
# process log message
my ($state, $tag) = (STATE_NONE, undef);
my (@modified, @added, @removed, @log, @branch_tags) = ();
while (<STDIN>) {
chomp;
debug "State $state, line:$_\n";
# Ignore empty space at the beginning of the log message
next
if ($state == STATE_LOG1 && /^\s*$/);
# We're done ignoring empty space
if ($state == STATE_LOG1) {
$state = STATE_LOG2;
}
if ($state == STATE_LOG2) {
# Don't modify the lines at all if we're processing the log message
push(@log, $_);
next;
} else {
# Strip out leading and trailing space
s/^\s*(.*?)\s*$/$1/;
}
if (/^Modified Files/) {
# Collect list of modified files
debug "State switching to STATE_MODIFIED\n";
$state = STATE_MODIFIED;
$tag = undef;
next;
} elsif (/^Added Files/) {
# Collect list of added files
debug "State switching to STATE_ADDED\n";
$state = STATE_ADDED;
$tag = undef;
next;
} elsif (/^Removed Files/) {
# Collect list of removed files
debug "State switching to STATE_REMOVED\n";
$state = STATE_REMOVED;
$tag = undef;
next;
} elsif (/^Log Message/) {
# Collect log message
debug "State switching to STATE_LOG1\n";
$state = STATE_LOG1;
$tag = undef;
next;
} elsif (/^Revision\/Branch/) {
# Parse old-style Revision/Branch field
debug "Found a branch tag\n";
/^[^:]+:\s*(.*)/;
push_once(@branch_tags, $1);
warn "Tag == $tag"
if (defined($tag));
next;
}
# Ignore the stuff at the top of the commit report
next
if ($state == STATE_NONE);
if (/^Tag:\s*(.*)$/) {
# Remember the tag
debug "Setting tag to $1\n";
$tag = $1;
next;
}
my (@tfiles) = ();
# Find the file in our command line list of files
foreach my $file (split) {
die "Nothing known about file $file!"
unless (exists($fversions{$file}));
push @tfiles, {
file => $file,
tag => $tag,
old => $fversions{$file}{old},
new => $fversions{$file}{new},
};
}
# Store the file list in the correct array
push(@modified, @tfiles)
if ($state == STATE_MODIFIED);
push(@added, @tfiles)
if ($state == STATE_ADDED);
push(@removed, @tfiles)
if ($state == STATE_REMOVED);
}
# Remove trailing blank lines from the log message
while (@log > 0 && $log[$#log] =~ /^\s*$/) {
pop(@log);
}
# If a new directory was added, we're done...
if (defined($files[1]) && defined($files[2]) &&
$files[1] eq "New" && $files[2] eq "directory") {
my (@text) = ();
# If there was a sticky tag for the directory, make it a branch tag
if ($log[$#log] =~ /^--> Using per-directory sticky tag \`(.*)\'$/) {
push_once(@branch_tags, $1);
pop(@log);
}
# Build the message...
push(@text, build_header($modname, "Module $modname: New directory $dir",
\@mailto, @branch_tags));
push(@text, "Log message:", "", @log);
# and send it (synchronously)
send_mail(\@mailto, \@text);
# Clean up after ourselves and exit.
cleanup_dir($tmpdir);
exit(0);
}
# If an import was done, we're done...
if (defined($files[1]) && defined($files[2]) &&
$files[1] eq "Imported" && $files[2] eq "sources") {
my (@text) = ();
# Build the message...
push(@text, build_header($modname, "Module $modname: Imported $dir",
\@mailto, @branch_tags));
push(@text, "Log message:", "", @log);
# and send it (synchronously)
send_mail(\@mailto, \@text);
# Clean up after ourselves and exit.
cleanup_dir($tmpdir);
exit(0);
}
debug "Searching for log file index...";
my ($i);
# Look for an empty log file or one that matches our current log message
for ($i = 0; ; $i++) {
my (@text);
# found one that doesn't exist...
last
if (!-e "$tmpdir/logfile.$i");
# read in the log file
open(FILE, "<$tmpdir/logfile.$i");
while (<FILE>) {
chomp;
push(@text, $_);
}
close(FILE);
# If the log file was empty, use it
last
if (@text == 0);
# If the log messages are identical, use that
last
if (join(' ', @log) eq join(' ', @text));
}
debug "$tmpdir/logfile.$i\n";
# Store modified, added, and removed file lists, along with the log message
names_to_file("$tmpdir/modified.$i", $dir, @modified);
names_to_file("$tmpdir/added.$i", $dir, @added);
names_to_file("$tmpdir/removed.$i", $dir, @removed);
write_log("$tmpdir/logfile.$i", @log);
# Now check to see if we're at the end of our rope
my ($lastdir) = (get_line("$tmpdir/lastdir"));
debug "Checking $ENV{CVSROOT}/$repdir against lastdir $lastdir\n";
# Nope, exit instead of sending a message
exit(0)
if ($lastdir ne "$ENV{CVSROOT}/$repdir");
debug "At last, we've reached the end\n";
# We have to daemonize and sleep so that there isn't any lock hanging
# around when we get to the cvs rdiff below...
daemonize();
sleep(10);
# Build the mail message...
my (@text) = ();
@files = ();
@branch_tags = ();
for ($i = 0; ; $i++) {
# No more log files
last
if (!-e "$tmpdir/logfile.$i");
# read and insert the log message
open(FILE, "<$tmpdir/logfile.$i");
push(@text, "Log message:", "");
while (<FILE>) {
chomp;
push(@text, $_);
}
push(@text, "");
close(FILE);
# read modified list and list all modified files if non-empty
@modified = file_to_names(@branch_tags, "$tmpdir/modified.$i");
push(@text, "Modified files:", name_to_list(@branch_tags, @modified), "")
if (@modified > 0);
# read added list and list all added files if non-empty
@added = file_to_names(@branch_tags, "$tmpdir/added.$i");
push(@text, "Added files:", name_to_list(@branch_tags, @added), "")
if (@added > 0);
# read removed list and list all removed files if non-empty
@removed = file_to_names(@branch_tags, "$tmpdir/removed.$i");
push(@text, "Removed files:", name_to_list(@branch_tags, @removed), "")
if (@removed > 0);
# remember all the files we looked at
push(@files, @modified, @added, @removed);
}
# Now that name_to_list has rebuilt our list of branch tags, we can build the
# header and prepend it to the message
unshift(@text, build_header($modname, "Module $modname: Change committed",
\@mailto, @branch_tags));
# sort the files out for our diff
@files = sort { $a->{name} cmp $b->{name} } @files;
my ($user, $filename);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time());
$user = getpwuid($<);
$filename = sprintf("%s.%04d%02d%02d.%02d%02d%02d.%s.diff", $modname,
$year + 1900, $mon + 1, $mday, $hour, $min, $sec, $user);
push(@text, "--$boundary");
push(@text, "Content-Type: text/plain; name=\"$filename\"");
push(@text, "Content-Disposition: attachment; filename=\"$filename\"");
push(@text, "Content-Transfer-Encoding: 8bit");
push(@text, "");
foreach my $file (@files) {
debug "Diffing file $file->{name}...\n";
# Run cvs rdiff, extracting a diff between the old version and the new
open(DIFF, "$CVS -Q rdiff -u -r $file->{old} -r $file->{new} " .
"$modname/$file->{name}|");
while (<DIFF>) {
chomp;
push(@text, $_);
}
close(DIFF);
}
# send the mail...
send_mail(\@mailto, \@text);
# and clean up after ourselves
cleanup_dir($tmpdir);
-12
View File
@@ -1,12 +0,0 @@
# The "notify" file controls where notifications from watches set by
# "cvs watch add" or "cvs edit" are sent. The first entry on a line is
# a regular expression which is tested against the directory that the
# change is being made to, relative to the $CVSROOT. If it matches,
# then the remainder of the line is a filter program that should contain
# one occurrence of %s for the user to notify, and information on its
# standard input.
#
# "ALL" or "DEFAULT" can be used in place of the regular expression.
#
# For example:
#ALL mail %s -s "CVS notification"
-19
View File
@@ -1,19 +0,0 @@
drevil:f76FWdDTUBG5c:fs2source
mysterial:f7nJUwoIhmSrg:fs2source
wmcoolmon:f7JRB.js9Q1sE:fs2source
inquisitor:f7BVkOvwjDlWk:fs2source
penguin:Jh.dOjaiO2jHk:fs2source
DTP:f7M92Z/6/uep.:fs2source
unknownplayer:f79BgAn.IzJs6:fs2source
phreak:f7WQyGiT/jzlM:fs2source
randomtiger:f7Way/xL9ic7o:fs2source
righteous1:f7fpcXiE0Ubao:fs2source
bobboau:f7jChSbXOIdWY:fs2source
sesquipedalian:f75AcAOV6TM6Q:fs2source
daveb:f7f2mVbMvbe.6:fs2source
Goober5000:f7Fc.gHzyrOL2:fs2source
dkharrat:f7odljbD5tm5k:fs2source
EdrickV:f7cDahmEbbAlg:fs2source
OldMan:f7N4NyUG5Ommw:fs2source
komet:f7fyoBN5r.m76:fs2source
anonymous:oIKtWP1q6GDt6:fs2source
-13
View File
@@ -1,13 +0,0 @@
# The "rcsinfo" file is used to control templates with which the editor
# is invoked on commit and import.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being made to, relative to the
# $CVSROOT. For the first match that is found, then the remainder of the
# line is the name of the file that contains the template.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
-20
View File
@@ -1,20 +0,0 @@
# The "taginfo" file is used to control pre-tag checks.
# The filter on the right is invoked with the following arguments:
#
# $1 -- tagname
# $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d
# $3 -- repository
# $4-> file revision [file revision ...]
#
# A non-zero exit of the filter program will cause the tag to be aborted.
#
# The first entry on a line is a regular expression which is tested
# against the directory that the change is being committed to, relative
# to the $CVSROOT. For the first match that is found, then the remainder
# of the line is the name of the filter to run.
#
# If the repository name does not match any of the regular expressions in this
# file, the "DEFAULT" line is used, if it is specified.
#
# If the name "ALL" appears as a regular expression it is always used
# in addition to the first matching regex or "DEFAULT".
-21
View File
@@ -1,21 +0,0 @@
# The "verifymsg" file is used to allow verification of logging
# information. It works best when a template (as specified in the
# rcsinfo file) is provided for the logging procedure. Given a
# template with locations for, a bug-id number, a list of people who
# reviewed the code before it can be checked in, and an external
# process to catalog the differences that were code reviewed, the
# following test can be applied to the code:
#
# Making sure that the entered bug-id number is correct.
# Validating that the code that was reviewed is indeed the code being
# checked in (using the bug-id number or a seperate review
# number to identify this particular code set.).
#
# If any of the above test failed, then the commit would be aborted.
#
# Actions such as mailing a copy of the report to each reviewer are
# better handled by an entry in the loginfo file.
#
# One thing that should be noted is the the ALL keyword is not
# supported. There can be only one entry that matches a given
# repository.
-18
View File
@@ -1,18 +0,0 @@
drevil
inquisitor
mysterial
DTP
randomtiger
wmcoolmon
unknownplayer
phreak
bobboau
righteous1
sesquipedalian
Goober5000
dkharrat
daveb
EdrickV
OldMan
komet
penguin
-25
View File
@@ -1,25 +0,0 @@
Makefile
Makefile.in
configure
FS2_Open.prj
FS2_Open.prj.bak
FS2_Open.pws
.tm_project.cache
config.guess
config.cache
config.log
config.status
config.sub
depcomp
install-sh
missing
mkinstalldirs
autom4te*
aclocal.m4
Freespace2.dsp
Freespace2.dsw
Freespace2.ncb
Freespace2.opt
Freespace2.plg
Release
Debug
@@ -43,24 +43,24 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G5 /MT /W2 /GX /Zi /Ot /Ow /Og /Oi /Oy /I "..\..\code" /I "..\..\oggvorbis\include" /I "c:\dxsdk\include\\" /I "..\..\dx8sdk\include" /D "_MBCS" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /U "_DEBUG" /FR /YX /FD /c
# ADD CPP /nologo /G5 /MT /W2 /GX /Zi /Ot /Ow /Og /Oi /Oy /I "code" /I "c:\mssdk\include\\" /I "c:\dxsdk\include" /I "c:\speech_api\include" /I "c:\devil-sdk\include" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WIN32" /D "USE_OPENGL" /D "HTL" /D "MORE_SPECIES" /U "_DEBUG" /FR /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo /o"Release\Profile\Freespace2.bsc" "Release\Profile\*.sbr"
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 Quartz.lib Dxerr8.lib d3d8.lib d3dx8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib vfw32.lib msacm32.lib comctl32.lib libjpeg.lib ogg_static.lib vorbis_static.lib vorbisfile_static.lib code.lib /nologo /subsystem:windows /map /debug /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libcd.lib" /out:"Release/fs2_open_r.exe" /libpath:"Release" /libpath:"..\..\oggvorbis\lib" /libpath:"..\..\dx8sdk\lib" /libpath:"c:\dxsdk\lib"
# ADD LINK32 Quartz.lib Dxerr8.lib d3d8.lib d3dx8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib vfw32.lib msacm32.lib comctl32.lib code.lib /nologo /subsystem:windows /map /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libcd.lib" /out:"C:\games\freespace2\fs2_open_r.exe" /libpath:"release" /libpath:"c:\mssdk\lib" /libpath:"c:\dxsdk\lib" /libpath:"c:\speech_api\lib"
# SUBTRACT LINK32 /pdb:none
# Begin Custom Build - Copying build...
InputPath=.\Release\fs2_open_r.exe
# Begin Custom Build - Copying $(InputPath) to D:\games\freespace2
InputPath=\games\freespace2\fs2_open_r.exe
SOURCE="$(InputPath)"
"$(FS2PATH)/fs2_open_r.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(InputPath) "$(FS2PATH)/fs2_open_r.exe"
"d:\games\freespace2\fs2_open_r.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(InputPath) d:\games\freespace2\fs2_open_r.exe
# End Custom Build
@@ -78,24 +78,24 @@ SOURCE="$(InputPath)"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /G5 /MTd /W4 /Gm /Gi /GX /ZI /Od /I "..\..\code" /I "..\..\oggvorbis\include" /I "c:\dxsdk\include\\" /I "..\..\dx8sdk\include" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /U "NDEBUG" /FR /YX /FD /GZ /GZ /c
# ADD CPP /nologo /G5 /MTd /W4 /Gm /Gi /GX /ZI /Od /I "code" /I "c:\mssdk\include\\" /I "c:\dxsdk\include" /I "c:\speech_api\include" /I "c:\devil-sdk\include" /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "NO_CD_CHECK" /D "MORE_SPECIES" /U "NDEBUG" /Fr /YX /FD /GZ /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo /o"Debug\Profile\Freespace2.bsc" "Debug\Profile\*.sbr"
# ADD BSC32 /nologo /o"debug/profile/Freespace2.bsc" "./debug/profile/*.sbr"
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 Quartz.lib d3d8.lib d3dx8.lib DxErr8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib vfw32.lib msacm32.lib comctl32.lib ogg_static.lib vorbis_static.lib vorbisfile_static.lib libjpeg_d.lib code.lib /nologo /subsystem:windows /map /debug /debugtype:both /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libcd.lib" /nodefaultlib:"libcmt.lib" /out:"Debug/fs2_open_d.exe" /libpath:"Debug" /libpath:"..\..\oggvorbis\lib" /libpath:"..\..\dx8sdk\lib" /libpath:"c:\dxsdk\lib\\"
# SUBTRACT LINK32 /pdb:none /incremental:no
# Begin Custom Build - Copying build...
InputPath=.\Debug\fs2_open_d.exe
# ADD LINK32 Quartz.lib d3d8.lib d3dx8.lib DxErr8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib vfw32.lib msacm32.lib comctl32.lib code.lib Dxerr8.lib d3d8.lib d3dx8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib vfw32.lib msacm32.lib comctl32.lib code.lib Dxerr8.lib d3d8.lib d3dx8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib vfw32.lib msacm32.lib comctl32.lib code.lib Dxerr8.lib d3d8.lib d3dx8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib winmm.lib vfw32.lib msacm32.lib comctl32.lib code.lib /nologo /subsystem:windows /debug /debugtype:both /machine:I386 /nodefaultlib:"libc.lib" /nodefaultlib:"libcd.lib" /out:"C:\games\freespace2\fs2_open_d.exe" /libpath:"debug" /libpath:"c:\mssdk\lib" /libpath:"c:\dxsdk\lib" /libpath:"c:\speech_api\lib"
# SUBTRACT LINK32 /pdb:none /incremental:no /map
# Begin Custom Build - Copying $(InputPath) to D:\games\freespace2
InputPath=\games\freespace2\fs2_open_d.exe
SOURCE="$(InputPath)"
"$(FS2PATH)/fs2_open_d.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(InputPath) "$(FS2PATH)/fs2_open_d.exe"
"d:\games\freespace2\fs2_open_d.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(InputPath) d:\games\freespace2\fs2_open_d.exe
# End Custom Build
@@ -107,55 +107,59 @@ SOURCE="$(InputPath)"
# Name "Freespace2 - Win32 Debug"
# Begin Source File
SOURCE=..\..\code\FREESPACE2\app_icon.ico
SOURCE=.\code\FREESPACE2\app_icon.ico
# End Source File
# Begin Source File
SOURCE=..\..\code\FREESPACE2\FreeSpace.cpp
SOURCE=.\code\FREESPACE2\FreeSpace.cpp
# End Source File
# Begin Source File
SOURCE=..\..\code\FREESPACE2\FreeSpace.h
SOURCE=.\code\FREESPACE2\FreeSpace.h
# End Source File
# Begin Source File
SOURCE=..\..\code\FREESPACE2\FreeSpace.rc
SOURCE=.\code\FREESPACE2\FreeSpace.rc
# End Source File
# Begin Source File
SOURCE=..\..\code\FREESPACE2\FreespaceResource.h
SOURCE=.\code\FREESPACE2\FreespaceResource.h
# End Source File
# Begin Source File
SOURCE=..\..\code\freespace2\goal_com.bmp
SOURCE=.\code\freespace2\goal_com.bmp
# End Source File
# Begin Source File
SOURCE=..\..\code\freespace2\goal_fail.bmp
SOURCE=.\code\freespace2\goal_fail.bmp
# End Source File
# Begin Source File
SOURCE=..\..\code\freespace2\goal_inc.bmp
SOURCE=.\code\freespace2\goal_inc.bmp
# End Source File
# Begin Source File
SOURCE=..\..\code\freespace2\goal_none.bmp
SOURCE=.\code\freespace2\goal_none.bmp
# End Source File
# Begin Source File
SOURCE=..\..\code\freespace2\goal_ord.bmp
SOURCE=.\code\freespace2\goal_ord.bmp
# End Source File
# Begin Source File
SOURCE=..\..\code\graphics\grstub.h
SOURCE=.\code\graphics\grstub.h
# End Source File
# Begin Source File
SOURCE=..\..\code\FREESPACE2\LevelPaging.cpp
SOURCE=.\code\FREESPACE2\LevelPaging.cpp
# End Source File
# Begin Source File
SOURCE=..\..\code\FREESPACE2\LevelPaging.h
SOURCE=.\code\FREESPACE2\LevelPaging.h
# End Source File
# Begin Source File
SOURCE=.\code\network\multiui.cpp
# End Source File
# End Target
# End Project
@@ -1,74 +1,44 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "Freespace2"=".\Freespace2.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name code
End Project Dependency
Begin Project Dependency
Project_Dep_Name libjpeg
End Project Dependency
}}}
###############################################################################
Project: "code"=".\code.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "libjpeg"=".\libjpeg.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "wxFRED2"=".\wxFRED2.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name code
End Project Dependency
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "Freespace2"=".\Freespace2.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name code
End Project Dependency
}}}
###############################################################################
Project: "code"=".\code\code.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
+1 -64
View File
@@ -2,67 +2,4 @@
#
# This file uses GNU Automake to generate makefiles
SUBDIRS = libjpeg code
EXTRA_DIST = \
FS2OpenSCPReadMe.doc \
projects/MSVC_2005/Freespace2.sln \
projects/MSVC_2005/Freespace2.vcproj \
projects/MSVC_2005/code.vcproj \
projects/MSVC_6/Freespace2.dsp \
projects/MSVC_6/Freespace2.dsw \
projects/MSVC_6/code.dsp \
projects/MSVC_6/libjpeg.dsp \
projects/MSVC_6/wxFRED2.dsp \
projects/anjuta1/FS2_Open.prj \
projects/anjuta1/README
# D_ variants are defaults and should always be used
AM_CXXFLAGS = -I./code @D_CFLAGS@
AM_LDFLAGS = @D_LDFLAGS@
EXTRA_PROGRAMS = cfilearchiver cfileextractor cryptstring scramble
###############################################################################
##
## Begin utilitites
##
# cfilearchiver -- to create VPs
cfilearchiver_SOURCES = \
code/cfilearchiver/cfilearchiver.cpp
# cfileextractor -- to extract files from VPs
cfileextractor_SOURCES = \
code/cfileextractor/cfileextractor.cpp
# cryptstring -- to encrypt strings that are used as cheat codes
cryptstring_SOURCES = \
code/cryptstring/cryptstring.cpp
# scramble -- to encrypt tables
scramble_SOURCES = \
code/parse/encrypt.cpp \
code/scramble/scramble.cpp \
code/scramble/scramble.h
# catch all to build utilitites
tools: cfilearchiver cfileextractor cryptstring scramble
# cleaning
clean-tools:
-test -z "$(EXTRA_PROGRAMS)" || rm -f $(EXTRA_PROGRAMS)
##
## End utilitites
##
###############################################################################
# make sure we get this stuff cleaned up
clean-generic: clean-tools
SUBDIRS = code
+506
View File
@@ -0,0 +1,506 @@
# Makefile.in generated by automake 1.7.2 from Makefile.am.
# @configure_input@
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
# Makefile.am for fs2_open (top level)
#
# This file uses GNU Automake to generate makefiles
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DX8_INCLUDE = @DX8_INCLUDE@
DX8_LIB = @DX8_LIB@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EXEEXT = @EXEEXT@
FS2_GRSOFT_FALSE = @FS2_GRSOFT_FALSE@
FS2_GRSOFT_TRUE = @FS2_GRSOFT_TRUE@
FS2_JOYSTICK_FALSE = @FS2_JOYSTICK_FALSE@
FS2_JOYSTICK_TRUE = @FS2_JOYSTICK_TRUE@
FS2_NETWORKING_FALSE = @FS2_NETWORKING_FALSE@
FS2_NETWORKING_TRUE = @FS2_NETWORKING_TRUE@
FS2_OS_UNIX_FALSE = @FS2_OS_UNIX_FALSE@
FS2_OS_UNIX_TRUE = @FS2_OS_UNIX_TRUE@
FS2_OS_WIN32_FALSE = @FS2_OS_WIN32_FALSE@
FS2_OS_WIN32_TRUE = @FS2_OS_WIN32_TRUE@
FS2_SOUND_FALSE = @FS2_SOUND_FALSE@
FS2_SOUND_TRUE = @FS2_SOUND_TRUE@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
SUBDIRS = code
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_CLEAN_FILES =
DIST_SOURCES =
RECURSIVE_TARGETS = info-recursive dvi-recursive pdf-recursive \
ps-recursive install-info-recursive uninstall-info-recursive \
all-recursive install-data-recursive install-exec-recursive \
installdirs-recursive install-recursive uninstall-recursive \
check-recursive installcheck-recursive
DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \
Makefile.in NEWS aclocal.m4 config.guess config.sub configure \
configure.in depcomp install-sh missing mkinstalldirs
DIST_SUBDIRS = $(SUBDIRS)
all: all-recursive
.SUFFIXES:
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)
$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): configure.in
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ETAGS = etags
ETAGSFLAGS =
CTAGS = ctags
CTAGSFLAGS =
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
top_distdir = .
distdir = $(PACKAGE)-$(VERSION)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkinstalldirs) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d $(distdir)/$$subdir \
|| mkdir $(distdir)/$$subdir \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" \
distdir=../$(distdir)/$$subdir \
distdir) \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist dist-all: distdir
$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
$(am__remove_distdir)
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf -
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/=inst && pwd` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && $(mkinstalldirs) "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist-gzip \
&& rm -f $(distdir).tar.gz \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@echo "$(distdir).tar.gz is ready for distribution" | \
sed 'h;s/./=/g;p;x;p;x'
distuninstallcheck:
cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
dvi-am:
info: info-recursive
info-am:
install-data-am:
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf autom4te.cache
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am clean \
clean-generic clean-recursive ctags ctags-recursive dist \
dist-all dist-gzip distcheck distclean distclean-generic \
distclean-recursive distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am dvi-recursive info info-am \
info-recursive install install-am install-data install-data-am \
install-data-recursive install-exec install-exec-am \
install-exec-recursive install-info install-info-am \
install-info-recursive install-man install-recursive \
install-strip installcheck installcheck-am installdirs \
installdirs-am installdirs-recursive maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive mostlyclean \
mostlyclean-generic mostlyclean-recursive pdf pdf-am \
pdf-recursive ps ps-am ps-recursive tags tags-recursive \
uninstall uninstall-am uninstall-info-am \
uninstall-info-recursive uninstall-recursive
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
+1 -5
View File
@@ -1,8 +1,4 @@
The "projects" directory contains ready projects for:
Microsoft Visual C++ 6
Microsoft Visual C++ 2005
Anjuta 1 (please see README with project before using)
This file is required to keep autoconf/automake from complaining.
See the ChangeLog to see what's new.
See the INSTALL file for instructions on how to build fs2_open.
-382
View File
@@ -1,382 +0,0 @@
# Configure paths for SDL
# Sam Lantinga 9/21/99
# stolen from Manish Singh
# stolen back from Frank Belew
# stolen from Manish Singh
# Shamelessly stolen from Owen Taylor
dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
dnl
AC_DEFUN([AM_PATH_SDL],
[dnl
dnl Get the cflags and libraries from the sdl-config script
dnl
AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
sdl_prefix="$withval", sdl_prefix="")
AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
sdl_exec_prefix="$withval", sdl_exec_prefix="")
AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
, enable_sdltest=yes)
if test x$sdl_exec_prefix != x ; then
sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
if test x${SDL_CONFIG+set} != xset ; then
SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
fi
fi
if test x$sdl_prefix != x ; then
sdl_args="$sdl_args --prefix=$sdl_prefix"
if test x${SDL_CONFIG+set} != xset ; then
SDL_CONFIG=$sdl_prefix/bin/sdl-config
fi
fi
AC_REQUIRE([AC_CANONICAL_TARGET])
PATH="$prefix/bin:$prefix/usr/bin:$PATH"
AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
min_sdl_version=ifelse([$1], ,0.11.0,$1)
AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
no_sdl=""
if test "$SDL_CONFIG" = "no" ; then
no_sdl=yes
else
SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
if test "x$enable_sdltest" = "xyes" ; then
ac_save_CFLAGS="$CFLAGS"
ac_save_CXXFLAGS="$CXXFLAGS"
ac_save_LIBS="$LIBS"
CFLAGS="$CFLAGS $SDL_CFLAGS"
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
dnl
dnl Now check if the installed SDL is sufficiently new. (Also sanity
dnl checks the results of sdl-config to some extent
dnl
rm -f conf.sdltest
AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "SDL.h"
char*
my_strdup (char *str)
{
char *new_str;
if (str)
{
new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
strcpy (new_str, str);
}
else
new_str = NULL;
return new_str;
}
int main (int argc, char *argv[])
{
int major, minor, micro;
char *tmp_version;
/* This hangs on some systems (?)
system ("touch conf.sdltest");
*/
{ FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
/* HP/UX 9 (%@#!) writes to sscanf strings */
tmp_version = my_strdup("$min_sdl_version");
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
printf("%s, bad version string\n", "$min_sdl_version");
exit(1);
}
if (($sdl_major_version > major) ||
(($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
(($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
{
return 0;
}
else
{
printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
printf("*** best to upgrade to the required version.\n");
printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
printf("*** to point to the correct copy of sdl-config, and remove the file\n");
printf("*** config.cache before re-running configure\n");
return 1;
}
}
],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
CFLAGS="$ac_save_CFLAGS"
CXXFLAGS="$ac_save_CXXFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
if test "x$no_sdl" = x ; then
AC_MSG_RESULT(yes)
ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no)
if test "$SDL_CONFIG" = "no" ; then
echo "*** The sdl-config script installed by SDL could not be found"
echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the SDL_CONFIG environment variable to the"
echo "*** full path to sdl-config."
else
if test -f conf.sdltest ; then
:
else
echo "*** Could not run SDL test program, checking why..."
CFLAGS="$CFLAGS $SDL_CFLAGS"
CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
LIBS="$LIBS $SDL_LIBS"
AC_TRY_LINK([
#include <stdio.h>
#include "SDL.h"
int main(int argc, char *argv[])
{ return 0; }
#undef main
#define main K_and_R_C_main
], [ return 0; ],
[ echo "*** The test program compiled, but did not run. This usually means"
echo "*** that the run-time linker is not finding SDL or finding the wrong"
echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
echo "*** to the installed location Also, make sure you have run ldconfig if that"
echo "*** is required on your system"
echo "***"
echo "*** If you have an old version installed, it is best to remove it, although"
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
[ echo "*** The test program failed to compile or link. See the file config.log for the"
echo "*** exact error that occured. This usually means SDL was incorrectly installed"
echo "*** or that you have moved SDL since it was installed. In the latter case, you"
echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
CFLAGS="$ac_save_CFLAGS"
CXXFLAGS="$ac_save_CXXFLAGS"
LIBS="$ac_save_LIBS"
fi
fi
SDL_CFLAGS=""
SDL_LIBS=""
ifelse([$3], , :, [$3])
fi
AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS)
rm -f conf.sdltest
])
dnl ---------------------------------------------------------------------------
dnl Macros for wxWindows detection. Typically used in configure.in as:
dnl
dnl AC_ARG_ENABLE(...)
dnl AC_ARG_WITH(...)
dnl ...
dnl AM_OPTIONS_WXCONFIG
dnl ...
dnl ...
dnl AM_PATH_WXCONFIG(2.3.4, wxWin=1)
dnl if test "$wxWin" != 1; then
dnl AC_MSG_ERROR([
dnl wxWindows must be installed on your system
dnl but wx-config script couldn't be found.
dnl
dnl Please check that wx-config is in path, the directory
dnl where wxWindows libraries are installed (returned by
dnl 'wx-config --libs' command) is in LD_LIBRARY_PATH or
dnl equivalent variable and wxWindows version is 2.3.4 or above.
dnl ])
dnl fi
dnl CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
dnl CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
dnl CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
dnl
dnl LDFLAGS="$LDFLAGS $WX_LIBS"
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl AM_OPTIONS_WXCONFIG
dnl
dnl adds support for --wx-prefix, --wx-exec-prefix and --wx-config
dnl command line options
dnl ---------------------------------------------------------------------------
AC_DEFUN([AM_OPTIONS_WXCONFIG],
[
AC_ARG_WITH(wx-prefix, [ --with-wx-prefix=PREFIX Prefix where wxWindows is installed (optional)],
wx_config_prefix="$withval", wx_config_prefix="")
AC_ARG_WITH(wx-exec-prefix,[ --with-wx-exec-prefix=PREFIX Exec prefix where wxWindows is installed (optional)],
wx_config_exec_prefix="$withval", wx_config_exec_prefix="")
AC_ARG_WITH(wx-config,[ --with-wx-config=CONFIG wx-config script to use (optional)],
wx_config_name="$withval", wx_config_name="")
])
dnl ---------------------------------------------------------------------------
dnl AM_PATH_WXCONFIG(VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl
dnl Test for wxWindows, and define WX_C*FLAGS, WX_LIBS and WX_LIBS_STATIC
dnl (the latter is for static linking against wxWindows). Set WX_CONFIG_NAME
dnl environment variable to override the default name of the wx-config script
dnl to use. Set WX_CONFIG_PATH to specify the full path to wx-config - in this
dnl case the macro won't even waste time on tests for its existence.
dnl ---------------------------------------------------------------------------
dnl
dnl Get the cflags and libraries from the wx-config script
dnl
AC_DEFUN([AM_PATH_WXCONFIG],
[
dnl do we have wx-config name: it can be wx-config or wxd-config or ...
if test x${WX_CONFIG_NAME+set} != xset ; then
WX_CONFIG_NAME=wx-config
fi
if test "x$wx_config_name" != x ; then
WX_CONFIG_NAME="$wx_config_name"
fi
dnl deal with optional prefixes
if test x$wx_config_exec_prefix != x ; then
wx_config_args="$wx_config_args --exec-prefix=$wx_config_exec_prefix"
WX_LOOKUP_PATH="$wx_config_exec_prefix/bin"
fi
if test x$wx_config_prefix != x ; then
wx_config_args="$wx_config_args --prefix=$wx_config_prefix"
WX_LOOKUP_PATH="$WX_LOOKUP_PATH:$wx_config_prefix/bin"
fi
dnl don't search the PATH if WX_CONFIG_NAME is absolute filename
if test -x "$WX_CONFIG_NAME" ; then
AC_MSG_CHECKING(for wx-config)
WX_CONFIG_PATH="$WX_CONFIG_NAME"
AC_MSG_RESULT($WX_CONFIG_PATH)
else
AC_PATH_PROG(WX_CONFIG_PATH, $WX_CONFIG_NAME, no, "$WX_LOOKUP_PATH:$PATH")
fi
if test "$WX_CONFIG_PATH" != "no" ; then
WX_VERSION=""
no_wx=""
min_wx_version=ifelse([$1], ,2.2.1,$1)
AC_MSG_CHECKING(for wxWindows version >= $min_wx_version)
WX_CONFIG_WITH_ARGS="$WX_CONFIG_PATH $wx_config_args"
WX_VERSION=`$WX_CONFIG_WITH_ARGS --version`
wx_config_major_version=`echo $WX_VERSION | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
wx_config_minor_version=`echo $WX_VERSION | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
wx_config_micro_version=`echo $WX_VERSION | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
wx_requested_major_version=`echo $min_wx_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
wx_requested_minor_version=`echo $min_wx_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
wx_requested_micro_version=`echo $min_wx_version | \
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
wx_ver_ok=""
if test $wx_config_major_version -gt $wx_requested_major_version; then
wx_ver_ok=yes
else
if test $wx_config_major_version -eq $wx_requested_major_version; then
if test $wx_config_minor_version -gt $wx_requested_minor_version; then
wx_ver_ok=yes
else
if test $wx_config_minor_version -eq $wx_requested_minor_version; then
if test $wx_config_micro_version -ge $wx_requested_micro_version; then
wx_ver_ok=yes
fi
fi
fi
fi
fi
if test "x$wx_ver_ok" = x ; then
no_wx=yes
else
WX_LIBS=`$WX_CONFIG_WITH_ARGS --libs`
WX_LIBS_STATIC=`$WX_CONFIG_WITH_ARGS --static --libs`
dnl starting with version 2.2.6 wx-config has --cppflags argument
wx_has_cppflags=""
if test $wx_config_major_version -gt 2; then
wx_has_cppflags=yes
else
if test $wx_config_major_version -eq 2; then
if test $wx_config_minor_version -gt 2; then
wx_has_cppflags=yes
else
if test $wx_config_minor_version -eq 2; then
if test $wx_config_micro_version -ge 6; then
wx_has_cppflags=yes
fi
fi
fi
fi
fi
if test "x$wx_has_cppflags" = x ; then
dnl no choice but to define all flags like CFLAGS
WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
WX_CPPFLAGS=$WX_CFLAGS
WX_CXXFLAGS=$WX_CFLAGS
WX_CFLAGS_ONLY=$WX_CFLAGS
WX_CXXFLAGS_ONLY=$WX_CFLAGS
else
dnl we have CPPFLAGS included in CFLAGS included in CXXFLAGS
WX_CPPFLAGS=`$WX_CONFIG_WITH_ARGS --cppflags`
WX_CXXFLAGS=`$WX_CONFIG_WITH_ARGS --cxxflags`
WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
WX_CFLAGS_ONLY=`echo $WX_CFLAGS | sed "s@^$WX_CPPFLAGS *@@"`
WX_CXXFLAGS_ONLY=`echo $WX_CXXFLAGS | sed "s@^$WX_CFLAGS *@@"`
fi
fi
if test "x$no_wx" = x ; then
AC_MSG_RESULT(yes (version $WX_VERSION))
ifelse([$2], , :, [$2])
else
if test "x$WX_VERSION" = x; then
dnl no wx-config at all
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(no (version $WX_VERSION is not new enough))
fi
WX_CFLAGS=""
WX_CPPFLAGS=""
WX_CXXFLAGS=""
WX_LIBS=""
WX_LIBS_STATIC=""
ifelse([$3], , :, [$3])
fi
fi
AC_SUBST(WX_CPPFLAGS)
AC_SUBST(WX_CFLAGS)
AC_SUBST(WX_CXXFLAGS)
AC_SUBST(WX_CFLAGS_ONLY)
AC_SUBST(WX_CXXFLAGS_ONLY)
AC_SUBST(WX_LIBS)
AC_SUBST(WX_LIBS_STATIC)
AC_SUBST(WX_VERSION)
])
-137
View File
@@ -1,137 +0,0 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
srcdir=`dirname $0`
PKG_NAME="fs2_open"
# check the version of a package
check_version() {
COMMAND=$1
MAJOR=$2
MINOR=$3
MICRO=$4
($COMMAND --version) </dev/null >/dev/null 2>&1 || return 1
ver=`$COMMAND --version|head -n 1|sed 's/^.*) //'|sed 's/ (.*)//'`
major=`echo $ver | cut -d. -f1 | sed s/[a-zA-Z\-].*//g`
minor=`echo $ver | cut -d. -f2 | sed s/[a-zA-Z\-].*//g`
micro=`echo $ver | cut -d. -f3 | sed s/[a-zA-Z\-].*//g`
test -z "$major" && major=0
test -z "$minor" && minor=0
test -z "$micro" && micro=0
fail=0
if [ ! "$major" -gt "$MAJOR" ]; then
if [ "$major" -lt "$MAJOR" ]; then
fail=1
elif [ ! "$minor" -gt "$MINOR" ]; then
if [ "$minor" -lt "$MINOR" ]; then
fail=1
elif [ "$micro" -lt "$MICRO" ]; then
fail=1
fi
fi
fi
return "$fail"
}
AUTOMAKE=
ACLOCAL=
DIE=0
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`autoconf' installed to."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
for AM in automake-1.9 automake-1.8 automake-1.7 automake-1.6 automake; do
(check_version "$AM" 1 6 1) && {
AUTOMAKE="$AM"
break
}
done
if [ -z "$AUTOMAKE" ]; then
echo
echo "**Error**: You must have \`automake' version 1.6.1 or greater"
echo "installed to compile $PKG_NAME. Download the appropriate package"
echo "for your distribution, or get the source tarball at"
echo "ftp://ftp.gnu.org/pub/gnu/"
DIE=1
fi
# if no automake, don't bother testing for aclocal
test -z "$AUTOMAKE" || {
for ACL in aclocal-1.9 aclocal-1.8 aclocal-1.7 aclocal-1.6 aclocal; do
(check_version "$ACL" 1 6 1) && {
ACLOCAL="$ACL"
break
}
done
if [ -z "$ACLOCAL" ]; then
echo
echo "**Error**: Missing \`aclocal'. The version of \`automake'"
echo "installed seems to be outdated. Get a recent package from"
echo "ftp://ftp.gnu.org/pub/gnu/"
DIE=1
fi
}
if test "$DIE" -eq 1; then
exit 1
fi
if test -z "$*"; then
echo "**Warning**: I am going to run \`configure' with no arguments."
echo "If you wish to pass any to it, please specify them on the"
echo \`$0\'" command line."
echo
fi
case $CC in
xlc )
am_opt=--include-deps;;
esac
for coin in `find $srcdir -name configure.ac -print`
do
dr=`dirname $coin`
if test -f $dr/NO-AUTO-GEN; then
echo skipping $dr -- flagged as no auto-gen
else
echo processing $dr
macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
( cd $dr
aclocalinclude="$ACLOCAL_FLAGS"
for k in $macrodirs; do
if test -d $k; then
aclocalinclude="$aclocalinclude -I $k"
##else
## echo "**Warning**: No such directory \`$k'. Ignored."
fi
done
echo "Running $ACLOCAL $aclocalinclude ..."
"$ACLOCAL" $aclocalinclude
echo "Running $AUTOMAKE --add-missing --copy --foreign $am_opt ..."
"$AUTOMAKE" --add-missing --copy --foreign $am_opt
echo "Running autoconf..."
autoconf
)
fi
done
#conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c
if test x$NOCONFIGURE = x; then
echo Running $srcdir/configure $conf_flags "$@" ...
$srcdir/configure $conf_flags "$@" \
&& echo Now type \`make\' to compile $PKG_NAME.
else
echo Skipping configure process.
fi
-5
View File
@@ -1,5 +0,0 @@
Makefile
Makefile.in
fs2_open_d
fs2_open_r
.deps
+283 -650
View File
@@ -1,672 +1,305 @@
## code/Makefile.am for fs2_open
##
## $Id: Makefile.am,v 1.20 2005-07-18 03:37:35 taylor Exp $
# code/Makefile.am for fs2_open
#
# $Id: Makefile.am,v 1.2 2003-03-11 19:00:05 penguin Exp $
noinst_PROGRAMS = fs2
EXTRA_DIST = \
freespace2/app_icon.ico \
freespace2/freespace.rc \
freespace2/freespaceresource.h \
freespace2/goal_com.bmp \
freespace2/goal_fail.bmp \
freespace2/goal_inc.bmp \
freespace2/goal_none.bmp \
freespace2/goal_ord.bmp \
wxfred2/res/FRED.ico \
wxfred2/wxfred.xrc
fs2_SOURCES = \
anim/animplay.cpp \
anim/packunpack.cpp \
asteroid/asteroid.cpp \
bmpman/bmpman.cpp \
cfile/cfile.cpp \
cfile/cfilearchive.cpp \
cfile/cfilelist.cpp \
cfile/cfilesystem.cpp \
cmdline/cmdline.cpp \
cmeasure/cmeasure.cpp \
controlconfig/controlsconfig.cpp \
controlconfig/controlsconfigcommon.cpp \
cutscene/cutscenes.cpp \
debris/debris.cpp \
debugconsole/console.cpp \
decals/decals.cpp \
demo/demo.cpp \
exceptionhandler/exceptionhandler.cpp \
fireball/fireballs.cpp \
fireball/warpineffect.cpp \
freespace2/freespace.cpp \
freespace2/levelpaging.cpp \
gamehelp/contexthelp.cpp \
gamehelp/gameplayhelp.cpp \
gamesequence/gamesequence.cpp \
globalincs/alphacolors.cpp \
globalincs/crypt.cpp \
globalincs/systemvars.cpp \
globalincs/version.cpp \
graphics/2d.cpp \
graphics/aaline.cpp \
graphics/bitblt.cpp \
graphics/circle.cpp \
graphics/colors.cpp \
graphics/font.cpp \
graphics/gradient.cpp \
graphics/gropengl.cpp \
graphics/grzbuffer.cpp \
graphics/line.cpp \
graphics/pixel.cpp \
graphics/rect.cpp \
graphics/scaler.cpp \
graphics/shade.cpp \
hud/hud.cpp \
hud/hudartillery.cpp \
hud/hudbrackets.cpp \
hud/hudconfig.cpp \
hud/hudescort.cpp \
hud/hudets.cpp \
hud/hudlock.cpp \
hud/hudmessage.cpp \
hud/hudreticle.cpp \
hud/hudshield.cpp \
hud/hudsquadmsg.cpp \
hud/hudtarget.cpp \
hud/hudtargetbox.cpp \
hud/hudwingmanstatus.cpp \
io/key.cpp \
io/keycontrol.cpp \
io/mouse.cpp \
io/timer.cpp \
jumpnode/jumpnode.cpp \
lighting/lighting.cpp \
localization/fhash.cpp \
localization/localize.cpp \
math/fix.cpp \
math/floating.cpp \
math/fvi.cpp \
math/spline.cpp \
math/staticrand.cpp \
math/vecmat.cpp \
menuui/barracks.cpp \
menuui/credits.cpp \
menuui/fishtank.cpp \
menuui/mainhallmenu.cpp \
menuui/mainhalltemp.cpp \
menuui/optionsmenu.cpp \
menuui/playermenu.cpp \
menuui/readyroom.cpp \
menuui/snazzyui.cpp \
menuui/techmenu.cpp \
menuui/trainingmenu.cpp \
mission/missionbriefcommon.cpp \
mission/missioncampaign.cpp \
mission/missiongoals.cpp \
mission/missiongrid.cpp \
mission/missionhotkey.cpp \
mission/missionload.cpp \
mission/missionlog.cpp \
mission/missionmessage.cpp \
mission/missionparse.cpp \
mission/missiontraining.cpp \
missionui/missionbrief.cpp \
missionui/missioncmdbrief.cpp \
missionui/missiondebrief.cpp \
missionui/missionloopbrief.cpp \
missionui/missionpause.cpp \
missionui/missionrecommend.cpp \
missionui/missionscreencommon.cpp \
missionui/missionshipchoice.cpp \
missionui/missionstats.cpp \
missionui/missionweaponchoice.cpp \
missionui/redalert.cpp \
model/modelcollide.cpp \
model/modelinterp.cpp \
model/modeloctant.cpp \
model/modelread.cpp \
nebula/neb.cpp \
nebula/neblightning.cpp \
object/collidedebrisship.cpp \
object/collidedebrisweapon.cpp \
object/collideshipship.cpp \
object/collideshipweapon.cpp \
object/collideweaponweapon.cpp \
object/objcollide.cpp \
object/object.cpp \
object/objectsort.cpp \
observer/observer.cpp \
palman/palman.cpp \
parse/encrypt.cpp \
parse/parselo.cpp \
parse/sexp.cpp \
particle/particle.cpp \
pcxutils/pcxutils.cpp \
physics/physics.cpp \
playerman/managepilot.cpp \
playerman/playercontrol.cpp \
popup/popup.cpp \
popup/popupdead.cpp \
radar/radar.cpp \
render/3dclipper.cpp \
render/3ddraw.cpp \
render/3dlaser.cpp \
render/3dmath.cpp \
render/3dsetup.cpp \
ship/afterburner.cpp \
ship/ai.cpp \
ship/aibig.cpp \
ship/aicode.cpp \
ship/aigoals.cpp \
ship/awacs.cpp \
ship/shield.cpp \
ship/ship.cpp \
ship/shipcontrails.cpp \
ship/shipfx.cpp \
ship/shiphit.cpp \
starfield/nebula.cpp \
starfield/starfield.cpp \
starfield/supernova.cpp \
stats/medals.cpp \
stats/scoring.cpp \
stats/stats.cpp \
tgautils/tgautils.cpp \
ui/button.cpp \
ui/checkbox.cpp \
ui/gadget.cpp \
ui/icon.cpp \
ui/inputbox.cpp \
ui/keytrap.cpp \
ui/listbox.cpp \
ui/radio.cpp \
ui/scroll.cpp \
ui/slider.cpp \
ui/slider2.cpp \
ui/uidraw.cpp \
ui/uimouse.cpp \
ui/window.cpp \
weapon/beam.cpp \
weapon/corkscrew.cpp \
weapon/emp.cpp \
weapon/flak.cpp \
weapon/muzzleflash.cpp \
weapon/shockwave.cpp \
weapon/swarm.cpp \
weapon/trails.cpp \
weapon/weapons.cpp
# D_ variants are defaults and should always be used
# FS2_ variants are for game building and wxFRED
AM_CXXFLAGS = @D_CFLAGS@ @FS2_CXXFLAGS@
AM_LDFLAGS = @D_LDFLAGS@ @FS2_LDFLAGS@
noinst_LIBRARIES = libcode.a
noinst_PROGRAMS = @FS2_BINARY@
EXTRA_PROGRAMS = fs2_open_r fs2_open_d wxFRED2_r wxFRED2_d
###############################################################################
##
## Begin CORE library
##
FS2_SOURCES = \
ai/ai.cpp \
ai/ai.h \
ai/aibig.cpp \
ai/aibig.h \
ai/aicode.cpp \
ai/aigoals.cpp \
ai/aigoals.h \
ai/aiinternal.h \
ai/ailocal.h \
ai/aiturret.cpp \
anim/animplay.cpp \
anim/animplay.h \
anim/packunpack.cpp \
anim/packunpack.h \
asteroid/asteroid.cpp \
asteroid/asteroid.h \
autopilot/autopilot.cpp \
autopilot/autopilot.h \
bmpman/bm_internal.h \
bmpman/bmpman.cpp \
bmpman/bmpman.h \
camera/camera.cpp \
camera/camera.h \
cfile/cfile.cpp \
cfile/cfile.h \
cfile/cfilearchive.cpp \
cfile/cfilearchive.h \
cfile/cfilelist.cpp \
cfile/cfilesystem.cpp \
cfile/cfilesystem.h \
cmdline/cmdline.cpp \
cmdline/cmdline.h \
cmeasure/cmeasure.cpp \
cmeasure/cmeasure.h \
controlconfig/controlsconfig.cpp \
controlconfig/controlsconfig.h \
controlconfig/controlsconfigcommon.cpp \
cutscene/cutscenes.cpp \
cutscene/cutscenes.h \
cutscene/movie.cpp \
cutscene/movie.h \
ddsutils/ddsutils.cpp \
ddsutils/ddsutils.h \
debris/debris.cpp \
debris/debris.h \
debugconsole/console.cpp \
debugconsole/dbugfile.h \
debugconsole/timerbar.cpp \
debugconsole/timerbar.h \
decals/decals.cpp \
decals/decals.h \
demo/demo.cpp \
demo/demo.h \
exceptionhandler/exceptionhandler.cpp \
exceptionhandler/exceptionhandler.h \
fireball/fireballs.cpp \
fireball/fireballs.h \
fireball/warpineffect.cpp \
fs2open_pxo/Client.cpp \
fs2open_pxo/Client.h \
fs2open_pxo/TCP_Client.cpp \
fs2open_pxo/TCP_Socket.cpp \
fs2open_pxo/TCP_Socket.h \
fs2open_pxo/protocol.h \
fs2open_pxo/udpsocket.cpp \
fs2open_pxo/udpsocket.h \
gamehelp/contexthelp.cpp \
gamehelp/contexthelp.h \
gamehelp/gameplayhelp.cpp \
gamehelp/gameplayhelp.h \
gamesequence/gamesequence.cpp \
gamesequence/gamesequence.h \
globalincs/alphacolors.cpp \
globalincs/alphacolors.h \
globalincs/crypt.cpp \
globalincs/crypt.h \
globalincs/globals.h \
globalincs/linklist.h \
globalincs/pstypes.h \
globalincs/systemvars.cpp \
globalincs/systemvars.h \
globalincs/version.cpp \
globalincs/version.h \
graphics/2d.cpp \
graphics/2d.h \
graphics/font.cpp \
graphics/font.h \
graphics/grbatch.cpp \
graphics/grbatch.h \
graphics/grinternal.h \
graphics/gropengl.cpp \
graphics/gropengl.h \
graphics/gropenglbmpman.cpp \
graphics/gropenglbmpman.h \
graphics/gropenglextension.cpp \
graphics/gropenglextension.h \
graphics/gropengllight.cpp \
graphics/gropengllight.h \
graphics/gropengltexture.cpp \
graphics/gropengltexture.h \
graphics/gropengltnl.cpp \
graphics/gropengltnl.h \
graphics/grstub.h \
graphics/grzbuffer.cpp \
graphics/grzbuffer.h \
graphics/line.h \
graphics/tmapper.h \
hud/hud.cpp \
hud/hud.h \
hud/hudartillery.cpp \
hud/hudartillery.h \
hud/hudbrackets.cpp \
hud/hudbrackets.h \
hud/hudconfig.cpp \
hud/hudconfig.h \
hud/hudescort.cpp \
hud/hudescort.h \
hud/hudets.cpp \
hud/hudets.h \
hud/hudgauges.h \
hud/hudlock.cpp \
hud/hudlock.h \
hud/hudmessage.cpp \
hud/hudmessage.h \
hud/hudnavigation.cpp \
hud/hudnavigation.h \
hud/hudobserver.cpp \
hud/hudobserver.h \
hud/hudparse.cpp \
hud/hudparse.h \
hud/hudresource.h \
hud/hudreticle.cpp \
hud/hudreticle.h \
hud/hudshield.cpp \
hud/hudshield.h \
hud/hudsquadmsg.cpp \
hud/hudsquadmsg.h \
hud/hudtarget.cpp \
hud/hudtarget.h \
hud/hudtargetbox.cpp \
hud/hudtargetbox.h \
hud/hudwingmanstatus.cpp \
hud/hudwingmanstatus.h \
io/key.cpp \
io/key.h \
io/keycontrol.cpp \
io/keycontrol.h \
io/mouse.cpp \
io/mouse.h \
io/timer.cpp \
io/timer.h \
irc/irc.cpp \
irc/irc.h \
jpgutils/jpgutils.cpp \
jpgutils/jpgutils.h \
jumpnode/jumpnode.cpp \
jumpnode/jumpnode.h \
lab/lab.cpp \
lab/lab.h \
lab/wmcgui.cpp \
lab/wmcgui.h \
lighting/lighting.cpp \
lighting/lighting.h \
localization/fhash.cpp \
localization/fhash.h \
localization/localize.cpp \
localization/localize.h \
math/bitarray.h \
math/fix.cpp \
math/fix.h \
math/floating.cpp \
math/floating.h \
math/fvi.cpp \
math/fvi.h \
math/spline.cpp \
math/spline.h \
math/staticrand.cpp \
math/staticrand.h \
math/vecmat.cpp \
math/vecmat.h \
menuui/barracks.cpp \
menuui/barracks.h \
menuui/credits.cpp \
menuui/credits.h \
menuui/fishtank.cpp \
menuui/fishtank.h \
menuui/mainhallmenu.cpp \
menuui/mainhallmenu.h \
menuui/mainhalltemp.cpp \
menuui/mainhalltemp.h \
menuui/optionsmenu.cpp \
menuui/optionsmenu.h \
menuui/optionsmenumulti.cpp \
menuui/optionsmenumulti.h \
menuui/playermenu.cpp \
menuui/playermenu.h \
menuui/readyroom.cpp \
menuui/readyroom.h \
menuui/snazzyui.cpp \
menuui/snazzyui.h \
menuui/storybook.cpp \
menuui/storybook.h \
menuui/techmenu.cpp \
menuui/techmenu.h \
menuui/trainingmenu.cpp \
menuui/trainingmenu.h \
mission/missionbriefcommon.cpp \
mission/missionbriefcommon.h \
mission/missioncampaign.cpp \
mission/missioncampaign.h \
mission/missiongoals.cpp \
mission/missiongoals.h \
mission/missiongrid.cpp \
mission/missiongrid.h \
mission/missionhotkey.cpp \
mission/missionhotkey.h \
mission/missionload.cpp \
mission/missionload.h \
mission/missionlog.cpp \
mission/missionlog.h \
mission/missionmessage.cpp \
mission/missionmessage.h \
mission/missionparse.cpp \
mission/missionparse.h \
mission/missiontraining.cpp \
mission/missiontraining.h \
missionui/chatbox.cpp \
missionui/chatbox.h \
missionui/missionbrief.cpp \
missionui/missionbrief.h \
missionui/missioncmdbrief.cpp \
missionui/missioncmdbrief.h \
missionui/missiondebrief.cpp \
missionui/missiondebrief.h \
missionui/missionloopbrief.cpp \
missionui/missionloopbrief.h \
missionui/missionpause.cpp \
missionui/missionpause.h \
missionui/missionrecommend.cpp \
missionui/missionrecommend.h \
missionui/missionscreencommon.cpp \
missionui/missionscreencommon.h \
missionui/missionshipchoice.cpp \
missionui/missionshipchoice.h \
missionui/missionstats.cpp \
missionui/missionstats.h \
missionui/missionweaponchoice.cpp \
missionui/missionweaponchoice.h \
missionui/redalert.cpp \
missionui/redalert.h \
model/model.h \
model/modelcollide.cpp \
model/modelinterp.cpp \
model/modelsinc.h \
model/modeloctant.cpp \
model/modelread.cpp \
nebula/neb.cpp \
nebula/neb.h \
nebula/neblightning.cpp \
nebula/neblightning.h \
network/fs2ox.cpp \
network/fs2ox.h \
network/multi.cpp \
network/multi.h \
network/multilag.h \
network/multimsgs.cpp \
network/multimsgs.h \
network/multiteamselect.cpp \
network/multiteamselect.h \
network/multiui.cpp \
network/multiui.h \
network/multiutil.cpp \
network/multiutil.h \
network/multi_campaign.cpp \
network/multi_campaign.h \
network/multi_data.cpp \
network/multi_data.h \
network/multi_dogfight.cpp \
network/multi_dogfight.h \
network/multi_endgame.cpp \
network/multi_endgame.h \
network/multi_ingame.cpp \
network/multi_ingame.h \
network/multi_kick.cpp \
network/multi_kick.h \
network/multi_log.cpp \
network/multi_log.h \
network/multi_obj.cpp \
network/multi_obj.h \
network/multi_observer.cpp \
network/multi_observer.h \
network/multi_oo.h \
network/multi_options.cpp \
network/multi_options.h \
network/multi_pause.cpp \
network/multi_pause.h \
network/multi_pinfo.cpp \
network/multi_pinfo.h \
network/multi_ping.cpp \
network/multi_ping.h \
network/multi_pmsg.cpp \
network/multi_pmsg.h \
network/multi_rate.cpp \
network/multi_rate.h \
network/multi_respawn.cpp \
network/multi_respawn.h \
network/multi_team.cpp \
network/multi_team.h \
network/multi_update.h \
network/multi_voice.cpp \
network/multi_voice.h \
network/multi_xfer.cpp \
network/multi_xfer.h \
network/psnet.cpp \
network/psnet.h \
network/psnet2.cpp \
network/psnet2.h \
object/collidedebrisship.cpp \
object/collidedebrisweapon.cpp \
object/collideshipship.cpp \
object/collideshipweapon.cpp \
object/collideweaponweapon.cpp \
object/objcollide.cpp \
object/objcollide.h \
object/objectdock.cpp \
object/objectdock.h \
object/object.cpp \
object/object.h \
object/objectsort.cpp \
observer/observer.cpp \
observer/observer.h \
palman/palman.cpp \
palman/palman.h \
parse/encrypt.cpp \
parse/encrypt.h \
parse/parselo.cpp \
parse/parselo.h \
parse/sexp.cpp \
parse/sexp.h \
particle/particle.cpp \
particle/particle.h \
pcxutils/pcxutils.cpp \
pcxutils/pcxutils.h \
physics/physics.cpp \
physics/physics.h \
playerman/managepilot.cpp \
playerman/managepilot.h \
playerman/player.h \
playerman/playercontrol.cpp \
popup/popup.cpp \
popup/popup.h \
popup/popupdead.cpp \
popup/popupdead.h \
radar/radar.cpp \
radar/radar.h \
radar/radarorb.cpp \
radar/radarorb.h \
radar/radarsetup.cpp \
radar/radarsetup.h \
render/3d.h \
render/3dclipper.cpp \
render/3ddraw.cpp \
render/3dinternal.h \
render/3dlaser.cpp \
render/3dmath.cpp \
render/3dsetup.cpp \
ship/afterburner.cpp \
ship/afterburner.h \
ship/awacs.cpp \
ship/awacs.h \
ship/shield.cpp \
ship/ship.cpp \
ship/ship.h \
ship/shipcontrails.cpp \
ship/shipcontrails.h \
ship/shipfx.cpp \
ship/shipfx.h \
ship/shiphit.cpp \
ship/shiphit.h \
ship/subsysdamage.h \
species_defs/species_defs.cpp \
species_defs/species_defs.h \
starfield/nebula.cpp \
starfield/nebula.h \
starfield/starfield.cpp \
starfield/starfield.h \
starfield/supernova.cpp \
starfield/supernova.h \
stats/medals.cpp \
stats/medals.h \
stats/scoring.cpp \
stats/scoring.h \
stats/stats.cpp \
stats/stats.h \
tgautils/tgautils.cpp \
tgautils/tgautils.h \
ui/button.cpp \
ui/checkbox.cpp \
ui/gadget.cpp \
ui/icon.cpp \
ui/inputbox.cpp \
ui/keytrap.cpp \
ui/listbox.cpp \
ui/radio.cpp \
ui/scroll.cpp \
ui/slider.cpp \
ui/slider2.cpp \
ui/ui.h \
ui/uidefs.h \
ui/uidraw.cpp \
ui/uimouse.cpp \
ui/window.cpp \
weapon/beam.cpp \
weapon/beam.h \
weapon/corkscrew.cpp \
weapon/corkscrew.h \
weapon/emp.cpp \
weapon/emp.h \
weapon/flak.cpp \
weapon/flak.h \
weapon/muzzleflash.cpp \
weapon/muzzleflash.h \
weapon/shockwave.cpp \
weapon/shockwave.h \
weapon/swarm.cpp \
weapon/swarm.h \
weapon/trails.cpp \
weapon/trails.h \
weapon/weapons.cpp \
weapon/weapon.h
## conditional includes follow:
## joystic support sources
if FS2_OS_WIN32
JOY_SOURCES = \
io/joy.cpp \
io/joy.h \
io/joy_ff.cpp \
io/joy_ff.h \
io/sw_error.hpp \
io/sw_force.h \
io/sw_guid.hpp \
io/swff_lib.cpp
endif
if FS2_OS_UNIX
JOY_SOURCES = \
io/joy.h \
io/joy-unix.cpp
endif
if FS2_JOYSTICK
fs2_SOURCES += \
io/joy.cpp \
io/joy_ff.cpp \
io/swff_lib.cpp
endif # FS2_JOYSTICK
## networking support sources
if FS2_OS_WIN32
FS2_SOURCES += \
network/multilag.cpp \
network/stand_gui.cpp \
network/stand_gui.h
endif
if FS2_OS_UNIX
FS2_SOURCES += \
network/stand_gui-unix.cpp \
network/stand_gui.h
endif
if FS2_NETWORKING
fs2_SOURCES += \
hud/hudobserver.cpp \
network/multi.cpp \
network/multimsgs.cpp \
network/multiteamselect.cpp \
network/multiui.cpp \
network/multiutil.cpp \
network/multi_campaign.cpp \
network/multi_data.cpp \
network/multi_dogfight.cpp \
network/multi_endgame.cpp \
network/multi_ingame.cpp \
network/multi_kick.cpp \
network/multi_log.cpp \
network/multi_obj.cpp \
network/multi_observer.cpp \
network/multi_options.cpp \
network/multi_pause.cpp \
network/multi_pinfo.cpp \
network/multi_ping.cpp \
network/multi_pmsg.cpp \
network/multi_rate.cpp \
network/multi_respawn.cpp \
network/multi_team.cpp \
network/multi_voice.cpp \
network/multi_xfer.cpp \
network/psnet.cpp \
network/psnet2.cpp \
menuui/optionsmenumulti.cpp \
missionui/chatbox.cpp
endif # FS2_NETWORKING
## sound support sources
if FS2_SOUND
SOUND_SOURCES = \
gamesnd/eventmusic.cpp \
gamesnd/eventmusic.h \
gamesnd/gamesnd.cpp \
gamesnd/gamesnd.h \
object/objectsnd.cpp \
object/objectsnd.h \
sound/ogg/ogg.cpp \
sound/ogg/ogg.h \
sound/audiostr-openal.cpp \
sound/audiostr.cpp \
sound/audiostr.h \
sound/acm-openal.cpp \
sound/acm.cpp \
sound/acm.h \
sound/ds.cpp \
sound/ds.h \
sound/ds3d.cpp \
sound/ds3d.h \
sound/midifile.cpp \
sound/midifile.h \
sound/midiseq.h \
sound/rbaudio.cpp \
sound/rbaudio.h \
sound/rtvoice.cpp \
sound/rtvoice.h \
sound/sound.cpp \
sound/sound.h \
sound/winmidi.cpp \
sound/winmidi.h \
sound/winmidi_base.cpp \
vcodec/codec1.cpp \
vcodec/codec1.h \
sound/fsspeech.cpp \
sound/fsspeech.h \
sound/speech.cpp \
sound/speech.h
fs2_SOURCES += \
gamesnd/eventmusic.cpp \
gamesnd/gamesnd.cpp \
object/objectsnd.cpp \
sound/acm.cpp \
sound/audiostr.cpp \
sound/ds.cpp \
sound/ds3d.cpp \
sound/dscap.cpp \
sound/midifile.cpp \
sound/rbaudio.cpp \
sound/rtvoice.cpp \
sound/sound.cpp \
sound/winmidi.cpp \
sound/winmidi_base.cpp \
vcodec/codec1.cpp
endif # FS2_SOUND
if FS2_OS_WIN32
SOUND_SOURCES += \
sound/dscap.cpp \
sound/dscap.h
endif
endif
## software-rendering support sources
if FS2_GRSOFT
fs2_SOURCES += \
graphics/grsoft.cpp \
graphics/tmapper.cpp
endif # FS2_GRSOFT
## Win32-specific sources
if FS2_OS_WIN32
WIN32_SOURCES = \
directx/dx8show.cpp \
directx/dx8show.h \
directx/vasync.h \
directx/vd3dtypes.h \
directx/vddraw.h \
directx/vdinput.h \
directx/vdplay.h \
directx/vdplobby.h \
directx/vdsetup.h \
directx/vdsound.h \
directx/vdvp.h \
globalincs/windebug.cpp \
graphics/gl/GLAUX.H \
graphics/gl/GLU.H \
graphics/gl/Gl.h \
graphics/gl/Glext.h \
graphics/gl/wglext.h \
graphics/GrD3DParticle.cpp \
graphics/GrD3DParticle.h \
graphics/GrD3DStateBlock.cpp \
graphics/grd3d.cpp \
graphics/grd3d.h \
graphics/grd3dbatch.cpp \
graphics/grd3dbatch.h \
graphics/grd3dcalls.cpp \
graphics/grd3dbmpman.cpp \
graphics/grd3dbmpman.h \
graphics/grd3dinternal.h \
graphics/grd3dlight.cpp \
graphics/grd3dlight.h \
graphics/grd3drender.cpp \
graphics/grd3dsetup.cpp \
graphics/grd3dsetup.h \
graphics/grd3dtexture.cpp \
osapi/monopub.h \
osapi/osapi.cpp \
osapi/osapi.h \
osapi/osregistry.cpp \
osapi/osregistry.h \
osapi/outwnd.cpp \
osapi/outwnd.h
endif
fs2_SOURCES += \
cutscene/movie.cpp \
directx/dx8show.cpp \
ddsutils/ddsutils.cpp \
globalincs/windebug.cpp \
glide/glide.cpp \
graphics/grd3d.cpp \
graphics/grd3drender.cpp \
graphics/grd3dtexture.cpp \
graphics/grdirectdraw.cpp \
graphics/grglide.cpp \
graphics/grglidetexture.cpp \
network/stand_gui.cpp \
osapi/osapi.cpp \
osapi/osregistry.cpp \
osapi/outwnd.cpp
endif # FS2_OS_WIN32
## Unix-specific sources
if FS2_OS_UNIX
UNIX_SOURCES = \
osapi/osapi_unix.cpp \
osapi/osapi.h \
osapi/osregistry_unix.cpp \
osapi/osregistry.h \
osapi/outwnd_unix.cpp \
osapi/outwnd.h \
windows_stub/stubs.cpp \
windows_stub/config.h
fs2_SOURCES += \
io/xmouse.cpp \
osapi/osapi_unix.cpp \
osapi/osregistry_unix.cpp \
osapi/outwnd_unix.cpp
endif # FS2_OS_UNIX
## compiler flags
# INCLUDES = -I.
AM_CXXFLAGS = -fno-exceptions @DX8_INCLUDE@
AM_LDFLAGS = -L/c/dx8/lib @DX8_LIB@
LDADD =
if FS2_OS_WIN32
## Win32 libraries needed
LDADD += \
-lgdi32 -lole32 -lwsock32 -lwinmm -lmsacm32 -lopengl32 \
-lcomctl32 -lstrmiids -ldxguid -lddraw -ldinput
endif
## libcode.a
libcode_a_SOURCES = ${FS2_SOURCES} ${JOY_SOURCES} ${SOUND_SOURCES} \
${WIN32_SOURCES} ${UNIX_SOURCES}
##
## End CODE library
##
###############################################################################
###############################################################################
##
## Begin MAIN fs2 binary
##
FS2OPEN_SOURCES = \
freespace2/freespace.cpp \
freespace2/freespace.h \
freespace2/levelpaging.cpp \
freespace2/levelpaging.h
fs2_open_d_SOURCES = \
${FS2OPEN_SOURCES} \
${PLATFORM_SOURCES}
fs2_open_r_SOURCES = \
${FS2OPEN_SOURCES} \
${PLATFORM_SOURCES}
fs2_open_d_LDADD = libcode.a ../libjpeg/libjpeg.a
fs2_open_r_LDADD = libcode.a ../libjpeg/libjpeg.a
##
## End MAIN binary
##
###############################################################################
###############################################################################
##
## Begin wxFRED2 binary
##
wxFRED_SOURCES = \
wxfred2/wxfred2.cpp \
wxfred2/wxfred2.h \
wxfred2/fredframe.cpp \
wxfred2/fredframe.h \
wxfred2/wxfred_xrc.cpp \
wxfred2/wxfred_xrc.h
wxFRED2_d_SOURCES = \
${wxFRED_SOURCES} \
${PLATFORM_SOURCES}
wxFRED2_r_SOURCES = \
${wxFRED_SOURCES} \
${PLATFORM_SOURCES}
wxFRED2_d_LDADD = libcode.a ../libjpeg/libjpeg.a
wxFRED2_r_LDADD = libcode.a ../libjpeg/libjpeg.a
##
## End wxFRED2 binary
##
###############################################################################
if FS2_OS_UNIX
## Unix libraries needed
## -- TODO --
endif
File diff suppressed because it is too large. Load diff
-34
View File
@@ -1,34 +0,0 @@
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#ifndef _AIINTERNAL_H
#define _AIINTERNAL_H
//Returns the enemy team mask for the specified subobject
int get_enemy_team_mask(int objnum);
//Returns true if the specified object is a stealth ship, false if not
bool is_object_stealth_ship(object* objp);
//Number of live turrets on the object attacking
int num_turrets_attacking(object *turret_parent, int target_objnum);
//Determine whether an object is targetable within a nebula (checks for stealth)
int object_is_targetable(object *target, ship *viewer);
//Returns the number of enemy fighters within threshold of pos.
int num_nearby_fighters(int enemy_team_mask, vec3d *pos, float threshold);
//Returns true if OK for *aip to fire its current weapon at its current target.
int check_ok_to_fire(int objnum, int target_objnum, weapon_info *wip);
//Does all the stuff needed to aim and fire a turret.
void ai_fire_from_turret(ship *shipp, ship_subsys *ss, int parent_objnum);
#endif
File diff suppressed because it is too large. Load diff
+22 -74
View File
@@ -9,45 +9,13 @@
/*
* $Logfile: /Freespace2/code/Anim/AnimPlay.cpp $
* $Revision: 2.17 $
* $Date: 2005-05-28 19:40:59 $
* $Author: taylor $
* $Revision: 2.8 $
* $Date: 2004-03-05 09:01:52 $
* $Author: Goober5000 $
*
* C module for playing back anim files
*
* $Log: not supported by cvs2svn $
* Revision 2.16 2005/05/23 05:58:31 taylor
* quick catch for some corrupted anis, only a partial fix but it will do until something
* a bit more heavy duty comes along in the near future
*
* Revision 2.15 2005/05/12 17:49:10 taylor
* use vm_malloc(), vm_free(), vm_realloc(), vm_strdup() rather than system named macros
* fixes various problems and is past time to make the switch
*
* Revision 2.14 2005/01/30 12:50:08 taylor
* merge with Linux/OSX tree - p0130
*
* Revision 2.13 2004/12/20 20:18:30 fryday
* Commented out ATL dependencies (And changed one macro to an swprintf instead)
* Tiny change in animplay ( pow(2.0, ...) instead of pow(2, ...)) because VS2K5
* throws an ambiguity error over that.
*
* Revision 2.12 2004/10/09 17:58:48 taylor
* one more try to fix the memory leak and end-of-mission crash for talking head anis
*
* Revision 2.11 2004/07/26 20:47:23 Kazan
* remove MCD complete
*
* Revision 2.10 2004/07/17 18:46:06 taylor
* various OGL and memory leak fixes
*
* Revision 2.9 2004/07/12 16:32:41 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.8 2004/03/05 09:01:52 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.7 2004/02/16 11:47:31 randomtiger
* Removed a lot of files that we dont need anymore.
* Changed htl to be on by default, command now -nohtl
@@ -281,8 +249,6 @@
#include "cfile/cfile.h"
#include "cmdline/cmdline.h"
static color Color_xparent;
anim *first_anim = NULL;
@@ -454,7 +420,7 @@ anim_instance *anim_play(anim_play_struct *aps)
if ( anim_instance_is_streamed(instance) ) {
instance->file_offset = instance->parent->file_offset;
}
instance->frame = (ubyte *) vm_malloc(instance->parent->width * instance->parent->height * 2);
instance->frame = (ubyte *) malloc(instance->parent->width * instance->parent->height * 2);
Assert( instance->frame != NULL );
instance->time_elapsed = 0.0f;
instance->stop_at = aps->stop_at;
@@ -702,7 +668,7 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
}
ubyte *temp = NULL;
int temp_file_offset = -1;
int temp_file_offset = 0;
// if we're using bitmap polys
BM_SELECT_TEX_FORMAT();
@@ -724,14 +690,6 @@ int anim_show_next_frame(anim_instance *instance, float frametime)
// always go back to screen format
BM_SELECT_SCREEN_FORMAT();
// see if we had an error during decode (corrupted anim stream)
if ( (temp == NULL) && (temp_file_offset < 0) ) {
mprintf(("ANI: Fatal ERROR at frame %i!! Aborting playback of \"%s\"...\n", instance->frame_num, instance->parent->name));
// return -1 to end all playing of this anim instanc
return -1;
}
if(instance->direction == ANIM_DIRECT_FORWARD){
if ( anim_instance_is_streamed(instance) ) {
instance->file_offset = temp_file_offset;
@@ -833,10 +791,8 @@ int anim_stop_playing(anim_instance* instance)
void anim_release_render_instance(anim_instance* instance)
{
Assert( instance != NULL );
if (instance->frame != NULL)
vm_free(instance->frame);
Assert(instance->frame);
free(instance->frame);
instance->frame = NULL;
instance->parent->instance_count--;
@@ -945,7 +901,7 @@ void anim_read_header(anim *ptr, CFILE *fp)
floor_pow++;
}
int floor_size = (int) pow(2.0, floor_pow);
int floor_size = (int) pow(2, floor_pow);
int diff = ptr->height - floor_size;
float waste = 100.0f * float((floor_size - diff))/(2.0f *(float)floor_size);
@@ -958,7 +914,6 @@ void anim_read_header(anim *ptr, CFILE *fp)
ptr->total_frames = cfread_short(fp);
cfread(&ptr->packer_code, 1, 1, fp);
ptr->packer_code = INTEL_SHORT(ptr->packer_code);
cfread(&ptr->palette, 256, 3, fp);
ptr->num_keys = cfread_short(fp);
@@ -1019,7 +974,7 @@ anim *anim_load(char *real_filename, int file_mapped)
if ( !fp )
return NULL;
ptr = (anim *) vm_malloc(sizeof(anim));
ptr = (anim *) malloc(sizeof(anim));
Assert(ptr);
ptr->flags = 0;
@@ -1037,7 +992,7 @@ anim *anim_load(char *real_filename, int file_mapped)
anim_read_header(ptr, fp);
if(ptr->num_keys > 0){
ptr->keys = (key_frame*)vm_malloc(sizeof(key_frame) * ptr->num_keys);
ptr->keys = (key_frame*)malloc(sizeof(key_frame) * ptr->num_keys);
Assert(ptr->keys != NULL);
}
@@ -1048,14 +1003,12 @@ anim *anim_load(char *real_filename, int file_mapped)
ptr->keys[idx].frame_num = 0;
cfread(&ptr->keys[idx].frame_num, 2, 1, fp);
cfread(&ptr->keys[idx].offset, 4, 1, fp);
ptr->keys[idx].frame_num = INTEL_INT( ptr->keys[idx].frame_num );
ptr->keys[idx].offset = INTEL_INT( ptr->keys[idx].offset );
}
/*prev_keyp = &ptr->keys;
count = ptr->num_keys;
while (count--) {
keyp = (key_frame *) vm_malloc(sizeof(key_frame));
keyp = (key_frame *) malloc(sizeof(key_frame));
keyp->next = *prev_keyp;
*prev_keyp = keyp;
prev_keyp = &keyp->next;
@@ -1065,7 +1018,6 @@ anim *anim_load(char *real_filename, int file_mapped)
cfread(&keyp->offset, 4, 1, fp);
}*/
cfread(&count, 4, 1, fp); // size of compressed data
count = INTEL_INT( count );
ptr->cfile_ptr = NULL;
@@ -1096,7 +1048,7 @@ anim *anim_load(char *real_filename, int file_mapped)
if ( ptr->flags & ANF_STREAMED ) {
ptr->data = NULL;
ptr->cache_file_offset = ptr->file_offset;
ptr->cache = (ubyte*)vm_malloc(ANI_STREAM_CACHE_SIZE+2);
ptr->cache = (ubyte*)malloc(ANI_STREAM_CACHE_SIZE+2);
Assert(ptr->cache);
cfseek(ptr->cfile_ptr, offset, CF_SEEK_SET);
cfread(ptr->cache, ANI_STREAM_CACHE_SIZE, 1, ptr->cfile_ptr);
@@ -1107,7 +1059,7 @@ anim *anim_load(char *real_filename, int file_mapped)
// Not a memory mapped file (or streamed)
ptr->flags &= ~ANF_MEM_MAPPED;
ptr->flags &= ~ANF_STREAMED;
ptr->data = (ubyte *) vm_malloc(count);
ptr->data = (ubyte *) malloc(count);
ptr->file_offset = -1;
cfread(ptr->data, count, 1, fp);
}
@@ -1143,7 +1095,7 @@ int anim_free(anim *ptr)
}
if ( !list )
return -2;
return -1;
// only free when ref_count is 0
ptr->ref_count--;
@@ -1155,27 +1107,23 @@ int anim_free(anim *ptr)
return -1;
if(ptr->keys != NULL){
vm_free(ptr->keys);
free(ptr->keys);
ptr->keys = NULL;
}
if ( ptr->flags & (ANF_MEM_MAPPED|ANF_STREAMED) ) {
cfclose(ptr->cfile_ptr);
if ( ptr->cache ) {
vm_free(ptr->cache);
ptr->cache = NULL;
free(ptr->cache);
}
}
else {
Assert(ptr->data);
if ( ptr->data ) {
vm_free(ptr->data);
ptr->data = NULL;
}
free(ptr->data);
}
*prev_anim = ptr->next;
vm_free(ptr);
free(ptr);
return 0;
}
@@ -1243,7 +1191,7 @@ int anim_write_frames_out(char *filename)
ai = init_anim_instance(source_anim, 16);
row_data = (ubyte**)vm_malloc((source_anim->height+1) * 4);
row_data = (ubyte**)malloc((source_anim->height+1) * 4);
for ( i = 0; i < source_anim->total_frames; i++ ) {
anim_get_next_raw_buffer(ai, 0, 0, 16);
@@ -1266,7 +1214,7 @@ int anim_write_frames_out(char *filename)
}
printf("\n");
vm_free(row_data);
free(row_data);
return 0;
}
@@ -1299,7 +1247,7 @@ void anim_display_info(char *real_filename)
anim_read_header(&A, fp);
// read the keyframe frame nums and offsets
key_frame_nums = (int*)vm_malloc(sizeof(int)*A.num_keys);
key_frame_nums = (int*)malloc(sizeof(int)*A.num_keys);
Assert(key_frame_nums != NULL);
for ( i = 0; i < A.num_keys; i++ ) {
key_frame_nums[i] = 0;
@@ -1340,7 +1288,7 @@ void anim_display_info(char *real_filename)
printf("ac version: %d\n", A.version);
if ( key_frame_nums != NULL ) {
vm_free(key_frame_nums);
free(key_frame_nums);
}
cfclose(fp);
+4 -15
View File
@@ -9,24 +9,13 @@
/*
* $Logfile: /Freespace2/code/Anim/AnimPlay.h $
* $Revision: 2.6 $
* $Date: 2005-07-13 02:50:48 $
* $Author: Goober5000 $
* $Revision: 2.3 $
* $Date: 2003-12-08 22:30:02 $
* $Author: randomtiger $
*
* Header file for playing back anim files
*
* $Log: not supported by cvs2svn $
* Revision 2.5 2005/04/05 05:53:14 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.4 2004/08/11 05:06:18 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.3 2003/12/08 22:30:02 randomtiger
* Put render state and other direct D3D calls repetition check back in, provides speed boost.
* Fixed bug that caused fullscreen only crash with DXT textures
* Put dithering back in for tgas and jpgs
*
* Revision 2.2 2003/11/11 02:15:41 Goober5000
* ubercommit - basically spelling and language fixes with some additional
* warnings disabled
@@ -136,7 +125,7 @@ typedef struct {
int start_at;
int stop_at;
int screen_id;
vec3d *world_pos;
vector *world_pos;
float radius;
int framerate_independent;
void *color;
+10 -45
View File
@@ -9,33 +9,15 @@
/*
* $Logfile: /Freespace2/code/Anim/PackUnpack.cpp $
* $Revision: 2.10 $
* $Date: 2005-05-24 03:13:36 $
* $Author: taylor $
* $Revision: 2.5 $
* $Date: 2004-03-05 09:01:53 $
* $Author: Goober5000 $
*
* Code for handling packing and unpacking in Hoffoss's RLE format, used for
* Anim files. Also handles Anim loading, creating Anim instances (for
* utilizing an Anim), and getting getting frames of the Anim.
*
* $Log: not supported by cvs2svn $
* Revision 2.9 2005/05/23 05:58:31 taylor
* quick catch for some corrupted anis, only a partial fix but it will do until something
* a bit more heavy duty comes along in the near future
*
* Revision 2.8 2005/05/12 17:49:10 taylor
* use vm_malloc(), vm_free(), vm_realloc(), vm_strdup() rather than system named macros
* fixes various problems and is past time to make the switch
*
* Revision 2.7 2004/07/26 20:47:23 Kazan
* remove MCD complete
*
* Revision 2.6 2004/07/12 16:32:41 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.5 2004/03/05 09:01:53 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.4 2004/02/14 00:18:29 randomtiger
* Please note that from now on OGL will only run with a registry set by Launcher v4. See forum for details.
* OK, these changes effect a lot of file, I suggest everyone updates ASAP:
@@ -212,9 +194,6 @@
#include "graphics/2d.h"
#include "anim/animplay.h"
int packer_code = PACKER_CODE;
int transparent_code = 254;
@@ -247,7 +226,7 @@ anim_instance *init_anim_instance(anim *ptr, int bpp)
}
ptr->instance_count++;
inst = (anim_instance *) vm_malloc(sizeof(anim_instance));
inst = (anim_instance *) malloc(sizeof(anim_instance));
Assert(inst);
inst->frame_num = -1;
inst->last_frame_num = -1;
@@ -258,9 +237,9 @@ anim_instance *init_anim_instance(anim *ptr, int bpp)
inst->aa_color = NULL;
if(bpp == 16){
inst->frame = (ubyte *) vm_malloc(inst->parent->width * inst->parent->height * 2);
inst->frame = (ubyte *) malloc(inst->parent->width * inst->parent->height * 2);
} else {
inst->frame = (ubyte *) vm_malloc(inst->parent->width * inst->parent->height);
inst->frame = (ubyte *) malloc(inst->parent->width * inst->parent->height);
}
return inst;
}
@@ -268,14 +247,14 @@ anim_instance *init_anim_instance(anim *ptr, int bpp)
void free_anim_instance(anim_instance *inst)
{
Assert(inst->frame);
vm_free(inst->frame);
free(inst->frame);
inst->frame = NULL;
inst->parent->instance_count--;
inst->parent = NULL;
inst->data = NULL;
inst->file_offset = -1;
vm_free(inst);
free(inst);
}
int anim_get_next_frame(anim_instance *inst)
@@ -1016,9 +995,6 @@ ubyte *unpack_frame(anim_instance *ai, ubyte *ptr, ubyte *frame, int size, ubyte
count = value & (~STD_RLE_CODE);
value = *ptr++;
if (count > size)
count = size;
size -= count;
Assert(size >= 0);
@@ -1105,9 +1081,6 @@ ubyte *unpack_frame(anim_instance *ai, ubyte *ptr, ubyte *frame, int size, ubyte
count = value & (~STD_RLE_CODE);
value = *ptr++;
if (count > size)
count = size;
size -= count;
Assert(size >= 0);
@@ -1126,8 +1099,7 @@ ubyte *unpack_frame(anim_instance *ai, ubyte *ptr, ubyte *frame, int size, ubyte
}
}
else {
// Assert(0); // unknown packing method
return NULL;
Assert(0); // unknown packing method
}
return ptr;
@@ -1209,9 +1181,6 @@ int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal
value = anim_instance_get_byte(ai,offset);
offset++;
if (count > size)
count = size;
size -= count;
Assert(size >= 0);
@@ -1302,9 +1271,6 @@ int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal
value = anim_instance_get_byte(ai,offset);
offset++;
if (count > size)
count = size;
size -= count;
Assert(size >= 0);
@@ -1323,8 +1289,7 @@ int unpack_frame_from_file(anim_instance *ai, ubyte *frame, int size, ubyte *pal
}
}
else {
// Int3(); // unknown packing method
return -1;
Int3(); // unknown packing method
}
return ai->file_offset + offset;
+3 -13
View File
@@ -9,8 +9,8 @@
/*
* $Logfile: /Freespace2/code/Anim/PackUnpack.h $
* $Revision: 2.5 $
* $Date: 2005-07-13 02:50:48 $
* $Revision: 2.2 $
* $Date: 2004-03-05 09:01:53 $
* $Author: Goober5000 $
*
* Code for handling packing and unpacking in Hoffoss's RLE format, used for
@@ -18,16 +18,6 @@
* utilizing an Anim), and getting getting frames of the Anim.
*
* $Log: not supported by cvs2svn $
* Revision 2.4 2005/04/05 05:53:14 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.3 2004/08/11 05:06:18 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.2 2004/03/05 09:01:53 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.1 2002/08/01 01:41:04 penguin
* The big include file move
*
@@ -223,7 +213,7 @@ typedef struct anim {
typedef struct anim_instance {
anim_instance *next, *prev;
int x,y; // coordinates anim is played at (top left corner of anim)
vec3d *world_pos; // world (x,y,z) position of explosion
vector *world_pos; // world (x,y,z) position of explosion
float radius; // radius of image, needed for scaling
int frame_num; // current frame, or last frame if between frames (first frame is 0)
int last_frame_num;// last frame rendered
+192 -89
View File
@@ -9,57 +9,13 @@
/*
* $Logfile: /Freespace2/code/Asteroid/Asteroid.cpp $
* $Revision: 2.20 $
* $Date: 2005-07-22 10:18:36 $
* $Revision: 2.7 $
* $Date: 2004-03-31 05:42:25 $
* $Author: Goober5000 $
*
* C module for asteroid code
*
* $Log: not supported by cvs2svn $
* Revision 2.19 2005/07/13 02:50:48 Goober5000
* remove PreProcDefine #includes in FS2
* --Goober5000
*
* Revision 2.18 2005/07/13 02:01:28 Goober5000
* fixed a bunch of "issues" caused by me with the species stuff
* --Goober5000
*
* Revision 2.17 2005/07/13 00:44:20 Goober5000
* improved species support and removed need for #define
* --Goober5000
*
* Revision 2.16 2005/06/01 09:34:59 taylor
* newline fix
*
* Revision 2.15 2005/04/28 05:29:28 wmcoolmon
* Removed FS2_DEMO defines that looked like they wouldn't cause the universe to collapse
*
* Revision 2.14 2005/04/28 01:32:57 wmcoolmon
* Switch stuff_string_white to stuff_string (I don't see why _white was used in the first place)
*
* Revision 2.13 2005/04/15 11:41:28 taylor
* stupid <expletive-delete> terminal, I <expletive-deleted> <expletive-deleted>!!!
*
* Revision 2.12 2005/04/15 11:36:55 taylor
* new GCC = new warning messages, yippeeee!!
*
* Revision 2.11 2005/04/05 05:53:14 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.10 2005/03/02 21:24:43 taylor
* more network/inferno goodness for Windows, takes care of a few warnings too
*
* Revision 2.9 2004/07/26 20:47:23 Kazan
* remove MCD complete
*
* Revision 2.8 2004/07/12 16:32:41 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.7 2004/03/31 05:42:25 Goober5000
* got rid of all those nasty warnings from xlocale and so forth; also added comments
* for #pragma warning disable to indicate the message being disabled
* --Goober5000
*
* Revision 2.6 2004/03/05 09:01:53 Goober5000
* Uber pass at reducing #includes
* --Goober5000
@@ -338,7 +294,6 @@
* $NoKeywords: $
*/
#include "asteroid/asteroid.h"
#include "object/object.h"
#include "object/objcollide.h"
@@ -370,15 +325,59 @@
#include "network/multi.h"
#endif
//WMC - we want asteroid ability with demo!!
//#ifndef FS2_DEMO
#ifndef FS2_DEMO
#define ASTEROID_OBJ_USED (1<<0) // flag used in asteroid_obj struct
#define MAX_ASTEROID_OBJS MAX_ASTEROIDS // max number of asteroids tracked in asteroid list
asteroid_obj Asteroid_objs[MAX_ASTEROID_OBJS]; // array used to store asteroid object indexes
asteroid_obj Asteroid_obj_list; // head of linked list of asteroid_obj structs
// Asteroid editor requires first set of entries to be "None" and then "Asteroid XXX"
// Any changes to this will require changes to the asteroid editor
debris_struct Field_debris_info[] = {
-1, "None",
ASTEROID_TYPE_SMALL, "Asteroid Small",
ASTEROID_TYPE_MEDIUM, "Asteroid Medium",
ASTEROID_TYPE_BIG, "Asteroid Large",
DEBRIS_TERRAN_SMALL, "Terran Small",
DEBRIS_TERRAN_MEDIUM, "Terran Medium",
DEBRIS_TERRAN_LARGE, "Terran Large",
DEBRIS_VASUDAN_SMALL, "Vasudan Small",
DEBRIS_VASUDAN_MEDIUM, "Vasudan Medium",
DEBRIS_VASUDAN_LARGE, "Vasudan Large",
DEBRIS_SHIVAN_SMALL, "Shivan Small",
DEBRIS_SHIVAN_MEDIUM, "Shivan Medium",
#if !defined(MORE_SPECIES)
DEBRIS_SHIVAN_LARGE, "Shivan Large"
#else
DEBRIS_SHIVAN_LARGE, "Shivan Large",
DEBRIS_ANCIENT_SMALL, "Ancient Small",
DEBRIS_ANCIENT_MEDIUM, "Ancient Medium",
DEBRIS_ANCIENT_LARGE, "Ancient Large",
DEBRIS_USER1_SMALL, "User1 Small",
DEBRIS_USER1_MEDIUM, "User1 Medium",
DEBRIS_USER1_LARGE, "User1 Large",
DEBRIS_USER2_SMALL, "User2 Small",
DEBRIS_USER2_MEDIUM, "User2 Medium",
DEBRIS_USER2_LARGE, "User2 Large",
DEBRIS_USER3_SMALL, "User3 Small",
DEBRIS_USER3_MEDIUM, "User3 Medium",
DEBRIS_USER3_LARGE, "User3 Large",
DEBRIS_USER4_SMALL, "User4 Small",
DEBRIS_USER4_MEDIUM, "User4 Medium",
DEBRIS_USER4_LARGE, "User4 Large",
#endif
};
// used for randomly generating debris type when there are multiple sizes.
#define SMALL_DEBRIS_WEIGHT 8
#define MEDIUM_DEBRIS_WEIGHT 4
@@ -484,7 +483,7 @@ float asteroid_cap_speed(int asteroid_info_index, float speed)
// Returns whether position is inside inner bounding volume
// sum together the following: 1 inside x, 2 inside y, 4 inside z
// inside only when sum = 7
int asteroid_in_inner_bound_with_axes(asteroid_field *asfieldp, vec3d *pos, float delta)
int asteroid_in_inner_bound_with_axes(asteroid_field *asfieldp, vector *pos, float delta)
{
Assert(asfieldp->has_inner_bound);
@@ -506,7 +505,7 @@ int asteroid_in_inner_bound_with_axes(asteroid_field *asfieldp, vec3d *pos, floa
// check if asteroid is within inner bound
// return 0 if not inside or no inner bound, 1 if inside inner bound
int asteroid_in_inner_bound(asteroid_field *asfieldp, vec3d *pos, float delta) {
int asteroid_in_inner_bound(asteroid_field *asfieldp, vector *pos, float delta) {
if (!asfieldp->has_inner_bound) {
return 0;
@@ -517,7 +516,7 @@ int asteroid_in_inner_bound(asteroid_field *asfieldp, vec3d *pos, float delta) {
// repositions asteroid outside the inner box on all 3 axes
// moves to the other side of the inner box a distance delta from edge of box
void inner_bound_pos_fixup(asteroid_field *asfieldp, vec3d *pos)
void inner_bound_pos_fixup(asteroid_field *asfieldp, vector *pos)
{
if (!asteroid_in_inner_bound(asfieldp, pos, 0)) {
return;
@@ -548,7 +547,7 @@ object *asteroid_create(asteroid_field *asfieldp, int asteroid_type, int asteroi
object *objp;
asteroid *asp;
asteroid_info *asip;
vec3d pos, delta_bound;
vector pos, delta_bound;
angles angs;
float radius;
ushort signature;
@@ -663,7 +662,7 @@ object *asteroid_create(asteroid_field *asfieldp, int asteroid_type, int asteroi
radius = 1.0f;
}
vec3d rotvel;
vector rotvel;
if ( Game_mode & GM_NORMAL ) {
vm_vec_rand_vec_quick(&rotvel);
vm_vec_scale(&rotvel, frand()/4.0f + 0.1f);
@@ -716,7 +715,7 @@ object *asteroid_create(asteroid_field *asfieldp, int asteroid_type, int asteroi
}
// Create asteroids when parent_objp blows up.
void asteroid_sub_create(object *parent_objp, int asteroid_type, vec3d *relvec)
void asteroid_sub_create(object *parent_objp, int asteroid_type, vector *relvec)
{
object *new_objp;
float speed;
@@ -805,6 +804,8 @@ int get_debris_from_same_group(int index) {
// the weight is then used to determine the frequencty of different sizes of ship debris
int get_debris_weight(int ship_debris_index)
{
#if defined(MORE_SPECIES)
if (ship_debris_index % 3 == 0)
return SMALL_DEBRIS_WEIGHT;
@@ -815,6 +816,32 @@ int get_debris_weight(int ship_debris_index)
return LARGE_DEBRIS_WEIGHT;
//Int3();
return 1;
#else
switch (ship_debris_index) {
case DEBRIS_TERRAN_SMALL:
case DEBRIS_VASUDAN_SMALL:
case DEBRIS_SHIVAN_SMALL:
return SMALL_DEBRIS_WEIGHT;
break;
case DEBRIS_TERRAN_MEDIUM:
case DEBRIS_VASUDAN_MEDIUM:
case DEBRIS_SHIVAN_MEDIUM:
return MEDIUM_DEBRIS_WEIGHT;
break;
case DEBRIS_TERRAN_LARGE:
case DEBRIS_VASUDAN_LARGE:
case DEBRIS_SHIVAN_LARGE:
return LARGE_DEBRIS_WEIGHT;
break;
default:
Int3();
return 1;
break;
}
#endif
}
// Create all the asteroids for the mission, called from
@@ -1020,8 +1047,8 @@ int asteroid_is_targeted(object *objp)
// Create an asteroid that will hit object *objp in delta_time seconds
void asteroid_aim_at_target(object *objp, object *asteroid_objp, float delta_time)
{
vec3d predicted_center_pos;
vec3d rand_vec;
vector predicted_center_pos;
vector rand_vec;
float speed;
vm_vec_scale_add(&predicted_center_pos, &objp->pos, &objp->phys_info.vel, delta_time);
@@ -1126,7 +1153,7 @@ void asteroid_maybe_reposition(object *objp, asteroid_field *asfieldp)
}
if ( asteroid_should_wrap(objp, asfieldp) ) {
vec3d vec_to_asteroid, old_asteroid_pos, old_vel;
vector vec_to_asteroid, old_asteroid_pos, old_vel;
float dot, dist;
old_asteroid_pos = objp->pos;
@@ -1184,7 +1211,7 @@ void lerp(float *goal, float f1, float f2, float scale)
void asteroid_process_pre( object *objp, float frame_time)
{
if (Asteroids_enabled) {
vec3d *v, *vv;
vector *v, *vv;
v = &objp->phys_info.vel;
vv = &objp->phys_info.desired_vel;
@@ -1200,7 +1227,7 @@ void asteroid_process_pre( object *objp, float frame_time)
#pragma warning ( push )
#pragma warning ( disable : 4701 ) // possible use of variable without initialization
int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos, collision_info_struct *asteroid_hit_info)
int asteroid_check_collision(object *pasteroid, object *other_obj, vector *hitpos, collision_info_struct *asteroid_hit_info)
{
if (!Asteroids_enabled) {
return 0;
@@ -1244,7 +1271,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
object *heavy_obj = heavy;
object *light_obj = light;
vec3d zero, p0, p1;
vector zero, p0, p1;
vm_vec_zero( &zero );
vm_vec_sub( &p0, &light->last_pos, &heavy->last_pos );
vm_vec_sub( &p1, &light->pos, &heavy->pos );
@@ -1254,7 +1281,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
mc.p1 = &p1; // Point 2 of ray to check
// find the light object's position in the heavy object's reference frame at last frame and also in this frame.
vec3d p0_temp, p0_rotated;
vector p0_temp, p0_rotated;
// Collision detection from rotation enabled if at rotaion is less than 30 degree in frame
// This should account for all ships
@@ -1287,7 +1314,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
// copy important data
int copy_flags = mc.flags; // make a copy of start end positions of sphere in big ship RF
vec3d copy_p0, copy_p1;
vector copy_p0, copy_p1;
copy_p0 = *mc.p0;
copy_p1 = *mc.p1;
@@ -1358,7 +1385,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
}
// find position in submodel RF of light object at collison
vec3d int_light_pos, diff;
vector int_light_pos, diff;
vm_vec_sub(&diff, mc.p1, mc.p0);
vm_vec_scale_add(&int_light_pos, mc.p0, &diff, mc.hit_dist);
model_find_world_point(&asteroid_hit_info->light_collision_cm_pos, &int_light_pos, mc.model_num, mc.hit_submodel, &heavy_obj->orient, &zero);
@@ -1390,7 +1417,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
}
// find position in submodel RF of light object at collison
vec3d diff;
vector diff;
vm_vec_sub(&diff, mc.p1, mc.p0);
vm_vec_scale_add(&asteroid_hit_info->light_collision_cm_pos, mc.p0, &diff, mc.hit_dist);
@@ -1421,7 +1448,7 @@ int asteroid_check_collision(object *pasteroid, object *other_obj, vec3d *hitpos
}
// find position in submodel RF of light object at collison
vec3d diff;
vector diff;
vm_vec_sub(&diff, mc.p1, mc.p0);
vm_vec_scale_add(&asteroid_hit_info->light_collision_cm_pos, mc.p0, &diff, mc.hit_dist);
@@ -1479,9 +1506,9 @@ void asteroid_render(object * obj)
}
// Create a normalized vector generally in the direction from *hitpos to other_obj->pos
void asc_get_relvec(vec3d *relvec, object *other_obj, vec3d *hitpos)
void asc_get_relvec(vector *relvec, object *other_obj, vector *hitpos)
{
vec3d tvec, rand_vec;
vector tvec, rand_vec;
int count = 0;
vm_vec_normalized_dir(&tvec, &other_obj->pos, hitpos);
@@ -1544,6 +1571,7 @@ void asteriod_explode_sound(object *objp, int type, int play_loud)
int sound_index = -1;
float range_factor = 1.0f; // how many times sound should traver farther than normal
#if defined(MORE_SPECIES)
if (type % 3 <= 1)
{
sound_index = SND_ASTEROID_EXPLODE_SMALL;
@@ -1554,7 +1582,33 @@ void asteriod_explode_sound(object *objp, int type, int play_loud)
sound_index = SND_ASTEROID_EXPLODE_BIG;
range_factor = 10.0f;
}
#else
switch (type) {
case ASTEROID_TYPE_SMALL:
case ASTEROID_TYPE_MEDIUM:
case DEBRIS_TERRAN_SMALL:
case DEBRIS_TERRAN_MEDIUM:
case DEBRIS_VASUDAN_SMALL:
case DEBRIS_VASUDAN_MEDIUM:
case DEBRIS_SHIVAN_SMALL:
case DEBRIS_SHIVAN_MEDIUM:
sound_index = SND_ASTEROID_EXPLODE_SMALL;
range_factor = 5.0f;
break;
case ASTEROID_TYPE_BIG:
case DEBRIS_TERRAN_LARGE:
case DEBRIS_VASUDAN_LARGE:
case DEBRIS_SHIVAN_LARGE:
sound_index = SND_ASTEROID_EXPLODE_BIG;
range_factor = 10.0f;
break;
default:
Int3();
return;
}
#endif
Assert(sound_index != -1);
if ( !play_loud ) {
@@ -1606,7 +1660,7 @@ void asteroid_do_area_effect(object *asteroid_objp)
// other_obj => object that hit asteroid, can be NULL if asteroid hit by area effect
// hitpos => world position asteroid was hit, can be NULL if hit by area effect
// damage => amount of damage to apply to asteroid
void asteroid_hit( object * asteroid_obj, object * other_obj, vec3d * hitpos, float damage )
void asteroid_hit( object * asteroid_obj, object * other_obj, vector * hitpos, float damage )
{
float explosion_life;
asteroid *asp;
@@ -1644,7 +1698,7 @@ void asteroid_hit( object * asteroid_obj, object * other_obj, vec3d * hitpos, fl
} else {
asp->death_hit_pos = asteroid_obj->pos;
// randomize hit pos a bit, otherwise we will get a NULL vector when trying to find direction to toss child asteroids
vec3d rand_vec;
vector rand_vec;
vm_vec_rand_vec_quick(&rand_vec);
vm_vec_add2(&asp->death_hit_pos, &rand_vec);
}
@@ -1750,7 +1804,7 @@ void asteroid_maybe_break_up(object *asteroid_obj)
asp = &Asteroids[asteroid_obj->instance];
if ( timestamp_elapsed(asp->final_death_time) ) {
vec3d relvec, vfh, tvec;
vector relvec, vfh, tvec;
asteroid_obj->flags |= OF_SHOULD_BE_DEAD;
@@ -1760,6 +1814,7 @@ void asteroid_maybe_break_up(object *asteroid_obj)
if ( !MULTIPLAYER_CLIENT ) {
#endif
#if defined(MORE_SPECIES)
if (asp->type <= ASTEROID_TYPE_BIG) // 3
// if this isn't true it's just debris, and debris doesn't break up
{
@@ -1786,7 +1841,7 @@ void asteroid_maybe_break_up(object *asteroid_obj)
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_MEDIUM, &tvec);
while (frand() > 0.6f) {
vec3d rvec, tvec2;
vector rvec, tvec2;
vm_vec_rand_vec_quick(&rvec);
vm_vec_scale_add(&tvec2, &vfh, &rvec, 0.75f);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_SMALL, &tvec2);
@@ -1797,6 +1852,54 @@ void asteroid_maybe_break_up(object *asteroid_obj)
break;
}
}
#else
switch (asp->type) {
case ASTEROID_TYPE_SMALL:
break;
case ASTEROID_TYPE_MEDIUM:
asc_get_relvec(&relvec, asteroid_obj, &asp->death_hit_pos);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_SMALL, &relvec);
vm_vec_normalized_dir(&vfh, &asteroid_obj->pos, &asp->death_hit_pos);
vm_vec_copy_scale(&tvec, &vfh, 2.0f);
vm_vec_sub2(&tvec, &relvec);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_SMALL, &tvec);
break;
case ASTEROID_TYPE_BIG:
asc_get_relvec(&relvec, asteroid_obj, &asp->death_hit_pos);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_MEDIUM, &relvec);
vm_vec_normalized_dir(&vfh, &asteroid_obj->pos, &asp->death_hit_pos);
vm_vec_copy_scale(&tvec, &vfh, 2.0f);
vm_vec_sub2(&tvec, &relvec);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_MEDIUM, &tvec);
while (frand() > 0.6f) {
vector rvec, tvec2;
vm_vec_rand_vec_quick(&rvec);
vm_vec_scale_add(&tvec2, &vfh, &rvec, 0.75f);
asteroid_sub_create(asteroid_obj, ASTEROID_TYPE_SMALL, &tvec2);
}
break;
// ship debris does not break up
case DEBRIS_TERRAN_SMALL:
case DEBRIS_TERRAN_MEDIUM:
case DEBRIS_TERRAN_LARGE:
case DEBRIS_VASUDAN_SMALL:
case DEBRIS_VASUDAN_MEDIUM:
case DEBRIS_VASUDAN_LARGE:
case DEBRIS_SHIVAN_SMALL:
case DEBRIS_SHIVAN_MEDIUM:
case DEBRIS_SHIVAN_LARGE:
break;
default:
Int3();
}
#endif
#ifndef NO_NETWORK
}
#endif
@@ -1805,10 +1908,10 @@ void asteroid_maybe_break_up(object *asteroid_obj)
}
}
int asteroid_get_random_in_cone(vec3d *pos, vec3d *dir, float ang, int danger)
int asteroid_get_random_in_cone(vector *pos, vector *dir, float ang, int danger)
{
int idx;
vec3d asteroid_dir;
vector asteroid_dir;
// just pick the first asteroid which satisfies our condition
for(idx=0; idx<Num_asteroids; idx++){
@@ -1827,7 +1930,7 @@ int asteroid_get_random_in_cone(vec3d *pos, vec3d *dir, float ang, int danger)
void asteroid_test_collide(object *asteroid_obj, object *ship_obj, mc_info *mc)
{
float asteroid_ray_dist;
vec3d asteroid_fvec, terminus;
vector asteroid_fvec, terminus;
// See if ray from asteroid intersects bounding box of escort ship
asteroid_ray_dist = vm_vec_mag_quick(&asteroid_obj->phys_info.desired_vel) * ASTEROID_MIN_COLLIDE_TIME;
@@ -2014,14 +2117,14 @@ void asteroid_parse_section()
stuff_string(asip->name, F_NAME, NULL);
required_string( "$POF file1:" );
stuff_string(asip->pof_files[0], F_NAME, NULL);
stuff_string_white( asip->pof_files[0] );
required_string( "$POF file2:" );
stuff_string(asip->pof_files[1], F_NAME, NULL);
stuff_string_white( asip->pof_files[1] );
if ( (strstr(asip->name,"Asteroid") != NULL) || (strstr(asip->name, "asteroid") != NULL) ) {
required_string( "$POF file3:" );
stuff_string(asip->pof_files[2], F_NAME, NULL);
stuff_string_white( asip->pof_files[2] );
}
asip->num_detail_levels = 0;
@@ -2063,11 +2166,8 @@ void asteroid_parse_tbl()
required_string("#Asteroid Types");
// total we're expecting
int Total_asteroid_types = ((True_NumSpecies + 1) * 3);
while (required_string_either("#End","$Name:")) {
Assert( Num_asteroid_types < Total_asteroid_types );
Assert( Num_asteroid_types < MAX_DEBRIS_TYPES );
asteroid_parse_section();
Num_asteroid_types++;
}
@@ -2075,7 +2175,11 @@ void asteroid_parse_tbl()
required_string("#End");
// check all read in
Assert(Num_asteroid_types == Total_asteroid_types);
#if defined(MORE_SPECIES)
Assert(Num_asteroid_types == (True_NumSpecies + 1) * 3);//the species + normal asteroids
#else
Assert(Num_asteroid_types == MAX_DEBRIS_TYPES);
#endif
Asteroid_impact_explosion_ani = -1;
required_string("$Impact Explosion:");
@@ -2298,7 +2402,7 @@ void asteroid_page_in()
}
}
}
/*
#else
// stubbed out functions not used in the demo
@@ -2310,8 +2414,8 @@ void asteroid_render( object *asteroid_objp ) {}
void asteroid_delete( object *asteroid_objp ) {}
void asteroid_process_pre( object *asteroid_objp, float frame_time) {}
void asteroid_process_post( object *asteroid_objp, float frame_time) {}
int asteroid_check_collision( object *asteroid_objp, object * other_obj, vec3d * hitpos, collision_info_struct *asteroid_hit_info ) {return 0;}
void asteroid_hit( object *asteroid_objp, object *other_objp, vec3d *hitpos, float damage ) {}
int asteroid_check_collision( object *asteroid_objp, object * other_obj, vector * hitpos, collision_info_struct *asteroid_hit_info ) {return 0;}
void asteroid_hit( object *asteroid_objp, object *other_objp, vector *hitpos, float damage ) {}
void asteroid_save_restore(CFILE *fp) {}
int asteroid_count() {return 0;}
int asteroid_collide_objnum(object *asteroid_objp) {return 0;}
@@ -2319,9 +2423,8 @@ float asteroid_time_to_impact(object *asteroid_objp) {return 0.0f;}
void asteroid_show_brackets() {}
void asteroid_target_closest_danger() {}
void asteroid_page_in() {}
void asteroid_sub_create(object *parent_objp, int asteroid_type, vec3d *relvec) {}
void asteroid_sub_create(object *parent_objp, int asteroid_type, vector *relvec) {}
void asteroid_frame() {}
#endif
*/
+93 -34
View File
@@ -9,31 +9,13 @@
/*
* $Logfile: /Freespace2/code/Asteroid/Asteroid.h $
* $Revision: 2.9 $
* $Date: 2005-07-13 02:50:48 $
* $Revision: 2.4 $
* $Date: 2004-03-05 09:01:53 $
* $Author: Goober5000 $
*
* Header file for asteroids
*
* $Log: not supported by cvs2svn $
* Revision 2.8 2005/07/13 02:01:28 Goober5000
* fixed a bunch of "issues" caused by me with the species stuff
* --Goober5000
*
* Revision 2.7 2005/07/13 00:44:20 Goober5000
* improved species support and removed need for #define
* --Goober5000
*
* Revision 2.6 2005/04/05 05:53:14 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.5 2004/08/11 05:06:18 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.4 2004/03/05 09:01:53 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.3 2003/10/15 22:03:23 Kazan
* Da Species Update :D
*
@@ -162,14 +144,79 @@ struct collision_info_struct;
#define MAX_ASTEROIDS 256
// DEBRIS TYPES
#if defined(MORE_SPECIES)
#define DEBRIS_NAME_MASK 0x000f
// -----------------------------------
// Kazan Extended Species version
// -----------------------------------
#define MAX_DEBRIS_TYPES 27
#define ASTEROID_TYPE_SMALL 0
#define ASTEROID_TYPE_MEDIUM 1
#define ASTEROID_TYPE_BIG 2
// terran
#define DEBRIS_TERRAN_SMALL 3
#define DEBRIS_TERRAN_MEDIUM 4
#define DEBRIS_TERRAN_LARGE 5
// vasudan
#define DEBRIS_VASUDAN_SMALL 6
#define DEBRIS_VASUDAN_MEDIUM 7
#define DEBRIS_VASUDAN_LARGE 8
// shivan
#define DEBRIS_SHIVAN_SMALL 9
#define DEBRIS_SHIVAN_MEDIUM 10
#define DEBRIS_SHIVAN_LARGE 11
// ancient
#define DEBRIS_ANCIENT_SMALL 12
#define DEBRIS_ANCIENT_MEDIUM 13
#define DEBRIS_ANCIENT_LARGE 14
// user1
#define DEBRIS_USER1_SMALL 15
#define DEBRIS_USER1_MEDIUM 16
#define DEBRIS_USER1_LARGE 17
// user2
#define DEBRIS_USER2_SMALL 18
#define DEBRIS_USER2_MEDIUM 19
#define DEBRIS_USER2_LARGE 20
// user3
#define DEBRIS_USER3_SMALL 21
#define DEBRIS_USER3_MEDIUM 22
#define DEBRIS_USER3_LARGE 23
// user4
#define DEBRIS_USER4_SMALL 24
#define DEBRIS_USER4_MEDIUM 25
#define DEBRIS_USER4_LARGE 26
#else
// -----------------------------------
// Old Volition Version
// -----------------------------------
#define MAX_DEBRIS_TYPES 12
//
#define ASTEROID_TYPE_SMALL 0
#define ASTEROID_TYPE_MEDIUM 1
#define ASTEROID_TYPE_BIG 2
//
#define DEBRIS_TERRAN_SMALL 3
#define DEBRIS_TERRAN_MEDIUM 4
#define DEBRIS_TERRAN_LARGE 5
//
#define DEBRIS_VASUDAN_SMALL 6
#define DEBRIS_VASUDAN_MEDIUM 7
#define DEBRIS_VASUDAN_LARGE 8
//
#define DEBRIS_SHIVAN_SMALL 9
#define DEBRIS_SHIVAN_MEDIUM 10
#define DEBRIS_SHIVAN_LARGE 11
// END DEBRIS TYPES
#endif
// This is for the asteroid types plus DEBRIS_X_Y
// (X is each species and Y is SMALL, MEDIUM, and LARGE)
#define MAX_DEBRIS_TYPES ((MAX_SPECIES + 1) * 3)
typedef struct debris_struct {
int index;
char *name;
} debris_struct;
// Data structure to track the active asteroids
typedef struct asteroid_obj {
@@ -179,6 +226,8 @@ typedef struct asteroid_obj {
extern asteroid_obj Asteroid_obj_list;
extern debris_struct Field_debris_info[];
#define MAX_ASTEROID_POFS 3 // Max number of POFs per asteroid type
#define AF_USED (1<<0) // Set means used.
@@ -211,10 +260,20 @@ typedef struct asteroid {
int final_death_time; // timestamp to swap in new models after explosion starts
int collide_objnum; // set to objnum that asteroid will be impacting soon
int collide_objsig; // object signature corresponding to collide_objnum
vec3d death_hit_pos; // hit pos that caused death
vector death_hit_pos; // hit pos that caused death
int target_objnum; // Yes, hah! Asteroids can have targets. See asteroid_aim_at_target().
} asteroid;
// TYPEDEF FOR SPECIES OF DEBRIS - BITFIELD
#define DS_TERRAN 0x01
#define DS_VASUDAN 0x02
#define DS_SHIVAN 0x04
#define DS_ANCIENT 0x08
#define DS_USER1 0x10
#define DS_USER2 0x20
#define DS_USER3 0x40
#define DS_USER4 0x80
// TYPEDEF FOR DEBRIS TYPE
typedef enum {
DG_ASTEROID,
@@ -230,12 +289,12 @@ typedef enum {
#define MAX_ACTIVE_DEBRIS_TYPES 3
typedef struct asteroid_field {
vec3d min_bound; // Minimum range of field.
vec3d max_bound; // Maximum range of field.
vector min_bound; // Minimum range of field.
vector max_bound; // Maximum range of field.
int has_inner_bound;
vec3d inner_min_bound;
vec3d inner_max_bound;
vec3d vel; // Average asteroid moves at this velocity.
vector inner_min_bound;
vector inner_max_bound;
vector vel; // Average asteroid moves at this velocity.
float speed; // Average speed of field
int num_initial_asteroids; // Number of asteroids at creation.
field_type_t field_type; // active throws and wraps, passive does not
@@ -259,17 +318,17 @@ void asteroid_render( object *asteroid_objp );
void asteroid_delete( object *asteroid_objp );
void asteroid_process_pre( object *asteroid_objp, float frame_time);
void asteroid_process_post( object *asteroid_objp, float frame_time);
int asteroid_check_collision( object *asteroid_objp, object * other_obj, vec3d * hitpos, collision_info_struct *asteroid_hit_info=NULL );
void asteroid_hit( object *asteroid_objp, object *other_objp, vec3d *hitpos, float damage );
int asteroid_check_collision( object *asteroid_objp, object * other_obj, vector * hitpos, collision_info_struct *asteroid_hit_info=NULL );
void asteroid_hit( object *asteroid_objp, object *other_objp, vector *hitpos, float damage );
int asteroid_count();
int asteroid_collide_objnum(object *asteroid_objp);
float asteroid_time_to_impact(object *asteroid_objp);
void asteroid_show_brackets();
void asteroid_target_closest_danger();
int asteroid_get_random_in_cone(vec3d *pos, vec3d *dir, float ang, int danger = 0);
int asteroid_get_random_in_cone(vector *pos, vector *dir, float ang, int danger = 0);
// need to extern for multiplayer
void asteroid_sub_create(object *parent_objp, int asteroid_type, vec3d *relvec);
void asteroid_sub_create(object *parent_objp, int asteroid_type, vector *relvec);
void asteroid_frame();
-839
View File
@@ -1,839 +0,0 @@
// Autopilot.cpp
// Derek Meek
// 4-30-2004
/*
* $Logfile: /Freespace2/code/Autopilot/Autopilot.cpp $
* $Revision: 1.22 $
* $Date: 2005-08-23 09:18:08 $
* $Author: Goober5000 $
*
* $Log: not supported by cvs2svn $
* Revision 1.21 2005/07/23 16:25:32 Goober5000
* remove an extraneous extern
* --Goober5000
*
* Revision 1.20 2005/07/13 02:30:52 Goober5000
* removed autopilot #define
* --Goober5000
*
* Revision 1.19 2005/04/19 23:03:42 wmcoolmon
* Lock time compression when autopilot is engaged
*
* Revision 1.18 2005/04/05 05:53:14 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 1.17 2005/03/25 06:57:32 wmcoolmon
* Big, massive, codebase commit. I have not removed the old ai files as the ones I uploaded aren't up-to-date (But should work with the rest of the codebase)
*
* Revision 1.16 2005/03/03 06:05:26 wmcoolmon
* Merge of WMC's codebase. "Features and bugs, making Goober say "Grr!", as release would be stalled now for two months for sure"
*
* Revision 1.15 2005/01/31 23:27:51 taylor
* merge with Linux/OSX tree - p0131-2
*
* Revision 1.14 2004/10/03 21:41:10 Kazan
* Autopilot convergence collision fix for ai_fly_to_ship() and ai_waypoints() -- mathematically expensive, only usable by autopilot
*
* Revision 1.13 2004/09/28 22:51:41 Kazan
* fix autopilot formation bug
*
* Revision 1.12 2004/09/28 19:54:31 Kazan
* | is binary or, || is boolean or - please use the right one
* autopilot velocity ramping biasing
* made debugged+k kill guardianed ships
*
* Revision 1.11 2004/07/29 23:41:21 Kazan
* bugfixes
*
* Revision 1.10 2004/07/27 18:52:10 Kazan
* squished another
*
* Revision 1.9 2004/07/27 18:04:09 Kazan
* i love it when bugs go crunch (autopilot ai fixup)
*
* Revision 1.8 2004/07/26 20:47:24 Kazan
* remove MCD complete
*
* Revision 1.7 2004/07/26 17:54:04 Kazan
* Autopilot system completed -- i am dropping plans for GUI nav map
* Fixed FPS counter during time compression
*
* Revision 1.6 2004/07/25 19:27:51 Kazan
* only disable afterburning during AIM_WAYPOINTS and AIM_FLY_TO_SHIP while AutoPilotEngaged
*
* Revision 1.5 2004/07/25 18:46:28 Kazan
* -fred_no_warn has become -no_warn and applies to both fred and fs2
* added new ai directive (last commit) and disabled afterburners while performing AIM_WAYPOINTS or AIM_FLY_TO_SHIP
* fixed player ship speed bug w/ player-use-ai, now stays in formation correctly and manages speed
* made -radar_reduce ignore itself if no parameter is given (ignoring launcher bug)
*
* Revision 1.4 2004/07/25 00:31:27 Kazan
* i have absolutely nothing to say about that subject
*
* Revision 1.3 2004/07/12 16:32:42 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 1.2 2004/07/01 16:38:18 Kazan
* working on autonav
*
* Revision 1.1 2004/05/07 23:50:14 Kazan
* Sorry Guys!
*
*
*
*
*/
#include "autopilot/autopilot.h"
#include "ai/ai.h"
#include "ai/aigoals.h"
#include "ship/ship.h"
#include "object/object.h"
#include "parse/sexp.h"
#include "freespace2/freespace.h"
// Extern functions/variables
extern int Player_use_ai;
extern int sexp_distance2(int obj1, char *subj);
// Module variables
bool AutoPilotEngaged;
int CurrentNav;
float ramp_bias;
NavPoint Navs[MAX_NAVPOINTS];
// used for ramping time compression;
int start_dist;
// ********************************************************************************************
void autopilot_ai_waypoint_goal_fixup(ai_goal* aigp)
{
// this function sets wp_index properly;
for (int i = 0; i < Num_waypoint_lists; i++)
{
if (!stricmp(aigp->ship_name, Waypoint_lists[i].name))
{
aigp->wp_index = i;
return;
}
}
}
// ********************************************************************************************
bool Sel_NextNav()
{
if (AutoPilotEngaged)
return false;
int i;
if (CurrentNav == -1)
{
for (i = 0; i < MAX_NAVPOINTS; i++)
{
if (Navs[i].flags & NP_VALIDTYPE && !(Navs[i].flags & NP_NOSELECT))
{
CurrentNav=i;
return true;
}
}
}
else
{
for (i = CurrentNav+1; i < MAX_NAVPOINTS+CurrentNav; i++)
{
if (Navs[i%MAX_NAVPOINTS].flags & NP_VALIDTYPE && !(Navs[i%MAX_NAVPOINTS].flags & NP_NOSELECT))
{
if (i != CurrentNav)
{
CurrentNav=i%MAX_NAVPOINTS;
return true;
}
}
}
}
return false;
}
// ********************************************************************************************
vec3d NavPoint::GetPosition()
{
vec3d position;
if (flags & NP_WAYPOINT)
{
position = ((waypoint_list*)target_obj)->waypoints[waypoint_num-1];
}
else
{
position = Objects[((ship*)target_obj)->objnum].pos;
}
return position;
}
char* NavPoint::GetInteralName()
{
char *NavName;
char strtmp[3];
if (flags & NP_WAYPOINT)
{
NavName = new char[strlen(((waypoint_list*)target_obj)->name)+5];
memset(NavName, 0, strlen(((waypoint_list*)target_obj)->name)+5);
strcpy(NavName, ((waypoint_list*)target_obj)->name);
strcat(NavName, ":");
strcat(NavName, itoa(waypoint_num, strtmp, 10));
}
else
{
NavName = new char[strlen(((ship*)target_obj)->ship_name)+1];
memset(NavName, 0, strlen(((ship*)target_obj)->ship_name)+1);
strcpy(NavName, ((ship*)target_obj)->ship_name);
}
return NavName;
}
// ********************************************************************************************
// Tell us is autopilot is allow
// This needs:
// * Nav point selected
// * No enemies within X distance
// * Destination > 1,000 meters away
bool CanAutopilot()
{
bool CanAuto = true;
CanAuto = CanAuto && CurrentNav != -1;
int dist = sexp_distance2(Player_ship->objnum, "<any hostile>");
CanAuto = CanAuto && (5000 <= dist || dist == SEXP_NAN);
if (CanAuto) // protect against no currentNav
{
char *name = Navs[CurrentNav].GetInteralName();
CanAuto = CanAuto && (1000 <= sexp_distance2(Player_ship->objnum, name));
delete[] name;
}
return CanAuto;
}
// ********************************************************************************************
// Engages autopilot
// This does:
// * Control switched from player to AI
// * Time compression to 32x
// * Lock time compression -WMC
// * Tell AI to fly to targetted Nav Point (for all nav-status wings/ships)
// * Sets max waypoint speed to the best-speed of the slowest ship tagged
void StartAutopilot()
{
if (!CanAutopilot())
return;
AutoPilotEngaged = true;
Player_use_ai = 1;
set_time_compression(1);
lock_time_compression(true);
// determine speed cap
int i,j;
float speed_cap = 1000000.0; // 1m is a safe starting point
for (i = 0; i < MAX_SHIPS; i++)
{
if (Ships[i].objnum != -1 &&
(Ships[i].flags2 & SF2_NAVPOINT_CARRY ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY)
)
)
{
if (speed_cap > Ship_info[Ships[i].ship_info_index].max_vel.xyz.z)
speed_cap = Ship_info[Ships[i].ship_info_index].max_vel.xyz.z;
}
}
// damp speed_cap to 90% of actual -- to make sure ships stay in formation
speed_cap = 0.90f * speed_cap;
ramp_bias = speed_cap/50.0f;
// assign ship goals
// when assigning goals to individual ships only do so if Ships[shipnum].wingnum != -1
// we will assign wing goals below
for (i = 0; i < MAX_SHIPS; i++)
{
if (Ships[i].objnum != -1 &&
(Ships[i].flags2 & SF2_NAVPOINT_CARRY ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY)
)
)
{
// clear the ship goals and cap the waypoint speed
ai_clear_ship_goals(&Ai_info[Ships[i].ai_index]);
Ai_info[Ships[i].ai_index].waypoint_speed_cap = (int)speed_cap;
// if they're not part of a wing set their goal
if (Ships[i].wingnum == -1)
{
if (Navs[CurrentNav].flags & NP_WAYPOINT)
{
ai_add_ship_goal_player( AIG_TYPE_PLAYER_WING, AI_GOAL_WAYPOINTS_ONCE, -1, ((waypoint_list*)Navs[CurrentNav].target_obj)->name, &Ai_info[Ships[i].ai_index] );
//fixup has to wait until after wing goals
}
else
{
ai_add_ship_goal_player( AIG_TYPE_PLAYER_WING, AI_GOAL_FLY_TO_SHIP, -1, ((ship*)Navs[CurrentNav].target_obj)->ship_name, &Ai_info[Ships[i].ai_index] );
}
}
}
}
// assign wing goals
for (i = 0; i < MAX_WINGS; i++)
{
if (Wings[i].flags & WF_NAV_CARRY )
{
//ai_add_ship_goal_player( int type, int mode, int submode, char *shipname, ai_info *aip );
//ai_add_wing_goal_player( AIG_TYPE_PLAYER_WING, AI_GOAL_STAY_NEAR_SHIP, 0, target_shipname, wingnum );
//ai_add_wing_goal_player( AIG_TYPE_PLAYER_WING, AI_GOAL_WAYPOINTS_ONCE, 0, target_shipname, wingnum );
//ai_clear_ship_goals( &(Ai_info[Ships[num].ai_index]) );
ai_clear_wing_goals( i );
if (Navs[CurrentNav].flags & NP_WAYPOINT)
{
ai_add_wing_goal_player( AIG_TYPE_PLAYER_WING, AI_GOAL_WAYPOINTS_ONCE, AIF_FORMATION_WING, ((waypoint_list*)Navs[CurrentNav].target_obj)->name, i );
// "fix up" the goal
for (j = 0; j < MAX_AI_GOALS; j++)
{
if (Wings[i].ai_goals[j].ai_mode == AI_GOAL_WAYPOINTS_ONCE ||
Wings[i].ai_goals[j].ai_mode == AIM_WAYPOINTS )
{
autopilot_ai_waypoint_goal_fixup(&(Wings[i].ai_goals[j]));
}
}
}
else
{
ai_add_wing_goal_player( AIG_TYPE_PLAYER_WING, AI_GOAL_FLY_TO_SHIP, AIF_FORMATION_WING, ((ship*)Navs[CurrentNav].target_obj)->ship_name, i );
}
}
}
// fixup has to go down here because ships are assigned goals during wing goals as well
for (i = 0; i < MAX_SHIPS; i++)
{
if (Ships[i].objnum != -1)
{
if (Ships[i].flags2 & SF2_NAVPOINT_CARRY ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY))
for (j = 0; j < MAX_AI_GOALS; j++)
{
if (Ai_info[Ships[i].ai_index].goals[j].ai_mode == AI_GOAL_WAYPOINTS_ONCE ||
Ai_info[Ships[i].ai_index].goals[j].ai_mode == AIM_WAYPOINTS)
{
autopilot_ai_waypoint_goal_fixup( &(Ai_info[Ships[i].ai_index].goals[j]) );
// formation fixup
//ai_form_on_wing(&Objects[Ships[i].objnum], &Objects[Player_ship->objnum]);
}
}
}
}
start_dist = DistanceTo(CurrentNav);
}
// ********************************************************************************************
// Checks if autopilot should automatically die
// Returns true if:
// * Targetted waypoint < 10,000 meters away
// * Enemy < 10,000 meters
bool Autopilot_AutoDiable()
{
return !CanAutopilot();
}
// ********************************************************************************************
// Disengages autopilot
// this does:
// * Time compression to 1x
// * Delete AI nav goal
// * Control switched from AI to player
void EndAutoPilot()
{
AutoPilotEngaged = false;
set_time_compression(1);
lock_time_compression(false);
Player_use_ai = 0;
//Clear AI Goals
// assign ship goals
// when assigning goals to individual ships only do so if Ships[shipnum].wingnum != -1
// we will assign wing goals below
int i,j;
for (i = 0; i < MAX_SHIPS; i++)
{
if (Ships[i].objnum != -1 &&
(
Ships[i].flags2 & SF2_NAVPOINT_CARRY ||
(Ships[i].wingnum != -1 && Wings[Ships[i].wingnum].flags & WF_NAV_CARRY )
)
)
{
Ai_info[Ships[i].ai_index].waypoint_speed_cap = -1; // uncap their speed
// old "dumb" routine
//ai_clear_ship_goals( &(Ai_info[Ships[i].ai_index]) );
for (j = 0; j < MAX_AI_GOALS; j++)
{
if (Ai_info[Ships[i].ai_index].goals[j].ai_mode == AI_GOAL_WAYPOINTS_ONCE ||
Ai_info[Ships[i].ai_index].goals[j].ai_mode == AI_GOAL_FLY_TO_SHIP ||
Ai_info[Ships[i].ai_index].goals[j].ai_mode == AIM_WAYPOINTS ||
Ai_info[Ships[i].ai_index].goals[j].ai_mode == AIM_FLY_TO_SHIP)
{
ai_remove_ship_goal( &(Ai_info[Ships[i].ai_index]), j );
}
}
}
}
// assign wing goals
for (i = 0; i < MAX_WINGS; i++)
{
if (Wings[i].flags & WF_NAV_CARRY )
{
// old "dumb" routine
//ai_clear_wing_goals( i );
for (j = 0; j < MAX_AI_GOALS; j++)
{
if (Wings[i].ai_goals[j].ai_mode == AI_GOAL_WAYPOINTS_ONCE ||
Wings[i].ai_goals[j].ai_mode == AI_GOAL_FLY_TO_SHIP ||
Wings[i].ai_goals[j].ai_mode == AIM_WAYPOINTS ||
Wings[i].ai_goals[j].ai_mode == AIM_FLY_TO_SHIP)
{
Wings[i].ai_goals[j].ai_mode = AI_GOAL_NONE;
Wings[i].ai_goals[j].signature = -1;
Wings[i].ai_goals[j].priority = -1;
Wings[i].ai_goals[j].flags = 0;
}
}
}
}
}
// ********************************************************************************************
// Checks for changes every NPS_TICKRATE milliseconds
// Checks:
// * if we've gotten close enough to a nav point for it to be counted as "Visited"
// * If we're current AutoNavigating it checks if we need to autodisengage
void NavSystem_Do()
{
static unsigned int last_update = 0;
if (clock () - last_update > NPS_TICKRATE)
{
if (AutoPilotEngaged)
if (Autopilot_AutoDiable())
EndAutoPilot();
// check if a NavPoints target has left, delete it if so
int i;
for (i = 0; i < MAX_NAVPOINTS; i++)
{
if ((Navs[i].flags & NP_SHIP) && (Navs[i].target_obj != NULL))
{
if (((ship*)Navs[i].target_obj)->objnum == -1)
DelNavPoint(i);
}
}
// check if we're reached a Node
for (i = 0; i < MAX_NAVPOINTS; i++)
{
if (Navs[i].target_obj != NULL)
{
if (Navs[i].flags & NP_VALIDTYPE && DistanceTo(i) < 1000)
Navs[i].flags |= NP_VISITED;
}
}
}
// ramp time compression
if (AutoPilotEngaged)
{
int dstfrm_start = start_dist - DistanceTo(CurrentNav);
// Ramp UP time compression
if (dstfrm_start < (3500*ramp_bias))
{
if (dstfrm_start >= (3000*ramp_bias) && DistanceTo(CurrentNav) > 30000)
set_time_compression(64);
else if (dstfrm_start >= (2000*ramp_bias))
set_time_compression(32);
else if (dstfrm_start >= (1600*ramp_bias))
set_time_compression(16);
else if (dstfrm_start >= (1200*ramp_bias))
set_time_compression(8);
else if (dstfrm_start >= (800*ramp_bias))
set_time_compression(4);
else if (dstfrm_start >= (400*ramp_bias))
set_time_compression(2);
}
// Ramp DOWN time compression
if (DistanceTo(CurrentNav) <= (7000*ramp_bias))
{
int dist = DistanceTo(CurrentNav);
if (dist >= (5000*ramp_bias))
set_time_compression(32);
else if (dist >= (4000*ramp_bias))
set_time_compression(16);
else if (dist >= (3000*ramp_bias))
set_time_compression(8);
else if (dist >= (2000*ramp_bias))
set_time_compression(4);
else if (dist >= (1000*ramp_bias))
set_time_compression(2);
}
}
}
// ********************************************************************************************
// Inits the Nav System
void NavSystem_Init()
{
memset((char *)&Navs, 0, sizeof(Navs));
AutoPilotEngaged = false;
CurrentNav = -1;
}
// ********************************************************************************************
// Finds a Nav point by name
int FindNav(char *Nav)
{
for (int i = 0; i < MAX_NAVPOINTS; i++)
{
if (!stricmp(Navs[i].NavName, Nav))
return i;
}
return -1;
}
// ********************************************************************************************
// Set A Nav point to "ZERO"
void ZeroNav(int i)
{
memset((char *)&Navs[i], 0, sizeof(NavPoint));
}
// ********************************************************************************************
// Removes a Nav
bool DelNavPoint(char *Nav)
{
int n = FindNav(Nav);
return DelNavPoint(n);
}
bool DelNavPoint(int nav)
{
if (nav != -1)
{
if (nav != MAX_NAVPOINTS-1)
{
for (int i = nav; i < MAX_NAVPOINTS-1; i++)
{
Navs[nav] = Navs[nav+1];
}
}
ZeroNav(MAX_NAVPOINTS-1);
return true;
}
return false;
}
// ********************************************************************************************
// adds a Nav
bool AddNav_Ship(char *Nav, char *TargetName, int flags)
{
// find an empty nav - should be the end
int empty = -1;
int i;
for (i = 0; i < MAX_NAVPOINTS && empty == -1; i++)
{
if (Navs[i].flags == 0)
empty = i;
}
if (empty == -1) // no empty navpoint slots
return false;
// Create the NavPoint struct
NavPoint tnav;
strncpy(tnav.NavName, Nav, 32);
tnav.flags = NP_SHIP | flags;
Assert(!(tnav.flags & NP_WAYPOINT));
for (i = 0; i < MAX_SHIPS; i++)
{
if (Ships[i].objnum != -1 && !stricmp(TargetName, Ships[i].ship_name))
{
tnav.target_obj = (void *)&Ships[i];
}
}
tnav.waypoint_num = 0; // unused for NP_SHIP
// copy it into it's location
Navs[empty] = tnav;
return true;
}
bool AddNav_Waypoint(char *Nav, char *WP_Path, int node, int flags)
{
// find an empty nav - should be the end
int empty = -1;
int i;
if (node == 0)
node = 1;
for (i = 0; i < MAX_NAVPOINTS && empty == -1; i++)
{
if (Navs[i].flags == 0)
empty = i;
}
if (empty == -1) // no empty navpoint slots
return false;
// Create the NavPoint struct
NavPoint tnav;
strncpy(tnav.NavName, Nav, 32);
tnav.flags = NP_WAYPOINT | flags;
Assert(!(tnav.flags & NP_SHIP));
for (i = 0; i < Num_waypoint_lists; i++)
{
if (!stricmp(WP_Path, Waypoint_lists[i].name))
{
tnav.target_obj = (void *)&Waypoint_lists[i];
}
}
tnav.waypoint_num = node;
// copy it into it's location
Navs[empty] = tnav;
return true;
}
// ********************************************************************************************
//Change Flags
bool Nav_Alt_Flags(char *Nav, int flags)
{
flags &= ~NP_VALIDTYPE; //clear the NP_SHIP and NP_WAYPOINT bits, make sure they haven't been set
int nav = FindNav(Nav);
if (nav != -1)
{
Navs[nav].flags &= NP_VALIDTYPE; // Clear all bits BUT NP_SHIP or NO_WAYPOINT
Navs[nav].flags |= flags; // merge
}
return (nav != -1);
}
//Get Flags
int Nav_Get_Flags(char *Nav)
{
int flags = 0;
int nav = FindNav(Nav);
if (nav != -1)
flags = Navs[nav].flags;
return flags;
}
// ********************************************************************************************
// Sexp Accessors
//Generic
bool Nav_Set_Flag(char *Nav, int flag)
{
Assert(!(flag & NP_VALIDTYPE));
int nav = FindNav(Nav);
if (nav != -1)
{
Navs[nav].flags |= flag;
return true;
}
return false;
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bool Nav_UnSet_Flag(char *Nav, int flag)
{
Assert(!(flag & NP_VALIDTYPE));
int nav = FindNav(Nav);
if (nav != -1)
{
Navs[nav].flags &= ~flag;
return true;
}
return false;
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//Named
bool Nav_Set_Hidden(char *Nav)
{
return Nav_Set_Flag(Nav, NP_HIDDEN);
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bool Nav_Set_NoAccess(char *Nav)
{
return Nav_Set_Flag(Nav, NP_NOACCESS);
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bool Nav_Set_Visited(char *Nav)
{
return Nav_Set_Flag(Nav, NP_VISITED);
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bool Nav_UnSet_Hidden(char *Nav)
{
return Nav_UnSet_Flag(Nav, NP_HIDDEN);
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bool Nav_UnSet_NoAccess(char *Nav)
{
return Nav_UnSet_Flag(Nav, NP_NOACCESS);
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bool Nav_UnSet_Visited(char *Nav)
{
return Nav_UnSet_Flag(Nav, NP_VISITED);
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
unsigned int DistanceTo(char *nav)
{
int n = FindNav(nav);
return DistanceTo(n);
}
unsigned int DistanceTo(int nav)
{
if (nav > MAX_NAVPOINTS && nav < 0)
return 0xFFFFFFFF;
char *name = Navs[nav].GetInteralName();
if (name == NULL)
return 0xFFFFFFFF;
int distance = sexp_distance2(Player_ship->objnum, name);
delete[] name;
if (distance == SEXP_NAN)
return 0xFFFFFFFF;
return distance;
}
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
bool IsVisited(char *nav)
{
int n = FindNav(nav);
return IsVisited(n);
}
bool IsVisited(int nav)
{
if (nav > MAX_NAVPOINTS && nav < 0)
return 0;
if (Navs[nav].flags & NP_VISITED)
return 1;
return 0;
}
-152
View File
@@ -1,152 +0,0 @@
// Autopilot.h
// Derek Meek
// 4-30-2004
/*
* $Logfile: /Freespace2/code/Autopilot/Autopilot.h $
* $Revision: 1.8 $
* $Date: 2005-07-13 02:50:49 $
* $Author: Goober5000 $
*
* $Log: not supported by cvs2svn $
* Revision 1.7 2005/04/05 05:53:14 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 1.6 2004/08/11 05:06:18 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 1.5 2004/07/27 18:52:10 Kazan
* squished another
*
* Revision 1.4 2004/07/25 19:27:51 Kazan
* only disable afterburning during AIM_WAYPOINTS and AIM_FLY_TO_SHIP while AutoPilotEngaged
*
* Revision 1.3 2004/07/25 00:31:27 Kazan
* i have absolutely nothing to say about that subject
*
* Revision 1.2 2004/07/01 16:38:18 Kazan
* working on autonav
*
* Revision 1.1 2004/05/07 23:50:14 Kazan
* Sorry Guys!
*
*
*
*
*/
#if !defined(_AUTOPILOT_H_)
#define _AUTOPILOT_H_
#include "globalincs/pstypes.h"
// milliseconds between updates
#define NPS_TICKRATE 250
#define MAX_NAVPOINTS 8
#define NP_WAYPOINT 0x0001 // Nav Point is bound to the poistion of a single node of a waypoint path
#define NP_SHIP 0x0002 // Nav Point is bound to the poisiton of a certain ship
#define NP_HIDDEN 0x0004 // Nav Point doesn't show on map and isn't selectable
#define NP_NOACCESS 0x0008 // Nav Point isn't selectable
#define NP_VISITED 0x0100 // Whether we've been within 1,000 meters of this waypoint
#define NP_NOSELECT ( NP_HIDDEN | NP_NOACCESS )
#define NP_VALIDTYPE ( NP_WAYPOINT | NP_SHIP )
struct NavPoint
{
char NavName[32];
int flags;
void *target_obj;
int waypoint_num; //only used when flags & NP_WAYPOINT
vec3d GetPosition();
char* GetInteralName();
};
extern bool AutoPilotEngaged;
extern int CurrentNav;
extern NavPoint Navs[MAX_NAVPOINTS];
// Cycles through the NavPoint List
bool Sel_NextNav();
// Tell us is autopilot is allow
// This needs:
// * Nav point selected
// * No enemies within 5,000 meters
// * Destination > 1,000 meters away
bool CanAutopilot();
// Engages autopilot
// This does:
// * Control switched from player to AI
// * Time compression to 32x
// * Tell AI to fly to targetted Nav Point (for all nav-status wings/ships)
// * Sets max waypoint speed to the best-speed of the slowest ship tagged
void StartAutopilot();
// Checks if autopilot should automatically die
// Returns true if:
// * Targetted waypoint < 1,000 meters away
// * Enemy < 5,000 meters
bool Autopilot_AutoDiable();
// Disengages autopilot
// this does:
// * Time compression to 1x
// * Delete AI nav goal
// * Control switched from AI to player
void EndAutoPilot();
// Checks for changes every NPS_TICKRATE milliseconds
// Checks:
// * if we've gotten close enough to a nav point for it to be counted as "Visited"
// * If we're current AutoNavigating it checks if we need to autodisengage
void NavSystem_Do();
// Inits the Nav System
void NavSystem_Init();
// Finds a Nav point by name
int FindNav(char *Nav);
// Set A Nav point to "ZERO"
void ZeroNav(int i);
// Removes a Nav
bool DelNavPoint(char *Nav);
bool DelNavPoint(int nav);
// adds a Nav
bool AddNav_Ship(char *Nav, char *TargetName, int flags);
bool AddNav_Waypoint(char *Nav, char *WP_Path, int node, int flags);
//Change Flags
bool Nav_Alt_Flags(char *Nav, int flags);
// Sexp Accessors
bool Nav_Set_Flag(char *Nav, int flag);
bool Nav_UnSet_Flag(char *Nav, int flag);
bool Nav_Set_Hidden(char *Nav);
bool Nav_Set_NoAccess(char *Nav);
bool Nav_Set_Visited(char *Nav);
bool Nav_UnSet_Hidden(char *Nav);
bool Nav_UnSet_NoAccess(char *Nav);
bool Nav_UnSet_Visited(char *Nav);
// Useful functions
unsigned int DistanceTo(char *nav);
unsigned int DistanceTo(int nav);
bool IsVisited(char *nav);
bool IsVisited(int nav);
#endif
-140
View File
@@ -1,140 +0,0 @@
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
/*
* $Logfile: /Freespace2/code/bmpman/bm_internal.h $
* $Revision: 2.3 $
* $Date: 2005-04-21 15:49:20 $
* $Author: taylor $
*
* bmpman info that's internal to bmpman related files only
*
* $Log: not supported by cvs2svn $
* Revision 2.2 2005/03/03 14:29:37 bobboau
* fixed a small error from my earlier commit.
*
* Revision 2.1 2004/11/23 00:10:06 taylor
* try and protect the bitmap_entry stuff a bit better
* fix the transparent support ship, again, but correctly this time
*
*
* $NoKeywords: $
*/
#ifndef __BM_INTERNAL_H__
#define __BM_INTERNAL_H__
// extra check to make sure this stuff doesn't end up in normal files
// don't use any of this unless BMPMAN_INTERNAL is defined
#ifdef BMPMAN_INTERNAL
#include "globalincs/pstypes.h"
#include "bmpman/bmpman.h"
// keep this defined to use per-ship nondarkening pixels
#define BMPMAN_SPECIAL_NONDARK
#define BM_TYPE_NONE 0
#define BM_TYPE_PCX 1
#define BM_TYPE_USER 2
#define BM_TYPE_ANI 3 // in-house ANI format
#define BM_TYPE_EFF 4 // specifies any type of animated image, the EFF itself is just text
#define BM_TYPE_32_BIT_FORMATS 5 // everything after this could/should be 24/32-bit
#define BM_TYPE_TGA 6 // 16 or 32 bit targa
#define BM_TYPE_DDS 7 // generic identifier for DDS
#define BM_TYPE_DXT1 8 // 24 bit with switchable alpha (compressed)
#define BM_TYPE_DXT3 9 // 32 bit with 4 bit alpha (compressed)
#define BM_TYPE_DXT5 10 // 32 bit with 8 bit alpha (compressed)
#define BM_TYPE_JPG 11 // 32 bit jpeg
#define BM_TYPE_RENDER_TARGET 12 // 32 bit setup internaly as a render target
/// Moved from cpp file ///////////////////
// Consider these 'protected' structures and functions that should only be used by special bitmap functions
typedef struct bm_extra_info {
struct {
// Stuff needed for animations
int first_frame; // used for animations -- points to index of first frame
ubyte num_frames; // used for animation -- number of frames in the animation
ubyte fps; // used for animation -- frames per second
} ani;
struct {
// Stuff needed for user bitmaps
void *data; // For user bitmaps, this is where the data comes from
ubyte bpp; // For user bitmaps, this is what format the data is
ubyte flags; // Flags passed to bm_create
} user;
struct {
// Stuff for static animations
ubyte type; // type for individual images
char filename[MAX_FILENAME_LEN]; // filename for individual images
} eff;
} bm_extra_info;
typedef struct bitmap_entry {
// identification
char filename[MAX_FILENAME_LEN]; // filename for this bitmap
uint signature; // a unique signature identifying the data
uint palette_checksum; // checksum used to be sure bitmap is in current palette
int handle; // Handle = id*MAX_BITMAPS + bitmapnum
int last_used; // When this bitmap was last used
ubyte type; // PCX, USER, ANI, etc
signed char ref_count; // Number of locks on bitmap. Can't unload unless ref_count is 0.
int dir_type; // which directory this was loaded from (to skip other locations with same name)
// compressed bitmap stuff (.dds) - RT please take a look at this and tell me if we really need it
int mem_taken; // How much memory does this bitmap use? - UnknownPlayer
int num_mipmaps; // number of mipmap levels, we need to read all of them
// Stuff to keep track of usage
ubyte preloaded; // If set, then this was loaded from the lst file
int preload_count; // how many times this gets used in game, for unlocking
ubyte used_flags; // What flags it was accessed thru
int load_count;
// Bitmap info
bitmap bm;
// Data for animations and user bitmaps
bm_extra_info info;
#ifdef BMPMAN_NDEBUG
// bookeeping
ubyte used_last_frame; // If set, then it was used last frame
ubyte used_this_frame; // If set, then it was used this frame
int data_size; // How much data this bitmap uses
int used_count; // How many times it was accessed
#endif
} bitmap_entry;
extern bitmap_entry bm_bitmaps[MAX_BITMAPS];
// image specific lock functions
void bm_lock_ani( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte bpp, ubyte flags );
void bm_lock_dds( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte bpp, ubyte flags );
void bm_lock_jpg( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte bpp, ubyte flags );
void bm_lock_pcx( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte bpp, ubyte flags );
void bm_lock_tga( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte bpp, ubyte flags );
void bm_lock_user( int handle, int bitmapnum, bitmap_entry *be, bitmap *bmp, ubyte bpp, ubyte flags );
#endif // BMPMAN_INTERNAL
#endif // __BM_INTERNAL_H__
File diff suppressed because it is too large. Load diff
+93 -124
View File
@@ -10,76 +10,13 @@
/*
* $Logfile: /Freespace2/code/Bmpman/BmpMan.h $
*
* $Revision: 2.25 $
* $Date: 2005-08-20 20:34:49 $
* $Revision: 2.13 $
* $Date: 2004-05-06 22:35:26 $
* $Author: taylor $
*
* Prototypes for Bitmap Manager functions
*
* $Log: not supported by cvs2svn $
* Revision 2.24 2005/07/13 02:50:49 Goober5000
* remove PreProcDefine #includes in FS2
* --Goober5000
*
* Revision 2.23 2005/06/19 02:28:55 taylor
* add a _fast version of bm_unload() to be used in modelinterp and future graphics API code
* clean up some modelinterp code to not use memcpy() everywhere so it's more platform compatible and matches old code (Jens Granseuer)
* NaN check to catch shards-of-death and prevent hitting an Assert() (Jens Granseuer)
* fix jumpnode code to catch model errors and close a memory leak
* make the call to bm_unload_all() after model_free_all() since we will get bmpman screwups otherwise
* don't show hardware sound RAM when using OpenAL build, it will always be 0
* print top-right memory figures in debug builds slighly further over when 1024+ res
*
* Revision 2.22 2005/04/24 12:56:42 taylor
* really are too many changes here:
* - remove all bitmap section support and fix problems with previous attempt
* ( code/bmpman/bmpman.cpp, code/bmpman/bmpman.h, code/globalincs/pstypes.h,
* code/graphics/2d.cpp, code/graphics/2d.h code/graphics/grd3dbmpman.cpp,
* code/graphics/grd3dinternal.h, code/graphics/grd3drender.cpp, code/graphics/grd3dtexture.cpp,
* code/graphics/grinternal.h, code/graphics/gropengl.cpp, code/graphics/gropengl.h,
* code/graphics/gropengllight.cpp, code/graphics/gropengltexture.cpp, code/graphics/gropengltexture.h,
* code/graphics/tmapper.h, code/network/multi_pinfo.cpp, code/radar/radarorb.cpp
* code/render/3ddraw.cpp )
* - use CLAMP() define in gropengl.h for gropengllight instead of single clamp() function
* - remove some old/outdated code from gropengl.cpp and gropengltexture.cpp
*
* Revision 2.21 2005/04/21 15:49:20 taylor
* update of bmpman and model bitmap management, well tested but things may get a bit bumpy
* - use VM_* macros for bmpman since it didn't seem to register the memory correctly (temporary)
* - a little "stupid" fix for dds bitmap reading
* - fix it so that memory is released properly on bitmap read errors
* - some cleanup to model texture loading
* - allow model textures to get released rather than just unloaded, saves bitmap slots
* - bump MAX_BITMAPS to 4750, should be able to decrease after public testing of new code
*
* Revision 2.20 2005/03/07 13:10:19 bobboau
* commit of render target code, d3d should be totaly functional,
* OGL still needs implementation.
*
* Revision 2.19 2005/02/10 14:38:50 taylor
* fix an issue with bm_set_components()
* abs is for ints fabsf is for floats (camera.cpp)
* make the in-cockpit stuff OGL friendly
*
* Revision 2.18 2004/11/23 00:10:06 taylor
* try and protect the bitmap_entry stuff a bit better
* fix the transparent support ship, again, but correctly this time
*
* Revision 2.17 2004/11/21 15:59:45 Kazan
* conflict res
*
* Revision 2.16 2004/10/31 21:26:27 taylor
* bmpman merge, EFF animation support, better page in stuff, dozen or so smaller fixes and cleanup
*
* Revision 2.15 2004/10/06 22:02:54 Kazan
* interface corruption fix - thanks taylor (MAX_BITMAPS upped to 7000)
*
* Revision 2.14 2004/08/11 05:06:18 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.13 2004/05/06 22:35:26 taylor
* DDS mipmap reading, remove unneeded bm_unlock() during page in
*
* Revision 2.12 2004/04/01 15:31:20 taylor
* don't use interface anis as ship textures
*
@@ -353,46 +290,85 @@
#define BMPMAN_NDEBUG
#endif
// this is causing problems - let's UP IT -- Kazan
// bumped from 3500 to 4500 2004/09/21 - taylor
// bumped to 4750 2005/02/03 - taylor
//#define MAX_BITMAPS 3500 // How many bitmaps the game can handle
#define MAX_BITMAPS 4750 // How many bitmaps the game can handle
// NOTE: MAX_BITMAPS shouldn't need to be bumped again. With the fixed bm_release() and it's
// proper use even the largest missions should stay under this number. With the largest retail
// missions and wasteful content we should still have about 20% of the slots free. If it still
// goes over then it's something the artists need to fix. For instance the Terran Mara fighter,
// with -spec and -glow and using the Shinepack, needs 117 bitmap slots alone. 111 of those is
// just for the glowmaps. This number can be greatly reduced if the number of ani frames for
// another LOD than LOD0 has fewer or no ani frames. A 37 frame glow ani for LOD2 is little
// more than a waste of resources. Future reports of texture corruption should be initially
// approached with content as the cause and not code. If anything we could/should reduce
// MAX_BITMAPS in the future. Where it's at now should accomidate even the largest mods.
// -- Taylor
#define MAX_BITMAPS 3500 // How many bitmaps the game can handle
// 16 bit pixel formats
#define BM_PIXEL_FORMAT_ARGB 0 // for glide - can assume certain things, like 1555 LFB writes, whee!
#define BM_PIXEL_FORMAT_D3D 1 // d3d - card dependant. booo!
#define BM_PIXEL_FORMAT_ARGB_D3D 2 // this card has nice 1555 textures like Glide - ahhhhh!
enum
{
BM_TYPE_NONE,
BM_TYPE_PCX, // 16 bit PCX
BM_TYPE_USER, // Data created at run time
BM_TYPE_ANI, // In-house ANI format
// Only list 32 bit formats after this flag please
BM_TYPE_32_BIT_FORMATS,
BM_TYPE_TGA,
BM_TYPE_JPG,
BM_TYPE_DDS,
};
extern int bm_inited;
/// Moved from cpp file ///////////////////
// Consider these 'protected' structures and functions that should only be used by special bitmap functions
extern int Bm_paging;
typedef union bm_extra_info {
struct {
// Stuff needed for animations
int first_frame; // used for animations -- points to index of first frame
ubyte num_frames; // used for animation -- number of frames in the animation
ubyte fps; // used for animation -- frames per second
} ani;
struct {
// Stuff needed for user bitmaps
void *data; // For user bitmaps, this is where the data comes from
ubyte bpp; // For user bitmaps, this is what format the data is
ubyte flags; // Flags passed to bm_create
} user;
} bm_extra_info;
void bm_init();
typedef struct bitmap_entry {
// identification
char filename[MAX_FILENAME_LEN]; // filename for this bitmap
void bm_close();
uint signature; // a unique signature identifying the data
uint palette_checksum; // checksum used to be sure bitmap is in current palette
int handle; // Handle = id*MAX_BITMAPS + bitmapnum
int last_used; // When this bitmap was last used
int bm_get_cache_slot( int bitmap_id, int separate_ani_frames );
ubyte type; // PCX, USER, ANI, etc
signed char ref_count; // Number of locks on bitmap. Can't unload unless ref_count is 0.
int bm_get_next_handle();
// compressed bitmap stuff (.dds) - RT please take a look at this and tell me if we really need it
int mem_taken; // How much memory does this bitmap use? - UnknownPlayer
int num_mipmaps; // number of mipmap levels, we need to read all of them
void *bm_malloc(int n, int size);
// Stuff to keep track of usage
ubyte preloaded; // If set, then this was loaded from the lst file
ubyte used_flags; // What flags it was accessed thru
void bm_update_memory_used(int n, int size);
// Bitmap info
bitmap bm;
// Data for animations and user bitmaps
bm_extra_info info;
#ifdef BMPMAN_NDEBUG
// bookeeping
ubyte used_last_frame; // If set, then it was used last frame
ubyte used_this_frame; // If set, then it was used this frame
int data_size; // How much data this bitmap uses
int used_count; // How many times it was accessed
#endif
} bitmap_entry;
void bm_gfx_init();
void bm_gfx_close();
int bm_gfx_get_cache_slot( int bitmap_id, int separate_ani_frames );
int bm_gfx_get_next_handle();
// 16 bit pixel formats
extern int Bm_pixel_format;
@@ -406,12 +382,12 @@ extern int bm_texture_ram;
// It returns a negative number if it couldn't load
// the bitmap. On success, it returns the bitmap
// number.
int bm_load(char * filename);
int bm_gfx_load(char * filename);
// special load function. basically allows you to load a bitmap which already exists (by filename).
// this is useful because in some cases we need to have a bitmap which is locked in screen format
// _and_ texture format, such as pilot pics and squad logos
int bm_load_duplicate(char *filename);
int bm_gfx_load_duplicate(char *filename);
// Creates a bitmap that exists in RAM somewhere, instead
// of coming from a disk file. You pass in a pointer to a
@@ -421,33 +397,29 @@ int bm_load_duplicate(char *filename);
// On success, it returns the bitmap number. You cannot
// free that RAM until bm_release is called on that bitmap.
// See example at bottom of this file
int bm_create( int bpp, int w, int h, void * data, int flags = 0);
int bm_gfx_create( int bpp, int w, int h, void * data, int flags = 0);
// Frees up a bitmap's data, but bitmap number 'n' can
// still be used, it will just have to be paged in next
// time it is locked.
int bm_unload( int n, bool = false );
// like bm_unload() except that it's safe to use to free data without worrying about
// load_count so it's safe to use in relation to bm_release() and in gr_*_texture functions
int bm_unload_fast( int n, bool = false );
int bm_gfx_unload( int n );
// Frees up a bitmap's data, and it's slot, so bitmap
// number 'n' cannot be used anymore, and bm_load or
// bm_create might reuse the slot.
void bm_release(int n);
void bm_gfx_release(int n);
// This loads a bitmap sequence so we can draw with it later.
// It returns a negative number if it couldn't load
// the bitmap. On success, it returns the bitmap
// number of the first frame and nframes is set.
extern int bm_load_animation( char * filename, int * nframes, int *fps = NULL, int can_drop_frames = 0, int dir_type = CF_TYPE_ANY );
extern int bm_gfx_load_animation( char * filename, int * nframes, int *fps = NULL, int can_drop_frames = 0, int dir_type = CF_TYPE_ANY );
// This locks down a bitmap and returns a pointer to a bitmap
// that can be accessed until you call bm_unlock. Only lock
// a bitmap when you need it! This will convert it into the
// appropriate format also.
extern bitmap * bm_lock( int bitmapnum, ubyte bpp, ubyte flags );
extern bitmap * bm_gfx_lock( int bitmapnum, ubyte bpp, ubyte flags );
// The signature is a field that gets filled in with
// a unique signature for each bitmap. The signature for each bitmap
@@ -455,10 +427,10 @@ extern bitmap * bm_lock( int bitmapnum, ubyte bpp, ubyte flags );
extern uint bm_get_signature( int bitmapnum);
// Unlocks a bitmap
extern void bm_unlock( int bitmapnum );
extern void bm_gfx_unlock( int bitmapnum );
// Gets info. w,h,or flags,nframes or fps can be NULL if you don't care.
extern void bm_get_info( int bitmapnum, int *w=NULL, int * h=NULL, ubyte * flags=NULL, int *nframes=NULL, int *fps=NULL );
extern void bm_gfx_get_info( int bitmapnum, int *w=NULL, int * h=NULL, ubyte * flags=NULL, int *nframes=NULL, int *fps=NULL, bitmap_section_info **sections = NULL );
// get filename
extern void bm_get_filename(int bitmapnum, char *filename);
@@ -468,10 +440,10 @@ extern void bm_update();
// call to load all data for all bitmaps that have been requested to be loaded
extern void bm_gfx_load_all();
extern void bm_unload_all();
extern void bm_gfx_unload_all();
// call to get the palette for a bitmap
void bm_get_palette(int n, ubyte *pal, char *name);
void bm_gfx_get_palette(int n, ubyte *pal, char *name);
// Hacked function to get a pixel from a bitmap.
// Only works good in 8bpp mode.
@@ -480,7 +452,7 @@ void bm_gfx_get_pixel( int bitmap, float u, float v, ubyte *r, ubyte *g, ubyte *
// Returns number of bytes of bitmaps locked this frame
// ntotal = number of bytes of bitmaps locked this frame
// nnew = number of bytes of bitmaps locked this frame that weren't locked last frame
void bm_get_frame_usage(int *ntotal, int *nnew);
void bm_gfx_get_frame_usage(int *ntotal, int *nnew);
/*
* Example on using bm_create
@@ -527,31 +499,28 @@ void bm_get_frame_usage(int *ntotal, int *nnew);
// Paging stuff
//============================================================================
void bm_page_in_start();
void bm_page_in_stop();
void bm_gfx_page_in_start();
void bm_gfx_page_in_stop();
// Paging code in a library should call these functions
// in its page in function.
// Marks a texture as being used for this level
// If num_frames is passed, assume this is an animation
void bm_page_in_texture( int bitmapnum, int num_frames=1 );
void bm_gfx_page_in_texture( int bitmapnum, int num_frames=1 );
// Marks a texture as being used for this level
// If num_frames is passed, assume this is an animation
void bm_page_in_nondarkening_texture( int bitmap, int num_frames=1 );
void bm_gfx_page_in_nondarkening_texture( int bitmap, int num_frames=1 );
// marks a texture as being a transparent textyre used for this level
// Marks a texture as being used for this level
// If num_frames is passed, assume this is an animation
void bm_page_in_xparent_texture( int bitmapnum, int num_frames=1 );
void bm_gfx_page_in_xparent_texture( int bitmapnum, int num_frames=1 );
// Marks an aabitmap as being used for this level
// If num_frames is passed, assume this is an animation
void bm_page_in_aabitmap( int bitmapnum, int num_frames=1 );
// unload a texture that was paged in
int bm_page_out( int handle );
void bm_gfx_page_in_aabitmap( int bitmapnum, int num_frames=1 );
//
// Mode: 0 = High memory
@@ -567,7 +536,6 @@ void BM_SELECT_ALPHA_TEX_FORMAT();
// set the rgba components of a pixel, any of the parameters can be NULL
extern void (*bm_set_components)(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
extern void (*bm_set_components_32)(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
void bm_set_components_argb(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
void bm_set_components_d3d(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
void bm_set_components_argb_d3d_16_screen(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
@@ -576,20 +544,21 @@ void bm_set_components_argb_d3d_16_tex(ubyte *pixel, ubyte *r, ubyte *g, ubyte *
void bm_set_components_argb_d3d_32_tex(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
// get the rgba components of a pixel, any of the parameters can be NULL
void bm_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
void bm_gfx_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a);
//============================================================================
// section info stuff
//============================================================================
// given a bitmap and a section, return the size (w, h)
void bm_gfx_get_section_size(int bitmapnum, int sx, int sy, int *w, int *h);
extern int GLOWMAP; //this holds a reference to a map that is a fully lit version of it's index -Bobboau
extern int SPECMAP; //this holds a reference to a map that is for specular mapping -Bobboau
extern int ENVMAP; //this holds a reference to a map that is for environment mapping -Bobboau
int bm_is_compressed(int num);
int bm_get_tcache_type(int num);
int bm_get_size(int num);
int bm_get_num_mipmaps(int num);
void bm_print_bitmaps();
int bm_make_render_target( int &x_res, int &y_res, int flags );
bool bm_is_render_target(int bitmap_id);
bool bm_set_render_target(int handle, int face = -1);
#endif
-485
View File
@@ -1,485 +0,0 @@
#include "camera/camera.h"
#include "math/vecmat.h"
#include "graphics/2d.h"
#include "globalincs/alphacolors.h"
#include "parse/parselo.h"
//Some global vars
std::vector<subtitle> Subtitles;
std::vector<camera> Cameras;
//Preset cameras
camera* Free_camera = NULL;
//This is where the camera class beings! :D
camera::camera()
{
//These are our two pointers, new'd and delete'd only by this class
desired_position = NULL;
desired_orientation = NULL;
reset();
}
camera::~camera()
{
//Cleanup
if(desired_position != NULL)
delete desired_position;
if(desired_orientation != NULL)
delete desired_orientation;
}
void camera::reset()
{
position = vmd_zero_vector;
if(desired_position != NULL)
{
delete desired_position;
desired_position = NULL;
}
translation_velocity = translation_vel_limit = translation_acc_limit = vmd_zero_vector;
vm_set_identity(&orientation);
if(desired_orientation != NULL)
{
delete desired_orientation;
desired_orientation = NULL;
}
rotation_rate = rotation_vel_limit = rotation_acc_limit = vmd_zero_vector;
}
void camera::set_position(vec3d *in_position, float in_translation_time, float in_translation_acceleration_time)
{
position = *in_position;
}
void camera::set_translation_velocity(vec3d *in_velocity)
{
if(in_velocity == NULL)
translation_velocity = *in_velocity;
else
vm_vec_zero(&translation_velocity);
}
#define square(a) (a*a)
void camera::set_rotation(matrix *in_orientation, float in_rotation_time, float in_rotation_acceleration_time)
{
if(in_rotation_time > 0.0f || in_rotation_acceleration_time > 0.0f)
{
//Safeties
if(in_rotation_acceleration_time <= 0.0f)
in_rotation_acceleration_time = 1.0f;
if(in_rotation_time <= 0.0f)
in_rotation_time = 3.0f;
if(in_rotation_acceleration_time*2.0f > in_rotation_time)
in_rotation_acceleration_time = in_rotation_time/2.0f;
//Get the angles in radians
angles curr_orientation, new_orientation;
vm_extract_angles_matrix(&curr_orientation, &orientation);
vm_extract_angles_matrix(&new_orientation, in_orientation);
//Find the distance
angles d;
d.p = new_orientation.p - curr_orientation.p;
d.b = new_orientation.b - curr_orientation.b;
d.h = new_orientation.h - curr_orientation.h;
/*d.p = curr_orientation.p - new_orientation.p;
d.b = curr_orientation.b - new_orientation.b;
d.h = curr_orientation.h - new_orientation.h;*/
/*ad_dist = -(V/At)square((At));
((Xf - Xo) - ad_dist)/V*/
/*v.p = (-(in_rotation_time - 2.0f*(in_rotation_acceleration_time)) + sqrt(square(in_rotation_time-2.0f*(in_rotation_acceleration_time))) + 4.0f*(curr_orientation.p - new_orientation.p))/2;
v.b = (-(in_rotation_time - 2.0f*(in_rotation_acceleration_time)) + sqrt(square(in_rotation_time-2.0f*(in_rotation_acceleration_time))) + 4.0f*(curr_orientation.b - new_orientation.b))/2;
v.h = (-(in_rotation_time - 2.0f*(in_rotation_acceleration_time)) + sqrt(square(in_rotation_time-2.0f*(in_rotation_acceleration_time))) + 4.0f*(curr_orientation.h - new_orientation.h))/2;*/
/*v.p = (new_orientation.p - curr_orientation.p)/(in_rotation_time - in_rotation_acceleration_time);
v.b = (new_orientation.p - curr_orientation.p)/(in_rotation_time - in_rotation_acceleration_time);
v.h = (new_orientation.p - curr_orientation.p)/(in_rotation_time - in_rotation_acceleration_time);*/
/*
angles *U = &rotation_rate;
float At = in_rotation_acceleration_time;
float t = in_rotation_time; //- 2.0f*At*/
/*v.p = ((d.p/At - U->p)/t);
v.b = ((d.b/At - U->b)/t);
v.h = ((d.h/At - U->h)/t);*/
/*v.p = ((d.p - U->p*At)/t);
v.b = ((d.b - U->b*At)/t);
v.h = ((d.h - U->h*At)/t);*/
//Set the desired orientation
if(desired_orientation == NULL)
desired_orientation = new matrix;
if(in_orientation != NULL)
*desired_orientation = *in_orientation;
else
vm_set_identity(desired_orientation);
//Calculate the maximum acceleration speed
rotation_acc_limit.xyz.z = fabsf(d.p / ((in_rotation_time * in_rotation_acceleration_time) - square(in_rotation_acceleration_time)));
rotation_acc_limit.xyz.x = fabsf(d.b / ((in_rotation_time * in_rotation_acceleration_time) - square(in_rotation_acceleration_time)));
rotation_acc_limit.xyz.y = fabsf(d.h / ((in_rotation_time * in_rotation_acceleration_time) - square(in_rotation_acceleration_time)));
//Calculate the maximum velocity
rotation_vel_limit.xyz.x = fabsf(rotation_acc_limit.xyz.x * in_rotation_acceleration_time);
rotation_vel_limit.xyz.y = fabsf(rotation_acc_limit.xyz.y * in_rotation_acceleration_time);
rotation_vel_limit.xyz.z = fabsf(rotation_acc_limit.xyz.z * in_rotation_acceleration_time);
//rotation_rate_delta_time = rotation_rate_delta_time_left = in_rotation_acceleration_time;
//rotation_rate_decel_time_til = in_rotation_time - in_rotation_acceleration_time;
//set_rotation_rate(&v, in_rotation_acceleration_time);
//rotation_rate_decel_time_til = in_rotation_time - in_rotation_acceleration_time;
}
else
{
if(in_orientation != NULL)
orientation = *in_orientation;
else
vm_set_identity(&orientation);
set_rotation_velocity(NULL);
}
}
void camera::set_rotation(angles *in_angles, float in_rotation_time, float in_rotation_acceleration_time)
{
matrix temp_matrix = IDENTITY_MATRIX;
if(in_angles != NULL)
vm_angles_2_matrix(&temp_matrix, in_angles);
set_rotation(&temp_matrix, in_rotation_time, in_rotation_acceleration_time);
}
void camera::set_rotation_facing(vec3d *in_target, float in_rotation_time, float in_rotation_acceleration_time)
{
matrix temp_matrix = IDENTITY_MATRIX;
if(in_target != NULL)
{
vec3d targetvec;
vm_vec_normalized_dir(&targetvec, in_target, &position);
vm_vector_2_matrix(&temp_matrix, &targetvec, NULL, NULL);
}
set_rotation(&temp_matrix, in_rotation_time, in_rotation_acceleration_time);
}
void camera::set_rotation_velocity(vec3d *in_rotation_rate)
{
if(in_rotation_rate != NULL)
rotation_rate = *in_rotation_rate;
else
vm_vec_zero(&rotation_rate);
/*if(in_rotation_rate == NULL)
{
rotation_rate.p = rotation_rate.b = rotation_rate.h = 0.0f;
rotation_rate_delta_time = rotation_rate_delta_time_left = in_rotation_acceleration_time = 0.0f;
rotation_rate_decel_time_til = -1.0f;
return;
}
rotation_rate_delta_time = rotation_rate_delta_time_left = in_rotation_acceleration_time;
rotation_rate_decel_time_til = -1.0f;
rotation_rate_delta.p = in_rotation_rate->p / in_rotation_acceleration_time;
rotation_rate_delta.b = in_rotation_rate->b / in_rotation_acceleration_time;
rotation_rate_delta.h = in_rotation_rate->h / in_rotation_acceleration_time;*/
}
void camera::do_frame(float in_frametime)
{
//float frametime, rot_frametime, trans_frametime;
//DO ROTATION STUFF
if(desired_orientation != NULL)
{
matrix ori_out;
vec3d vel_out;
vm_matrix_interpolate(desired_orientation, &orientation, &rotation_rate, in_frametime, &ori_out, &vel_out, &rotation_vel_limit, &rotation_acc_limit, 1);
orientation = ori_out;
rotation_rate = vel_out;
//TODO: Make this "if(*desired_orienation == orientation)"
//Note that this means we are finished rotating
if(vel_out.xyz.x == 0.0f && vel_out.xyz.y == 0.0f && vel_out.xyz.z == 0.0f)
{
delete desired_orientation;
desired_orientation = NULL;
rotation_rate = rotation_vel_limit = rotation_acc_limit = vmd_zero_vector;
}
}
else if(rotation_rate.xyz.x || rotation_rate.xyz.y || rotation_rate.xyz.z)
{
//TODO: Make this right.
angles new_orientation;
vm_angles_2_matrix(&orientation, &new_orientation);
new_orientation.p += rotation_rate.xyz.z;
new_orientation.b += rotation_rate.xyz.x;
new_orientation.h += rotation_rate.xyz.y;
vm_angles_2_matrix(&orientation, &new_orientation);
}
/* rot_frametime = trans_frametime = in_frametime;
do
{
frametime = rot_frametime;
if(rotation_rate_delta_time_left || rotation_rate_decel_time_til > 0.0f)
{
if(frametime > rotation_rate_delta_time_left && rotation_rate_delta_time_left)
frametime = rotation_rate_delta_time_left;
if(frametime > rotation_rate_decel_time_til && rotation_rate_decel_time_til > 0.0f)
frametime = rotation_rate_decel_time_til;
if(rotation_rate_delta_time_left)
{
rotation_rate.p += (rotation_rate_delta.p) * frametime;
rotation_rate.b += (rotation_rate_delta.b) * frametime;
rotation_rate.h += (rotation_rate_delta.h) * frametime;
}
//mprintf(("DX:%f DY:%f DZ:%f",rotation_rate_delta.p,rotation_rate_delta.b,rotation_rate_delta.h));
//mprintf(( " X:%f", rotation_rate.p));
//mprintf(( " Y:%f", rotation_rate.b));
//mprintf(( " Z:%f\n", rotation_rate.h));
if(rotation_rate_delta_time_left)
{
rotation_rate_delta_time_left -= frametime;
}
if(rotation_rate_decel_time_til > 0.0f)
{
rotation_rate_decel_time_til -= frametime;
if(rotation_rate_decel_time_til == 0.0f)
{
rotation_rate_delta.p *= -1.0f;
rotation_rate_delta.b *= -1.0f;
rotation_rate_delta.h *= -1.0f;
rotation_rate_delta_time_left = rotation_rate_delta_time;
rotation_rate_decel_time_til = -1.0f;
}
}
}
rot_frametime -= frametime;
} while(rot_frametime);*/
//DO TRANSLATION STUFF
// float frametime = in_frametime;
/*if(translation_time_left)
{
if(in_frametime > translation_time_left)
frametime = translation_time_left;
else
frametime = in_frametime;
vm_vec_scale_add2(&translation_velocity, &translation_velocity_delta, frametime);
translation_time_left -= frametime;
}*/
vm_vec_scale_add2(&position, &translation_velocity, in_frametime);
}
#define MAX_SUBTITLE_LINES 10
subtitle::subtitle(int in_x_pos, int in_y_pos, char* in_text, float in_display_time, char* in_imageanim, float in_fade_time, color *in_text_color, bool center_x, bool center_y, int in_width)
{
//Setup text
int len = strlen(in_text);
if(len == 0)
return;
int num_text_lines;
char *text_line_ptrs[MAX_SUBTITLE_LINES];
int text_line_lens[MAX_SUBTITLE_LINES];
num_text_lines = split_str(in_text, in_width, text_line_lens, text_line_ptrs, MAX_SUBTITLE_LINES);
std::string temp_str;
for(int i = 0; i < num_text_lines; i++)
{
temp_str.assign(text_line_ptrs[i], text_line_lens[i]);
text_lines.push_back(temp_str);
}
//Setup text color
if(in_text_color)
text_color = *in_text_color;
else
gr_init_alphacolor(&text_color, 255, 255, 255, 255);
//Setup display and fade time
display_time = fl_abs(in_display_time);
fade_time = fl_abs(in_fade_time);
//Setup image
image_id = -1;
if(in_imageanim != NULL)
{
len = strlen(in_imageanim);
if(len != 0 && len < MAX_FILENAME_LEN)
{
image_id = bm_load(in_imageanim);
if(image_id != -1)
strcpy(imageanim, in_imageanim);
}
}
//Setup pos
int w=0, h=0, tw=0, th=0;
image_pos[0] = 0;
image_pos[1] = 0;
if(center_x || center_y)
{
//Get text size
for(int i = 0; i < num_text_lines; i++)
{
gr_get_string_size(&w, &h, text_line_ptrs[i], text_line_lens[i]);
if(w > tw)
tw = w;
th += h;
}
//Get image size
if(image_id != -1)
{
bm_get_info(image_id, &w, &h);
tw += w;
if(h > th)
th = h;
}
//Center it?
if(center_x)
image_pos[0] = (gr_screen.max_w - tw)/2;
if(center_y)
image_pos[0] = (gr_screen.max_h - th)/2;
}
if(in_x_pos < 0 && !center_x)
image_pos[0] += gr_screen.max_w + in_x_pos;
else
image_pos[0] += in_x_pos;
if(in_y_pos < 0 && !center_y)
image_pos[1] += gr_screen.max_h + in_y_pos;
else
image_pos[1] += in_y_pos;
if(image_id != -1)
text_pos[0] = image_pos[0] + w; //Still set from bm_get_info call
else
text_pos[0] = image_pos[0];
text_pos[1] = image_pos[1];
time_displayed = 0.0f;
time_displayed_end = 2.0f*fade_time + display_time;
}
void subtitle::do_frame(float frametime)
{
//Figure out how much alpha
if(time_displayed < fade_time)
{
text_color.alpha = (ubyte)fl2i(255.0f*(time_displayed/fade_time));
}
else if(time_displayed > time_displayed_end)
{
//We're finished
if(image_id != -1)
{
bm_unload(image_id);
image_id = -1;
}
return;
}
else if((time_displayed - fade_time) > display_time)
{
text_color.alpha = (ubyte)fl2i(255.0f*(1-(time_displayed - fade_time - display_time)/fade_time));
}
else
{
text_color.alpha = 255;
}
gr_set_color_fast(&text_color);
int font_height = gr_get_font_height();
int y = text_pos[1];
for(unsigned int i = 0; i < text_lines.size(); i++)
{
gr_string(text_pos[0], y, (char*)text_lines[i].c_str(), false);
y += font_height;
}
if(image_id != -1)
{
gr_set_bitmap(image_id, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, text_color.alpha/255.0f);
gr_bitmap(image_pos[0], image_pos[1], false);
}
time_displayed += frametime;
}
subtitle::~subtitle()
{
if(image_id != -1)
bm_unload(image_id);
}
void cameras_init()
{
camera handy_camera;
//Preset cameras
Cameras.push_back(handy_camera);
Free_camera = &Cameras[Cameras.size()-1];
}
void cameras_close()
{
Cameras.clear();
//Preset cameras
Free_camera = NULL;
}
void cameras_do_frame(float frametime)
{
unsigned int i,size=Cameras.size();
for(i = 0; i < size; i++)
{
Cameras[i].do_frame(frametime);
}
}
void subtitles_init()
{
//Do nothing!!
}
void subtitles_close()
{
Subtitles.clear();
}
void subtitles_do_frame(float frametime)
{
unsigned int i,size=Subtitles.size();
for(i = 0; i < size; i++)
{
Subtitles[i].do_frame(frametime);
}
}
-88
View File
@@ -1,88 +0,0 @@
#ifndef _CAMERA_H
#define _CAMERA_H
#include <string>
#include <vector>
#include "globalincs/pstypes.h"
#include "graphics/2d.h"
class camera
{
private:
vec3d position;
vec3d *desired_position; //NULL unless we're trying to move somewhere
vec3d translation_velocity;
vec3d translation_vel_limit;
vec3d translation_acc_limit;
matrix orientation;
matrix *desired_orientation; //NULL unless we're trying to point somewhere
vec3d rotation_rate;
vec3d rotation_vel_limit;
vec3d rotation_acc_limit;
public:
camera();
~camera();
void reset();
//Set
void set_position(vec3d *in_position, float in_translation_time = 0.0f, float in_translation_acceleration_time = 0.0f);
void set_translation_velocity(vec3d *in_velocity);
void set_rotation(matrix *in_orientation, float in_rotation_time = 0.0f, float in_rotation_acceleration_time = 0.0f);
void set_rotation(angles *in_angles, float in_rotation_time = 0.0f, float in_rotation_acceleration_time = 0.0f);
void set_rotation_facing(vec3d *in_target, float in_rotation_time = 0.0f, float in_rotation_acceleration_time = 0.0f);
void set_rotation_velocity(vec3d *in_rotation_rate);
//Get
//These return values should never ever be changed, I do this in the interest of speed.
vec3d *get_position() {return &position;}
matrix *get_orientation() {return &orientation;}
//Do
void do_frame(float in_frametime);
};
class subtitle
{
private:
std::vector<std::string> text_lines;
int text_pos[2];
float display_time;
float fade_time;
color text_color;
//Done with set
char imageanim[MAX_FILENAME_LEN];
int image_id;
int image_pos[2];
//Time this has been displayed
float time_displayed;
//When to end it
float time_displayed_end;
public:
subtitle(int in_x_pos, int in_y_pos, char* in_text, float in_display_time, char* in_imageanim = NULL, float in_fade_time = 0.0f, color *in_text_color = NULL, bool center_x = false, bool center_y = false, int in_width = 200);
~subtitle();
void do_frame(float frametime);
};
//Some global stuff
extern std::vector<subtitle> Subtitles;
extern std::vector<camera> Cameras;
//Preset cameras
extern camera* Free_camera;
//Helpful functions
void cameras_init();
void cameras_close();
void cameras_do_frame(float frametime);
void subtitles_init();
void subtitles_close();
void subtitles_do_frame(float frametime);
#endif // _CAMERA_H
+50 -106
View File
@@ -9,60 +9,13 @@
/*
* $Logfile: /Freespace2/code/CFile/cfile.cpp $
* $Revision: 2.30 $
* $Date: 2005-04-19 06:22:20 $
* $Revision: 2.15 $
* $Date: 2004-05-06 22:12:14 $
* $Author: taylor $
*
* Utilities for operating on files
*
* $Log: not supported by cvs2svn $
* Revision 2.29 2005/04/05 05:53:14 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.28 2005/03/02 03:13:00 taylor
* that one should never have slipped passed me (Linux specific)
*
* Revision 2.27 2005/01/30 18:32:41 taylor
* merge with Linux/OSX tree - p0130
* remove extra brace in cfile.cpp
*
* Revision 2.26 2005/01/30 12:50:08 taylor
* merge with Linux/OSX tree - p0130
*
* Revision 2.25 2005/01/09 21:40:07 wmcoolmon
* Fix for music directory parent
*
* Revision 2.24 2004/12/25 00:22:54 wmcoolmon
* Added .ogg in proper directories
*
* Revision 2.23 2004/10/31 21:29:00 taylor
* EFF animation support
*
* Revision 2.22 2004/10/09 18:08:33 taylor
* almost forgot this for the IBX stuff
*
* Revision 2.21 2004/07/26 20:47:25 Kazan
* remove MCD complete
*
* Revision 2.20 2004/07/17 09:03:29 taylor
* make sure avi and mpg movies get added to file cache
*
* Revision 2.19 2004/07/12 16:32:42 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.18 2004/06/22 23:14:09 wmcoolmon
* Nonworking OGG support for sound (not music) added, disabled load-only-used-weapons code, modification to sound system registry code.
* OGG code has been commented out, so you don't need the SDK yet.
*
* Revision 2.17 2004/05/26 02:29:44 wmcoolmon
* Scratch that - .tbm is a better extension
*
* Revision 2.16 2004/05/26 02:26:14 wmcoolmon
* Added table chunk extension
*
* Revision 2.15 2004/05/06 22:12:14 taylor
* make sure JPG and DDS files are added to the file cache for maps and effects
*
* Revision 2.14 2004/03/05 09:01:54 Goober5000
* Uber pass at reducing #includes
* --Goober5000
@@ -296,7 +249,7 @@
#include <winbase.h> /* needed for memory mapping of file functions */
#endif
#ifdef SCP_UNIX
#ifdef unix
#include <sys/stat.h>
#include <glob.h>
#include <sys/mman.h>
@@ -306,14 +259,8 @@
#include "parse/encrypt.h"
#include "cfile/cfilesystem.h"
#include "cfile/cfilearchive.h"
#include "osapi/osapi.h"
char Cfile_root_dir[CFILE_ROOT_DIRECTORY_LEN] = "";
#ifdef SCP_UNIX
char Cfile_user_dir[CFILE_ROOT_DIRECTORY_LEN] = "";
#endif
// During cfile_init, verify that Pathtypes[n].index == n for each item
// Each path must have a valid parent that can be tracable all the way back to the root
@@ -325,34 +272,34 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
// What type this is Path Extensions Parent type
{ CF_TYPE_INVALID, NULL, NULL, CF_TYPE_INVALID },
// Root must be index 1!!
{ CF_TYPE_ROOT, "", ".mve .avi .mpg", CF_TYPE_ROOT },
{ CF_TYPE_ROOT, "", ".mve", CF_TYPE_ROOT },
{ CF_TYPE_DATA, "data", ".cfg .log .txt", CF_TYPE_ROOT },
{ CF_TYPE_MAPS, "data" DIR_SEPARATOR_STR "maps", ".pcx .ani .eff .tga .jpg .dds", CF_TYPE_DATA },
{ CF_TYPE_MAPS, "data" DIR_SEPARATOR_STR "maps", ".pcx .ani .tga .jpg .dds", CF_TYPE_DATA },
{ CF_TYPE_TEXT, "data" DIR_SEPARATOR_STR "text", ".txt .net", CF_TYPE_DATA },
{ CF_TYPE_MISSIONS, "data" DIR_SEPARATOR_STR "missions", ".fs2 .fc2 .ntl .ssv", CF_TYPE_DATA },
{ CF_TYPE_MODELS, "data" DIR_SEPARATOR_STR "models", ".pof", CF_TYPE_DATA },
{ CF_TYPE_TABLES, "data" DIR_SEPARATOR_STR "tables", ".tbl .tbm", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS, "data" DIR_SEPARATOR_STR "sounds", ".wav .ogg", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS_8B22K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "8b22k", ".wav .ogg", CF_TYPE_SOUNDS },
{ CF_TYPE_SOUNDS_16B11K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "16b11k", ".wav .ogg", CF_TYPE_SOUNDS },
{ CF_TYPE_TABLES, "data" DIR_SEPARATOR_STR "tables", ".tbl", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS, "data" DIR_SEPARATOR_STR "sounds", ".wav", CF_TYPE_DATA },
{ CF_TYPE_SOUNDS_8B22K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "8b22k", ".wav", CF_TYPE_SOUNDS },
{ CF_TYPE_SOUNDS_16B11K, "data" DIR_SEPARATOR_STR "sounds" DIR_SEPARATOR_STR "16b11k", ".wav", CF_TYPE_SOUNDS },
{ CF_TYPE_VOICE, "data" DIR_SEPARATOR_STR "voice", "", CF_TYPE_DATA },
{ CF_TYPE_VOICE_BRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "briefing", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_CMD_BRIEF, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "command_briefings", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_DEBRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "debriefing", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_PERSONAS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "personas", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_SPECIAL, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "special", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_TRAINING, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "training", ".wav .ogg", CF_TYPE_VOICE },
{ CF_TYPE_MUSIC, "data" DIR_SEPARATOR_STR "music", ".wav .ogg", CF_TYPE_DATA },
{ CF_TYPE_MOVIES, "data" DIR_SEPARATOR_STR "movies", ".mve .msb .avi .mpg", CF_TYPE_DATA },
{ CF_TYPE_VOICE_BRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "briefing", ".wav", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_CMD_BRIEF, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "command_briefings", ".wav", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_DEBRIEFINGS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "debriefing", ".wav", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_PERSONAS, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "personas", ".wav", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_SPECIAL, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "special", ".wav", CF_TYPE_VOICE },
{ CF_TYPE_VOICE_TRAINING, "data" DIR_SEPARATOR_STR "voice" DIR_SEPARATOR_STR "training", ".wav", CF_TYPE_VOICE },
{ CF_TYPE_MUSIC, "data" DIR_SEPARATOR_STR "music", ".wav", CF_TYPE_VOICE },
{ CF_TYPE_MOVIES, "data" DIR_SEPARATOR_STR "movies", ".mve .msb", CF_TYPE_DATA },
{ CF_TYPE_INTERFACE, "data" DIR_SEPARATOR_STR "interface", ".pcx .ani .tga", CF_TYPE_DATA },
{ CF_TYPE_FONT, "data" DIR_SEPARATOR_STR "fonts", ".vf", CF_TYPE_DATA },
{ CF_TYPE_EFFECTS, "data" DIR_SEPARATOR_STR "effects", ".ani .eff .pcx .neb .tga .jpg .dds", CF_TYPE_DATA },
{ CF_TYPE_EFFECTS, "data" DIR_SEPARATOR_STR "effects", ".ani .pcx .neb .tga .jpg .dds", CF_TYPE_DATA },
{ CF_TYPE_HUD, "data" DIR_SEPARATOR_STR "hud", ".ani .pcx .tga", CF_TYPE_DATA },
{ CF_TYPE_PLAYER_MAIN, "data" DIR_SEPARATOR_STR "players", "", CF_TYPE_DATA },
{ CF_TYPE_PLAYER_IMAGES_MAIN, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "images", ".pcx", CF_TYPE_PLAYER_MAIN },
{ CF_TYPE_CACHE, "data" DIR_SEPARATOR_STR "cache", ".clr .tmp .ibx", CF_TYPE_DATA }, //clr=cached color
{ CF_TYPE_CACHE, "data" DIR_SEPARATOR_STR "cache", ".clr .tmp", CF_TYPE_DATA }, //clr=cached color
{ CF_TYPE_PLAYERS, "data" DIR_SEPARATOR_STR "players", ".hcf", CF_TYPE_DATA },
{ CF_TYPE_SINGLE_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "single", ".pl2 .cs2 .plr .csg .css", CF_TYPE_PLAYERS },
{ CF_TYPE_SINGLE_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "single", ".plr .csg .css", CF_TYPE_PLAYERS },
{ CF_TYPE_MULTI_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "multi", ".plr", CF_TYPE_DATA },
{ CF_TYPE_MULTI_CACHE, "data" DIR_SEPARATOR_STR "multidata", ".pcx .fs2", CF_TYPE_DATA },
{ CF_TYPE_CONFIG, "data" DIR_SEPARATOR_STR "config", ".cfg", CF_TYPE_DATA },
@@ -384,7 +331,7 @@ CFILE *cf_open_packed_cfblock(FILE *fp, int type, int offset, int size);
#if defined _WIN32
CFILE *cf_open_mapped_fill_cfblock(HANDLE hFile, int type);
#elif defined SCP_UNIX
#elif defined unix
CFILE *cf_open_mapped_fill_cfblock(FILE *fp, int type);
#endif
@@ -452,7 +399,11 @@ int cfile_init(char *exe_dir, char *cdrom_dir)
// are we in a root directory?
if(cfile_in_root_dir(buf)){
#if defined _WIN32
MessageBox((HWND)NULL, "Freespace2/Fred2 cannot be run from a drive root directory!", "Error", MB_OK);
#elif defined unix
fprintf(stderr, "Error: Freespace2/Fred2 cannot be run from a drive root directory!\n");
#endif
return 1;
}
@@ -466,15 +417,16 @@ int cfile_init(char *exe_dir, char *cdrom_dir)
buf[i] = 0;
cfile_chdir(buf);
} else {
#if defined _WIN32
MessageBox((HWND)NULL, "Error trying to determine executable root directory!", "Error", MB_OK);
#elif defined unix
fprintf(stderr, "Error trying to determine executable root directory!\n");
#endif
return 1;
}
// set root directory
strncpy(Cfile_root_dir, buf, CFILE_ROOT_DIRECTORY_LEN-1);
#ifdef SCP_UNIX
snprintf(Cfile_user_dir, MAX_PATH, "%s/%s/", detect_home(), Osreg_user_dir);
#endif
for ( i = 0; i < MAX_CFILE_BLOCKS; i++ ) {
Cfile_block_list[i].type = CFILE_BLOCK_UNUSED;
@@ -534,7 +486,7 @@ int cfile_push_chdir(int type)
int e;
char dir[128];
char OriginalDirectory[128];
char *Drive = NULL, *Path = NULL;
char *Drive, *Path;
char NoDir[] = "\\.";
_getcwd(OriginalDirectory, 127);
@@ -578,7 +530,7 @@ int cfile_chdir(char *dir)
{
int e;
char OriginalDirectory[128];
char *Drive = NULL, *Path = NULL;
char *Drive, *Path;
char NoDir[] = "\\.";
_getcwd(OriginalDirectory, 127);
@@ -623,6 +575,7 @@ int cfile_pop_dir()
// NOTE : WILL NOT DELETE READ-ONLY FILES
int cfile_flush_dir(int dir_type)
{
int find_handle;
int del_count;
Assert( CF_TYPE_SPECIFIED(dir_type) );
@@ -635,7 +588,6 @@ int cfile_flush_dir(int dir_type)
// proceed to delete the files
del_count = 0;
#if defined _WIN32
int find_handle;
_finddata_t find;
find_handle = _findfirst( "*", &find );
if (find_handle != -1) {
@@ -650,7 +602,7 @@ int cfile_flush_dir(int dir_type)
} while (!_findnext(find_handle, &find));
_findclose( find_handle );
}
#elif defined SCP_UNIX
#elif defined unix
glob_t globinfo;
memset(&globinfo, 0, sizeof(globinfo));
int status = glob("*", 0, NULL, &globinfo);
@@ -890,11 +842,7 @@ CFILE *cfopen(char *file_path, char *mode, int type, int dir_type, bool localize
if ( strchr(mode,'w') ) {
// For write-only files, require a full path or a path type
#ifdef SCP_UNIX
if ( strpbrk(file_path, "/") ) {
#else
if ( strpbrk(file_path,"/\\:") ) {
#endif
if ( strpbrk(file_path,"/\\:") ) {
// Full path given?
strcpy(longname, file_path );
} else {
@@ -942,7 +890,7 @@ CFILE *cfopen(char *file_path, char *mode, int type, int dir_type, bool localize
if (hFile != INVALID_HANDLE_VALUE) {
return cf_open_mapped_fill_cfblock(hFile, dir_type);
}
#elif defined SCP_UNIX
#elif defined unix
FILE *fp = fopen( longname, "rb" );
if (fp) {
return cf_open_mapped_fill_cfblock(fp, dir_type);
@@ -1045,13 +993,9 @@ int cfclose( CFILE * cfile )
result = CloseHandle(cb->hMapFile);
Assert(result); // Ensure file handle is closed properly
result = 0;
#elif defined SCP_UNIX
// FIXME: result is wrong after munmap() but it is successful
//result = munmap(cb->data, cb->data_length);
//Assert(result);
munmap(cb->data, cb->data_length);
if ( cb->fp != NULL)
result = fclose(cb->fp);
#elif defined unix
result = munmap(cb->data, cb->data_length);
Assert(result);
#endif
} else if ( cb->fp != NULL ) {
@@ -1080,7 +1024,6 @@ CFILE *cf_open_fill_cfblock(FILE *fp, int type)
cfile_block_index = cfget_cfile_block();
if ( cfile_block_index == -1 ) {
fclose(fp);
return NULL;
} else {
CFILE *cfp;
@@ -1093,7 +1036,13 @@ CFILE *cf_open_fill_cfblock(FILE *fp, int type)
cfbp->fp = fp;
cfbp->dir_type = type;
#if defined _WIN32
cf_init_lowlevel_read_code(cfp,0,filelength(fileno(fp)) );
#elif defined unix
struct stat statbuf;
fstat(fileno(fp), &statbuf);
cf_init_lowlevel_read_code(cfp, 0, statbuf.st_size );
#endif
return cfp;
}
@@ -1113,7 +1062,6 @@ CFILE *cf_open_packed_cfblock(FILE *fp, int type, int offset, int size)
cfile_block_index = cfget_cfile_block();
if ( cfile_block_index == -1 ) {
fclose(fp);
return NULL;
} else {
CFILE *cfp;
@@ -1143,7 +1091,7 @@ CFILE *cf_open_packed_cfblock(FILE *fp, int type, int offset, int size)
//
#if defined _WIN32
CFILE *cf_open_mapped_fill_cfblock(HANDLE hFile, int type)
#elif defined SCP_UNIX
#elif defined unix
CFILE *cf_open_mapped_fill_cfblock(FILE *fp, int type)
#endif
{
@@ -1151,9 +1099,6 @@ CFILE *cf_open_mapped_fill_cfblock(FILE *fp, int type)
cfile_block_index = cfget_cfile_block();
if ( cfile_block_index == -1 ) {
#ifdef SCP_UNIX
fclose(fp);
#endif
return NULL;
}
else {
@@ -1179,9 +1124,8 @@ CFILE *cf_open_mapped_fill_cfblock(FILE *fp, int type)
cfbp->data = (ubyte*)MapViewOfFile(cfbp->hMapFile, FILE_MAP_READ, 0, 0, 0);
Assert( cfbp->data != NULL );
#elif defined SCP_UNIX
#elif defined unix
cfbp->fp = fp;
cfbp->data_length = filelength( fileno(fp) );
cfbp->data = mmap(NULL, // start
cfbp->data_length, // length
PROT_READ, // prot
@@ -1239,7 +1183,7 @@ float cfread_float(CFILE *file, int ver, float deflt)
if (cfread( &f, sizeof(f), 1, file) != 1)
return deflt;
f = INTEL_FLOAT(&f);
// i = INTEL_INT(i); // hmm, not sure what to do here
return f;
}
@@ -1312,7 +1256,7 @@ ubyte cfread_ubyte(CFILE *file, int ver, ubyte deflt)
return b;
}
void cfread_vector(vec3d *vec, CFILE *file, int ver, vec3d *deflt)
void cfread_vector(vector *vec, CFILE *file, int ver, vector *deflt)
{
if (file->version < ver) {
if (deflt)
@@ -1385,7 +1329,7 @@ void cfread_string_len(char *buf,int n, CFILE *file)
int cfwrite_float(float f, CFILE *file)
{
f = INTEL_FLOAT(&f);
// i = INTEL_INT(i); // hmm, not sure what to do here
return cfwrite(&f, sizeof(f), 1, file);
}
@@ -1418,7 +1362,7 @@ int cfwrite_ubyte(ubyte b, CFILE *file)
return cfwrite(&b, sizeof(b), 1, file);
}
int cfwrite_vector(vec3d *vec, CFILE *file)
int cfwrite_vector(vector *vec, CFILE *file)
{
if(!cfwrite_float(vec->xyz.x, file)){
return 0;
+6 -26
View File
@@ -9,28 +9,13 @@
/*
* $Logfile: /Freespace2/code/CFile/cfile.h $
* $Revision: 2.12 $
* $Date: 2005-07-13 02:50:49 $
* $Author: Goober5000 $
* $Revision: 2.7 $
* $Date: 2003-08-20 08:12:08 $
* $Author: wmcoolmon $
*
* <insert description of file here>
*
* $Log: not supported by cvs2svn $
* Revision 2.11 2005/04/05 05:53:14 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.10 2005/01/30 12:50:08 taylor
* merge with Linux/OSX tree - p0130
*
* Revision 2.9 2004/08/11 05:06:19 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.8 2004/05/26 21:02:26 wmcoolmon
* Added weapons_expl modular table, updated cfilesystem to work with modular tables, fixed loading order, fixed ship loading error messages
*
* Revision 2.7 2003/08/20 08:12:08 wmcoolmon
* Made cfile_delete return 0 on failure, 1 on success
*
* Revision 2.6 2002/11/10 16:29:53 DTP
* -DTP reworked mod support,
*
@@ -374,14 +359,13 @@
#ifndef __CFILE_H__
#define __CFILE_H__
#include <time.h>
#include "globalincs/pstypes.h"
#if defined _WIN32
#define DIR_SEPARATOR_CHAR '\\'
#define DIR_SEPARATOR_STR "\\"
#elif defined SCP_UNIX
#elif defined unix
#define DIR_SEPARATOR_CHAR '/'
#define DIR_SEPARATOR_STR "/"
#else
@@ -460,7 +444,6 @@ typedef struct {
#define CF_SORT_NONE 0
#define CF_SORT_NAME 1
#define CF_SORT_TIME 2
#define CF_SORT_REVERSE 3
#define cfread_fix(file) (fix)cfread_int(file)
#define cfwrite_fix(i,file) cfwrite_int(i,file)
@@ -472,9 +455,6 @@ extern int (*Get_file_list_filter)(char *filename);
// cfile directory. valid after cfile_init() returns successfully
#define CFILE_ROOT_DIRECTORY_LEN 256
extern char Cfile_root_dir[CFILE_ROOT_DIRECTORY_LEN];
#ifdef SCP_UNIX
extern char Cfile_user_dir[CFILE_ROOT_DIRECTORY_LEN];
#endif
//================= LOW-LEVEL FUNCTIONS ==================
// Call this once at the beginning of the program
@@ -606,7 +586,7 @@ ushort cfread_ushort(CFILE *file, int ver = 0, ushort deflt = 0);
int cfread_int(CFILE *file, int ver = 0, int deflt = 0);
uint cfread_uint(CFILE *file, int ver = 0, uint deflt = 0);
float cfread_float(CFILE *file, int ver = 0, float deflt = 0.0f);
void cfread_vector(vec3d *vec, CFILE *file, int ver = 0, vec3d *deflt = NULL);
void cfread_vector(vector *vec, CFILE *file, int ver = 0, vector *deflt = NULL);
void cfread_angles(angles *ang, CFILE *file, int ver = 0, angles *deflt = NULL);
// Reads variable length, null-termined string. Will only read up
@@ -624,7 +604,7 @@ int cfwrite_uint(uint i, CFILE *file);
int cfwrite_short(short s, CFILE *file);
int cfwrite_ushort(ushort s, CFILE *file);
int cfwrite_ubyte(ubyte u, CFILE *file);
int cfwrite_vector(vec3d *vec, CFILE *file);
int cfwrite_vector(vector *vec, CFILE *file);
int cfwrite_angles(angles *ang, CFILE *file);
// writes variable length, null-termined string.
+4 -16
View File
@@ -9,24 +9,14 @@
/*
* $Logfile: /Freespace2/code/CFile/CfileArchive.cpp $
* $Revision: 2.7 $
* $Date: 2005-07-24 18:31:17 $
* $Author: taylor $
* $Revision: 2.4 $
* $Date: 2004-03-05 09:01:54 $
* $Author: Goober5000 $
*
* Low-level code for reading data out of large archive files or normal files. All
* reads/seeks come through here.
*
* $Log: not supported by cvs2svn $
* Revision 2.6 2004/07/26 20:47:25 Kazan
* remove MCD complete
*
* Revision 2.5 2004/07/12 16:32:42 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.4 2004/03/05 09:01:54 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.3 2003/03/19 09:05:25 Goober5000
* more housecleaning, this time for debug warnings
* --Goober5000
@@ -113,8 +103,6 @@
#include "cfile/cfile.h"
#include "cfile/cfilearchive.h"
#define CHECK_POSITION
// Called once to setup the low-level reading code.
@@ -253,7 +241,7 @@ int cfseek( CFILE *cfile, int offset, int where )
#if defined(CHECK_POSITION) && !defined(NDEBUG)
int tmp_offset;
tmp_offset = (int)ftell(cb->fp) - cb->lib_offset;
tmp_offset = ftell(cb->fp) - cb->lib_offset;
Assert(tmp_offset==cb->raw_position);
#endif
+3 -9
View File
@@ -9,20 +9,14 @@
/*
* $Logfile: /Freespace2/code/CFile/CfileArchive.h $
* $Revision: 2.3 $
* $Date: 2005-07-13 02:50:49 $
* $Author: Goober5000 $
* $Revision: 2.1 $
* $Date: 2002-07-07 19:55:58 $
* $Author: penguin $
*
* External def's for CfileArchive.cpp. This should only be used
* internally by cfile stuff.
*
* $Log: not supported by cvs2svn $
* Revision 2.2 2004/08/11 05:06:19 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.1 2002/07/07 19:55:58 penguin
* Back-port to MSVC
*
* Revision 2.0 2002/06/03 04:02:21 penguin
* Warpcore CVS sync
*
+3 -38
View File
@@ -9,25 +9,13 @@
/*
* $Logfile: /Freespace2/code/CFile/CfileList.cpp $
* $Revision: 2.6 $
* $Date: 2005-01-31 23:27:51 $
* $Author: taylor $
* $Revision: 2.2 $
* $Date: 2002-08-01 01:41:04 $
* $Author: penguin $
*
* Code for doing directory lists and sorts
*
* $Log: not supported by cvs2svn $
* Revision 2.5 2004/07/26 20:47:25 Kazan
* remove MCD complete
*
* Revision 2.4 2004/07/17 09:26:00 taylor
* add CF_SORT_REVERSE to real sort routine, makes CF_SORT_TIME work again
*
* Revision 2.3 2004/07/12 16:32:42 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.2 2002/08/01 01:41:04 penguin
* The big include file move
*
* Revision 2.1 2002/07/29 19:37:21 penguin
* added #ifdef _WIN32 around windows-specific system headers
*
@@ -86,9 +74,6 @@
#include "globalincs/pstypes.h"
#include "cfile/cfile.h"
// Sorts a list of filenames using the specified sorting method (CF_SORT_*).
// n = number of filenames in list to sort
// list = list of filenames to be sorted
@@ -156,22 +141,6 @@ void cf_sort_filenames( int n, char **list, int sort, file_list_info *info )
incr /= 2;
}
return;
} else if (sort == CF_SORT_REVERSE) {
incr = n / 2;
char buffer[MAX_FILENAME_LEN];
for (i = 0; i < incr; i++) {
t = list[n - 1 - i];
if ( stricmp(list[i], t) > 0 ) {
strcpy(buffer, list[i]);
strcpy(list[i], t);
strcpy(t, buffer);
}
}
return;
}
@@ -179,8 +148,6 @@ void cf_sort_filenames( int n, char **list, int sort, file_list_info *info )
}
#if (0) // these aren't used anywhere now
// cf_compress - Do Run Length Compression on a block of data. Targa format.
//
// Usage:
@@ -350,8 +317,6 @@ int cf_decompress(char *out, char *in )
}
#endif // 0
// cfread() reads from a file and decompresses it
//
+143 -325
View File
@@ -9,9 +9,9 @@
/*
* $Logfile: /Freespace2/code/CFile/CfileSystem.cpp $
* $Revision: 2.26 $
* $Date: 2005-05-12 17:49:10 $
* $Author: taylor $
* $Revision: 2.17 $
* $Date: 2004-05-03 21:22:19 $
* $Author: Kazan $
*
* Functions to keep track of and find files that can exist
* on the harddrive, cd-rom, or in a pack file on either of those.
@@ -20,35 +20,6 @@
* all those locations, inherently enforcing precedence orders.
*
* $Log: not supported by cvs2svn $
* Revision 2.25 2005/01/30 12:50:08 taylor
* merge with Linux/OSX tree - p0130
*
* Revision 2.24 2004/11/21 11:27:31 taylor
* some 64-bit OS comaptibility fixes
*
* Revision 2.23 2004/10/31 21:28:38 taylor
* support new pilot code, Linux code tree merge, don't use same pilot directory for Inferno builds
*
* Revision 2.22 2004/07/26 20:47:25 Kazan
* remove MCD complete
*
* Revision 2.21 2004/07/17 09:26:00 taylor
* add CF_SORT_REVERSE to real sort routine, makes CF_SORT_TIME work again
*
* Revision 2.20 2004/07/12 16:32:42 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.19 2004/05/26 22:02:36 wmcoolmon
* Fixed cf_matches_spec; small bug was introduced.
*
* Revision 2.18 2004/05/26 21:02:26 wmcoolmon
* Added weapons_expl modular table, updated cfilesystem to work with modular tables, fixed loading order, fixed ship loading error messages
*
* Revision 2.17 2004/05/03 21:22:19 Kazan
* Abandon strdup() usage for mod list processing - it was acting odd and causing crashing on free()
* Fix condition where alt_tab_pause() would flipout and trigger failed assert if game minimizes during startup (like it does a lot during debug)
* Nav Point / Auto Pilot code (All disabled via #ifdefs)
*
* Revision 2.16 2004/05/01 21:47:43 Kazan
* bah! stupid me "NULL" not "null" - i hate when i do that
*
@@ -197,13 +168,9 @@
#include <winbase.h> /* needed for memory mapping of file functions */
#endif
#ifdef SCP_UNIX
#ifdef unix
#include <glob.h>
#include <sys/types.h>
#include <dirent.h>
#include <fnmatch.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#include "cmdline/cmdline.h"
@@ -211,14 +178,9 @@
#include "cfile/cfilesystem.h"
#include "localization/localize.h"
#define CF_ROOTTYPE_PATH 0
#define CF_ROOTTYPE_PACK 1
// for a defined and specifically set location to get/send pilot/campaign files
char *Pilot_file_path = NULL;
// Created by:
// specifying hard drive tree
// searching for pack files on hard drive // Found by searching all known paths
@@ -246,8 +208,7 @@ typedef struct cf_root_block {
static int Num_roots = 0;
static cf_root_block *Root_blocks[CF_MAX_ROOT_BLOCKS];
static int Num_path_roots = 0;
// Created by searching all roots in order. This means Files is then sorted by precedence.
typedef struct cf_file {
@@ -286,7 +247,7 @@ cf_file *cf_create_file()
int offset = Num_files % CF_NUM_FILES_PER_BLOCK;
if ( File_blocks[block] == NULL ) {
File_blocks[block] = (cf_file_block *)vm_malloc( sizeof(cf_file_block) );
File_blocks[block] = (cf_file_block *)malloc( sizeof(cf_file_block) );
Assert( File_blocks[block] != NULL);
}
@@ -317,7 +278,7 @@ cf_root *cf_create_root()
int offset = Num_roots % CF_NUM_ROOTS_PER_BLOCK;
if ( Root_blocks[block] == NULL ) {
Root_blocks[block] = (cf_root_block *)vm_malloc( sizeof(cf_root_block) );
Root_blocks[block] = (cf_root_block *)malloc( sizeof(cf_root_block) );
Assert(Root_blocks[block] != NULL);
}
@@ -338,11 +299,10 @@ int cf_get_packfile_count(cf_root *root)
for (i=CF_TYPE_ROOT; i<CF_MAX_PATH_TYPES; i++ ) {
strcpy( filespec, root->path );
if(strlen(Pathtypes[i].path)) {
strcat( filespec, Pathtypes[i].path );
if ( filespec[strlen(filespec)-1] != DIR_SEPARATOR_CHAR ) {
if(strlen(Pathtypes[i].path)) {
strcat( filespec, Pathtypes[i].path );
strcat( filespec, DIR_SEPARATOR_STR );
}
// }
}
#if defined _WIN32
@@ -363,7 +323,7 @@ int cf_get_packfile_count(cf_root *root)
_findclose( find_handle );
}
#elif defined SCP_UNIX
#elif defined unix
strcat( filespec, "*.[vV][pP]" );
glob_t globinfo;
@@ -418,7 +378,7 @@ void cf_build_pack_list( cf_root *root )
}
// allocate a temporary array of temporary roots so we can easily sort them
temp_roots_sort = (cf_root_sort*)vm_malloc(sizeof(cf_root_sort) * temp_root_count);
temp_roots_sort = (cf_root_sort*)malloc(sizeof(cf_root_sort) * temp_root_count);
if(temp_roots_sort == NULL){
Int3();
return;
@@ -431,9 +391,7 @@ void cf_build_pack_list( cf_root *root )
if(strlen(Pathtypes[i].path)) {
strcat( filespec, Pathtypes[i].path );
if ( filespec[strlen(filespec)-1] != DIR_SEPARATOR_CHAR ) {
strcat( filespec, DIR_SEPARATOR_STR );
}
strcat( filespec, DIR_SEPARATOR_STR );
}
@@ -473,7 +431,7 @@ void cf_build_pack_list( cf_root *root )
_findclose( find_handle );
}
#elif defined SCP_UNIX
#elif defined unix
strcat( filespec, "*.[vV][pP]" );
glob_t globinfo;
memset(&globinfo, 0, sizeof(globinfo));
@@ -520,64 +478,17 @@ void cf_build_pack_list( cf_root *root )
}
// free up the temp list
vm_free(temp_roots_sort);
free(temp_roots_sort);
}
void cf_build_root_list(char *cdrom_dir)
{
Num_roots = 0;
Num_path_roots = 0;
cf_root *root;
char str_temp[128], *cur_pos;
#ifdef SCP_UNIX
// =========================================================================
// now look for mods under the users HOME directory to use before system ones
if (Cmdline_mod) {
for (cur_pos=Cmdline_mod; strlen(cur_pos) != 0; cur_pos+= (strlen(cur_pos)+1))
{
memset(str_temp, 0, 128);
strcpy(str_temp, cur_pos);
strcat(str_temp, DIR_SEPARATOR_STR);
root = cf_create_root();
strcpy( root->path, Cfile_user_dir );
// do we already have a slash? as in the case of a root directory install
if(strlen(root->path) && (root->path[strlen(root->path)-1] != DIR_SEPARATOR_CHAR)){
strcat(root->path, DIR_SEPARATOR_STR); // put trailing backslash on for easier path construction
}
strcat(root->path, str_temp);
root->roottype = CF_ROOTTYPE_PATH;
cf_build_pack_list(root);
}
}
// =========================================================================
// =========================================================================
// set users HOME directory as default for loading and saving files
root = cf_create_root();
strcpy( root->path, Cfile_user_dir );
// do we already have a slash? as in the case of a root directory install
if(strlen(root->path) && (root->path[strlen(root->path)-1] != DIR_SEPARATOR_CHAR)){
strcat(root->path, DIR_SEPARATOR_STR); // put trailing backslash on for easier path construction
}
root->roottype = CF_ROOTTYPE_PATH;
// set the default player location to here
if ( Pilot_file_path == NULL )
Pilot_file_path = root->path;
// Next, check any VP files under the current directory.
cf_build_pack_list(root);
// =========================================================================
#endif
if(Cmdline_mod) {
// stackable Mod support -- Kazan
//This for statement is a work of art :D
@@ -585,11 +496,13 @@ void cf_build_root_list(char *cdrom_dir)
{
//strdup was not behaving reliably
//str_temp = vm_strdup(cur_pos);
//str_temp = strdup(cur_pos);
memset(str_temp, 0, 128);
strcpy(str_temp, cur_pos);
strcat(str_temp, DIR_SEPARATOR_STR);
root = cf_create_root();
@@ -619,12 +532,9 @@ void cf_build_root_list(char *cdrom_dir)
strcat(root->path, DIR_SEPARATOR_STR); // put trailing backslash on for easier path construction
}
root->roottype = CF_ROOTTYPE_PATH;
// set the default path for pilot files
if ( Pilot_file_path == NULL )
Pilot_file_path = root->path;
//======================================================
// Next, check any VP files under the current directory.
cf_build_pack_list(root);
@@ -673,18 +583,11 @@ void cf_search_root_path(int root_index)
for (i=CF_TYPE_ROOT; i<CF_MAX_PATH_TYPES; i++ ) {
// we don't want to add player files to the cache - taylor
if ( (i == CF_TYPE_SINGLE_PLAYERS) || (i == CF_TYPE_MULTI_PLAYERS) ) {
continue;
}
strcpy( search_path, root->path );
if(strlen(Pathtypes[i].path)) {
strcat( search_path, Pathtypes[i].path );
if ( search_path[strlen(search_path)-1] != DIR_SEPARATOR_CHAR ) {
strcat( search_path, DIR_SEPARATOR_STR );
}
strcat( search_path, DIR_SEPARATOR_STR );
}
#if defined _WIN32
@@ -723,51 +626,37 @@ void cf_search_root_path(int root_index)
_findclose( find_handle );
}
#elif defined SCP_UNIX
DIR *dirp;
struct dirent *dir;
dirp = opendir (search_path);
if ( dirp ) {
while ((dir = readdir (dirp)) != NULL)
{
if (!fnmatch ("*.*", dir->d_name, 0))
{
char fn[MAX_PATH];
snprintf(fn, MAX_PATH-1, "%s%s", search_path, dir->d_name);
fn[MAX_PATH-1] = 0;
struct stat buf;
if (stat(fn, &buf) == -1) {
continue;
}
if (!S_ISREG(buf.st_mode)) {
continue;
}
char *ext = strchr( dir->d_name, '.' );
#elif defined unix
strcat( search_path, "*" );
glob_t globinfo;
memset(&globinfo, 0, sizeof(globinfo));
int status = glob(search_path, 0, NULL, &globinfo);
if (status == 0) {
for (unsigned int j = 0; j < globinfo.gl_pathc; j++) {
// Determine if this is a regular file
struct stat statbuf;
memset(&statbuf, 0, sizeof(statbuf));
stat(globinfo.gl_pathv[j], &statbuf);
if (S_ISREG(statbuf.st_mode)) {
char *ext = strchr(globinfo.gl_pathv[j], '.' );
if ( ext ) {
if ( is_ext_in_list( Pathtypes[i].extensions, ext ) ) {
// Found a file!!!!
cf_file *file = cf_create_file();
strcpy( file->name_ext, dir->d_name );
strcpy( file->name_ext, globinfo.gl_pathv[j] );
file->root_index = root_index;
file->pathtype_index = i;
file->write_time = buf.st_mtime;
file->size = buf.st_size;
file->write_time = statbuf.st_mtime;
file->size = statbuf.st_size;
file->pack_offset = 0; // Mark as a non-packed file
//mprintf(( "Found file '%s'\n", file->name_ext ));
}
}
}
}
closedir(dirp);
globfree(&globinfo);
}
#endif
}
@@ -785,7 +674,7 @@ typedef struct VP_FILE {
int offset;
int size;
char filename[32];
_fs_time_t write_time;
time_t write_time;
} VP_FILE;
void cf_search_root_pack(int root_index)
@@ -806,10 +695,6 @@ void cf_search_root_pack(int root_index)
Assert( sizeof(VP_header) == 16 );
fread(&VP_header, 1, sizeof(VP_header), fp);
VP_header.version = INTEL_INT( VP_header.version );
VP_header.index_offset = INTEL_INT( VP_header.index_offset );
VP_header.num_files = INTEL_INT( VP_header.num_files );
// Read index info
fseek(fp, VP_header.index_offset, SEEK_SET);
@@ -824,10 +709,6 @@ void cf_search_root_pack(int root_index)
fread( &find, sizeof(VP_FILE), 1, fp );
find.offset = INTEL_INT( find.offset );
find.size = INTEL_INT( find.size );
find.write_time = INTEL_INT( find.write_time );
if ( find.size == 0 ) {
if ( !stricmp( find.filename, ".." )) {
int l = strlen(search_path);
@@ -837,8 +718,8 @@ void cf_search_root_pack(int root_index)
}
*p = 0;
} else {
if ( strlen(search_path) && (search_path[strlen(search_path)-1] != DIR_SEPARATOR_CHAR) ) {
strcat( search_path, DIR_SEPARATOR_STR );
if ( strlen(search_path) ) {
strcat( search_path, DIR_SEPARATOR_STR );
}
strcat( search_path, find.filename );
}
@@ -859,7 +740,7 @@ void cf_search_root_pack(int root_index)
strcpy( file->name_ext, find.filename );
file->root_index = root_index;
file->pathtype_index = j;
file->write_time = (time_t)find.write_time;
file->write_time = find.write_time;
file->size = find.size;
file->pack_offset = find.offset; // Mark as a packed file
//mprintf(( "Found pack file '%s'\n", file->name_ext ));
@@ -940,7 +821,7 @@ void cf_free_secondary_filelist()
// Free the root blocks
for (i=0; i<CF_MAX_ROOT_BLOCKS; i++ ) {
if ( Root_blocks[i] ) {
vm_free( Root_blocks[i] );
free( Root_blocks[i] );
Root_blocks[i] = NULL;
}
}
@@ -949,7 +830,7 @@ void cf_free_secondary_filelist()
// Init the file blocks
for (i=0; i<CF_MAX_FILE_BLOCKS; i++ ) {
if ( File_blocks[i] ) {
vm_free( File_blocks[i] );
free( File_blocks[i] );
File_blocks[i] = NULL;
}
}
@@ -978,14 +859,18 @@ int cf_find_file_location( char *filespec, int pathtype, char *pack_filename, in
// of the file
// NOTE: full path should also include localization, if so desired
#ifdef SCP_UNIX
if ( strpbrk(filespec, "/") ) { // do we have a full path already?
#else
if ( strpbrk(filespec,"/\\:") ) { // do we have a full path already?
#endif
FILE *fp = fopen(filespec, "rb" );
if (fp) {
if ( size ) *size = filelength(fileno(fp));
if ( size ) {
#if defined _WIN32
*size = filelength(fileno(fp));
#elif defined unix
struct stat statbuf;
fstat(fileno(fp), &statbuf);
*size = statbuf.st_size;
#endif
}
if ( offset ) *offset = 0;
if ( pack_filename ) {
strcpy( pack_filename, filespec );
@@ -1026,7 +911,6 @@ int cf_find_file_location( char *filespec, int pathtype, char *pack_filename, in
case CF_TYPE_MULTI_PLAYERS:
case CF_TYPE_MULTI_CACHE:
case CF_TYPE_MISSIONS:
case CF_TYPE_CACHE:
cfs_slow_search = 1;
break;
@@ -1074,7 +958,7 @@ int cf_find_file_location( char *filespec, int pathtype, char *pack_filename, in
return 1;
}
}
#elif defined SCP_UNIX
#elif defined unix
FILE *fp = fopen(longname, "rb" );
if (fp) {
if ( size ) {
@@ -1120,9 +1004,7 @@ int cf_find_file_location( char *filespec, int pathtype, char *pack_filename, in
strcpy( pack_filename, r->path );
if ( f->pack_offset < 1 ) {
strcat( pack_filename, Pathtypes[f->pathtype_index].path );
if ( pack_filename[strlen(pack_filename)-1] != DIR_SEPARATOR_CHAR ) {
strcat( pack_filename, DIR_SEPARATOR_STR );
}
strcat( pack_filename, DIR_SEPARATOR_STR );
strcat( pack_filename, f->name_ext );
}
}
@@ -1144,9 +1026,7 @@ int cf_find_file_location( char *filespec, int pathtype, char *pack_filename, in
if(strlen(Pathtypes[f->pathtype_index].path)){
strcat( pack_filename, Pathtypes[f->pathtype_index].path );
if ( pack_filename[strlen(pack_filename)-1] != DIR_SEPARATOR_CHAR ) {
strcat( pack_filename, DIR_SEPARATOR_STR );
}
strcat( pack_filename, DIR_SEPARATOR_STR );
}
strcat( pack_filename, f->name_ext );
@@ -1166,35 +1046,17 @@ int cf_matches_spec(char *filespec, char *filename)
{
char *src_ext, *dst_ext;
src_ext = strrchr(filespec, '*');
if(!src_ext)
{
src_ext = strchr(filespec, '.');
if (!src_ext)
return 1;
}
else
{
src_ext++;
}
src_ext = strchr(filespec, '.');
if (!src_ext)
return 1;
if (*src_ext == '*')
return 1;
if(strlen(filespec) > strlen(filename))
{
return 0;
}
dst_ext = filename + strlen(filename) - ((filespec + strlen(filespec)) - src_ext);
dst_ext = strchr(filename, '.');
if (!dst_ext)
return 1;
if(src_ext == filespec)
{
return !stricmp(dst_ext, src_ext);
}
else
{
return (!stricmp(dst_ext, src_ext) && !strnicmp(dst_ext, src_ext, src_ext - filespec));
}
return !stricmp(dst_ext, src_ext);
}
int (*Get_file_list_filter)(char *filename) = NULL;
@@ -1227,7 +1089,7 @@ int cf_file_already_in_list( int num_files, char **list, char *filename )
int cf_get_file_list( int max, char **list, int pathtype, char *filter, int sort, file_list_info *info )
{
char *ptr;
int i, l, num_files = 0, own_flag = 0;
int i, l, find_handle, num_files = 0, own_flag = 0;
if (max < 1) {
Get_file_list_filter = NULL;
@@ -1238,18 +1100,16 @@ int cf_get_file_list( int max, char **list, int pathtype, char *filter, int sort
Assert(list);
if (!info && (sort == CF_SORT_TIME)) {
info = (file_list_info *) vm_malloc(sizeof(file_list_info) * max);
info = (file_list_info *) malloc(sizeof(file_list_info) * max);
own_flag = 1;
}
char filespec[MAX_PATH_LEN];
#if defined _WIN32
cf_create_default_path_string( filespec, pathtype, filter );
#if defined _WIN32
_finddata_t find;
int find_handle;
find_handle = _findfirst( filespec, &find );
if (find_handle != -1) {
do {
@@ -1265,7 +1125,7 @@ int cf_get_file_list( int max, char **list, int pathtype, char *filter, int sort
else
l = strlen(find.name);
list[num_files] = (char *)vm_malloc(l + 1);
list[num_files] = (char *)malloc(l + 1);
strncpy(list[num_files], find.name, l);
list[num_files][l] = 0;
if (info)
@@ -1280,53 +1140,41 @@ int cf_get_file_list( int max, char **list, int pathtype, char *filter, int sort
_findclose( find_handle );
}
#elif defined SCP_UNIX
cf_create_default_path_string( filespec, pathtype, NULL );
DIR *dirp;
struct dirent *dir;
dirp = opendir (filespec);
if ( dirp ) {
while ((dir = readdir (dirp)) != NULL)
{
if (num_files >= max)
break;
if (fnmatch(filter, dir->d_name, 0) != 0)
continue;
char fn[MAX_PATH];
snprintf(fn, MAX_PATH-1, "%s/%s", filespec, dir->d_name);
fn[MAX_PATH-1] = 0;
struct stat buf;
if (stat(fn, &buf) == -1) {
continue;
}
if (!S_ISREG(buf.st_mode)) {
continue;
}
if ( !Get_file_list_filter || (*Get_file_list_filter)(dir->d_name) ) {
ptr = strrchr(dir->d_name, '.');
if (ptr)
l = ptr - dir->d_name;
else
l = strlen(dir->d_name);
list[num_files] = (char *)vm_malloc(l + 1);
strncpy(list[num_files], dir->d_name, l);
list[num_files][l] = 0;
if (info)
info[num_files].write_time = buf.st_mtime;
num_files++;
#elif defined unix
char base_filespec[MAX_PATH_LEN];
cf_create_default_path_string( base_filespec, pathtype );
int base_filespec_len = strlen(base_filespec);
glob_t globinfo;
memset(&globinfo, 0, sizeof(globinfo));
int status = glob(filespec, 0, NULL, &globinfo);
if (status == 0) {
for (unsigned int i = 0; i < globinfo.gl_pathc; i++) {
// Determine if this is a regular file
struct stat statbuf;
memset(&statbuf, 0, sizeof(statbuf));
stat(globinfo.gl_pathv[i], &statbuf);
if (S_ISREG(statbuf.st_mode)) {
if ( !Get_file_list_filter || (*Get_file_list_filter)(globinfo.gl_pathv[i]) ) {
char *found_file = globinfo.gl_pathv[i];
Assert(strncmp(found_file, base_filespec, base_filespec_len) == 0);
found_file += base_filespec_len;
ptr = strrchr(found_file, '.');
if (ptr)
l = ptr - found_file;
else
l = strlen(found_file);
list[num_files] = (char *)malloc(l + 1);
strncpy(list[num_files], found_file, l);
list[num_files][l] = 0;
if (info)
info[num_files].write_time = statbuf.st_mtime;
num_files++;
}
}
globfree(&globinfo);
}
closedir(dirp);
}
#endif
@@ -1341,6 +1189,7 @@ int cf_get_file_list( int max, char **list, int pathtype, char *filter, int sort
}
if (num_files >= max)
break;
if ( !cf_matches_spec( filter,f->name_ext)) {
@@ -1361,7 +1210,7 @@ int cf_get_file_list( int max, char **list, int pathtype, char *filter, int sort
else
l = strlen(f->name_ext);
list[num_files] = (char *)vm_malloc(l + 1);
list[num_files] = (char *)malloc(l + 1);
strncpy(list[num_files], f->name_ext, l);
list[num_files][l] = 0;
@@ -1381,7 +1230,7 @@ int cf_get_file_list( int max, char **list, int pathtype, char *filter, int sort
}
if (own_flag) {
vm_free(info);
free(info);
}
Get_file_list_filter = NULL;
@@ -1432,20 +1281,18 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
}
if (!info && (sort == CF_SORT_TIME)) {
info = (file_list_info *) vm_malloc(sizeof(file_list_info) * max);
if ( info )
own_flag = 1;
info = (file_list_info *) malloc(sizeof(file_list_info) * max);
own_flag = 1;
}
char filespec[MAX_PATH_LEN];
// Search the default directories
#if defined _WIN32
cf_create_default_path_string( filespec, pathtype, filter );
mprintf(("cf_get_file_list_preallocated looking for type=%d, filter=\"%s\"\n",
pathtype, filter));
// Search the default directories
#if defined _WIN32
int find_handle;
_finddata_t find;
@@ -1478,51 +1325,41 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
_findclose( find_handle );
}
#elif defined SCP_UNIX
cf_create_default_path_string( filespec, pathtype, NULL );
#elif defined unix
char base_filespec[MAX_PATH_LEN];
cf_create_default_path_string( base_filespec, pathtype );
int base_filespec_len = strlen(base_filespec);
glob_t globinfo;
memset(&globinfo, 0, sizeof(globinfo));
int status = glob(filespec, 0, NULL, &globinfo);
if (status == 0) {
for (unsigned int i = 0; i < globinfo.gl_pathc; i++) {
// Determine if this is a regular file
struct stat statbuf;
memset(&statbuf, 0, sizeof(statbuf));
stat(globinfo.gl_pathv[i], &statbuf);
if (S_ISREG(statbuf.st_mode)) {
if ( !Get_file_list_filter || (*Get_file_list_filter)(globinfo.gl_pathv[i]) ) {
char *found_file = globinfo.gl_pathv[i];
Assert(strncmp(found_file, base_filespec, base_filespec_len) == 0);
found_file += base_filespec_len;
DIR *dirp;
struct dirent *dir;
strncpy(arr[num_files], found_file, MAX_FILENAME_LEN - 1 );
char *ptr = strrchr(arr[num_files], '.');
if ( ptr ) {
*ptr = 0;
}
dirp = opendir (filespec);
if ( dirp ) {
while ((dir = readdir (dirp)) != NULL)
{
if (num_files >= max)
break;
if (fnmatch(filter, dir->d_name, 0) != 0)
continue;
char fn[MAX_PATH];
snprintf(fn, MAX_PATH-1, "%s/%s", filespec, dir->d_name);
fn[MAX_PATH-1] = 0;
struct stat buf;
if (stat(fn, &buf) == -1) {
continue;
}
if (!S_ISREG(buf.st_mode)) {
continue;
}
if ( !Get_file_list_filter || (*Get_file_list_filter)(dir->d_name) ) {
strncpy(arr[num_files], dir->d_name, MAX_FILENAME_LEN - 1 );
char *ptr = strrchr(arr[num_files], '.');
if ( ptr ) {
*ptr = 0;
if (info) {
info[num_files].write_time = statbuf.st_mtime;
}
num_files++;
}
if (info) {
info[num_files].write_time = buf.st_mtime;
}
num_files++;
}
}
closedir(dirp);
globfree(&globinfo);
}
#endif
@@ -1574,7 +1411,7 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
}
if (own_flag) {
vm_free(info);
free(info);
}
Get_file_list_filter = NULL;
@@ -1592,11 +1429,7 @@ int cf_get_file_list_preallocated( int max, char arr[][MAX_FILENAME_LEN], char *
// Output: path - Fully qualified pathname.
void cf_create_default_path_string( char *path, int pathtype, char *filename, bool localize )
{
#ifdef SCP_UNIX
if ( filename && strpbrk(filename,"/") ) {
#else
if ( filename && strpbrk(filename,"/\\:") ) {
#endif
if ( filename && strpbrk(filename,"/\\:") ) {
// Already has full path
strcpy( path, filename );
@@ -1610,30 +1443,14 @@ void cf_create_default_path_string( char *path, int pathtype, char *filename, bo
Assert(CF_TYPE_SPECIFIED(pathtype));
// force a specific directory to search for player files
if ( (pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS) ) {
strcpy(path, Pilot_file_path);
} else {
strcpy(path, root->path);
}
strcpy(path, root->path);
strcat(path, Pathtypes[pathtype].path);
// Don't add slash for root directory
if (Pathtypes[pathtype].path[0] != '\0') {
if ( path[strlen(path)-1] != DIR_SEPARATOR_CHAR ) {
strcat(path, DIR_SEPARATOR_STR);
}
strcat(path, DIR_SEPARATOR_STR);
}
#ifdef INF_BUILD
// keep pilot files separated for an Inferno build since they aren't compatible
if ( pathtype == CF_TYPE_SINGLE_PLAYERS ) {
strcat(path, "inferno");
strcat(path, DIR_SEPARATOR_STR);
}
#endif
// add filename
if (filename) {
strcat(path, filename);
@@ -1658,3 +1475,4 @@ void cf_create_default_path_string( char *path, int pathtype, char *filename, bo
}
}
}
+2 -9
View File
@@ -9,8 +9,8 @@
/*
* $Logfile: /Freespace2/code/CFile/CfileSystem.h $
* $Revision: 2.3 $
* $Date: 2005-07-13 02:50:49 $
* $Revision: 2.1 $
* $Date: 2004-03-05 09:01:54 $
* $Author: Goober5000 $
*
* Functions to keep track of and find files that can exist
@@ -20,13 +20,6 @@
* all those locations, inherently enforcing precedence orders.
*
* $Log: not supported by cvs2svn $
* Revision 2.2 2004/08/11 05:06:19 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.1 2004/03/05 09:01:54 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.0 2002/06/03 04:02:21 penguin
* Warpcore CVS sync
*
+14 -155
View File
@@ -9,20 +9,13 @@
/*
* $Logfile: /Freespace2/code/Cfilearchiver/CfileArchiver.cpp $
* $Revision: 2.3 $
* $Date: 2005-09-08 00:09:31 $
* $Author: taylor $
* $Revision: 2.1 $
* $Date: 2003-11-16 09:42:37 $
* $Author: Goober5000 $
*
* Program to create an archive file for use with cfile stuff
*
* $Log: not supported by cvs2svn $
* Revision 2.2 2005/01/30 12:50:08 taylor
* merge with Linux/OSX tree - p0130
*
* Revision 2.1 2003/11/16 09:42:37 Goober5000
* clarified and pruned debug spew messages
* --Goober5000
*
* Revision 2.0 2002/06/03 04:02:21 penguin
* Warpcore CVS sync
*
@@ -37,28 +30,15 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef _WIN32
#include <direct.h>
#include <io.h>
#include <string.h>
#include <conio.h>
#else
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#endif
#include "globalincs/pstypes.h"
#include "cfile/cfile.h"
static int data_error;
static int no_dir;
unsigned int Total_size=16; // Start with size of header
unsigned int Num_files =0;
FILE *fp_out = NULL;
FILE *fp_out_hdr = NULL;
FILE * fp_out = NULL;
FILE * fp_out_hdr = NULL;
typedef struct vp_header {
char id[4];
@@ -102,7 +82,7 @@ int write_index(char *hf, char *df)
return 1;
}
void pack_file( char *filespec, char *filename, int filesize, _fs_time_t time_write )
void pack_file( char *filespec, char *filename, int filesize, time_t time_write )
{
char path[1024];
@@ -130,15 +110,13 @@ void pack_file( char *filespec, char *filename, int filesize, _fs_time_t time_wr
fwrite( &Total_size, 1, 4, fp_out_hdr );
fwrite( &filesize, 1, 4, fp_out_hdr );
fwrite( &path, 1, 32, fp_out_hdr );
fwrite( &time_write, 1, sizeof(_fs_time_t), fp_out_hdr);
fwrite( &time_write, 1, sizeof(time_t), fp_out_hdr);
Total_size += filesize;
Num_files++;
printf( "Packing %s\\%s...", filespec, filename );
printf( "Packing %s%s%s...", filespec, DIR_SEPARATOR_STR, filename );
sprintf( path, "%s%s%s", filespec, DIR_SEPARATOR_STR, filename );
sprintf( path, "%s\\%s", filespec, filename );
FILE *fp = fopen( path, "rb" );
@@ -175,7 +153,7 @@ void add_directory( char * dirname)
int i = 0;
fwrite(&i, 1, 4, fp_out_hdr);
// strip out any directories that this dir is a subdir of
while ((tmpptr = strchr(pathptr, DIR_SEPARATOR_CHAR)) != NULL) {
while ((tmpptr = strchr(pathptr, '\\')) != NULL) {
pathptr = tmpptr+1;
}
fwrite(pathptr, 1, 32, fp_out_hdr);
@@ -185,10 +163,8 @@ void add_directory( char * dirname)
void pack_directory( char * filespec)
{
#ifdef _WIN32
int find_handle;
_finddata_t find;
#endif
char tmp[512];
char tmp1[512];
@@ -208,21 +184,12 @@ void pack_directory( char * filespec)
}
*/
char *ts;
// strip trailing slash
ts = filespec+(strlen(filespec)-1);
while(*ts == DIR_SEPARATOR_CHAR && ts > filespec)
*ts = '\0';
strcpy( tmp1, filespec );
add_directory(filespec);
strcat( tmp1, DIR_SEPARATOR_STR"*.*" );
strcat( tmp1, "\\*.*" );
printf( "In dir '%s'\n", tmp1 );
#ifdef _WIN32
find_handle = _findfirst( tmp1, &find );
if( find_handle != -1 ) {
if ( find.attrib & _A_SUBDIR ) {
@@ -250,95 +217,10 @@ void pack_directory( char * filespec)
}
}
}
#else
DIR *dirp;
struct dirent *dir;
dirp = opendir (filespec);
if ( dirp ) {
while ((dir = readdir(dirp)) != NULL) {
char fn[MAX_PATH];
snprintf(fn, MAX_PATH-1, "%s/%s", filespec, dir->d_name);
fn[MAX_PATH-1] = 0;
struct stat buf;
if (stat(fn, &buf) == -1) {
continue;
}
if ( (strcmp(dir->d_name, ".") == 0) || (strcmp(dir->d_name, "..") == 0) ) {
continue;
}
if (S_ISDIR(buf.st_mode)) {
strcpy( tmp, filespec );
strcat( tmp, "/" );
strcat( tmp, dir->d_name );
pack_directory(tmp);
} else {
pack_file( filespec, dir->d_name, buf.st_size, buf.st_mtime );
}
}
closedir(dirp);
} else {
printf("Error: Source directory does not exist!\n");
no_dir = 1;
}
#endif
add_directory("..");
}
int verify_directory( char *filespec )
{
char *ts;
char *dd;
// strip trailing '/'
ts = filespec+(strlen(filespec)-1);
while(*ts == DIR_SEPARATOR_CHAR && ts > filespec)
*ts = '\0';
// make sure last directory is named "data", ignoring case
dd = filespec+(strlen(filespec)-4);
if ( stricmp( dd, "data" ) )
data_error = 1;
return data_error;
}
void print_instructions()
{
printf( "Creates a vp archive out of a FreeSpace data tree.\n\n" );
printf( "Usage: cfilearchiver archive_name src_dir\n");
printf( "Example: cfilearchiver freespace /tmp/freespace/data\n\n");
printf( "Directory structure options:\n" );
printf( " Effects (.ani .pcx .neb .tga)\n" );
printf( " Fonts (.vf)\n" );
printf( " Hud (.ani .pcx .tga\n" );
printf( " Interface (.pcx .ani .tga)\n" );
printf( " Maps (.pcx .ani .tga)\n" );
printf( " Missions (.ntl .ssv), FS1(.fsm .fsc), FS2(.fs2 .fc2)\n" );
printf( " Models (.pof)\n" );
printf( " Music (.wav)\n" );
printf( " Sounds/8b22k (.wav)\n" );
printf( " Sounds/16b11k (.wav)\n" );
printf( " Tables (.tbl)\n" );
printf( " Voice/Briefing (.wav)\n" );
printf( " Voice/Command briefings (.wav)\n" );
printf( " Voice/Debriefing (.wav)\n" );
printf( " Voice/Personas (.wav)\n" );
printf( " Voice/Special (.wav)\n" );
printf( " Voice/Training (.wav)\n" );
exit(0);
}
// we end up #include'ing SDL.h which on Windows and Mac will redfine main() which is something
// that we don't want since we don't actually link against SDL, this solves the problem...
#ifdef main
#undef main
#endif
int main(int argc, char *argv[] )
{
@@ -346,16 +228,12 @@ int main(int argc, char *argv[] )
char *p;
if ( argc < 3 ) {
#ifdef _WIN32
printf( "Usage: %s archive_name src_dir\n", argv[0] );
printf( "Example: %s freespace c:\\freespace\\data\n", argv[0] );
printf( "Creates an archive named freespace out of the\nfreespace data tree\n" );
printf( "Press any key to exit...\n" );
getch();
return 1;
#else
print_instructions();
#endif
}
strcpy( archive, argv[1] );
@@ -370,41 +248,24 @@ int main(int argc, char *argv[] )
fp_out = fopen( archive_dat, "wb" );
if ( !fp_out ) {
printf( "Couldn't open '%s'!\n", archive_dat );
#ifdef _WIN32
printf( "out1: Couldn't open '%s'!\n", archive_dat );
printf( "Press any key to exit...\n" );
getch();
return 1;
#else
exit(1);
#endif
}
fp_out_hdr = fopen( archive_hdr, "wb" );
if ( !fp_out_hdr ) {
printf( "Couldn't open '%s'!\n", archive_hdr );
#ifdef _WIN32
printf( "out2: Couldn't open '%s'!\n", archive_hdr );
printf( "Press any key to exit...\n" );
getch();
return 1;
#else
exit(2);
#endif
}
if ( verify_directory( argv[2] ) != 0 ) {
printf("Warning! Last directory must be named \"data\" (not case sensitive)\n");
exit(3);
}
write_header();
pack_directory( argv[2] );
// in case the directory doesn't exist
if ( no_dir )
exit(4);
write_header();
fclose(fp_out);
@@ -414,10 +275,8 @@ int main(int argc, char *argv[] )
if (!write_index(archive_hdr, archive_dat)) {
printf("Error appending index!\n");
#ifdef _WIN32
printf("Press any key to exit...\n");
getch();
#endif
return 1;
}
@@ -1,476 +0,0 @@
/*
* Copyright (C) 2005 Taylor Richards
*
*/
/*
* $Logfile: /Freespace2/code/cfileextractor/cfileextractor.cpp $
* $Revision: 1.6 $
* $Date: 2005-09-08 05:04:15 $
* $Author: taylor $
*
* Cross-platform cmdline extractor for VP files
*
* $Log: not supported by cvs2svn $
* Revision 1.5 2005/09/08 00:09:31 taylor
* fix building/linking of command line tools under Linux/OSX
* add tools as targets to OSX project file
*
* Revision 1.4 2005/05/24 20:52:10 taylor
* make sure that we recursively create directories for Linux/OSX
* replace older recursive mkdir method in cfileextractor with new method
*
* Revision 1.3 2005/05/24 03:12:27 taylor
* get command sanity check right, fixes lowercase on extract too
*
* Revision 1.2 2005/05/18 01:57:54 taylor
* a few help text adjustments and fix some compiler warnings
*
* Revision 1.1 2005/05/17 21:00:57 taylor
* Initial import of cfileextractor, still needs some work but does what it needs to
*
*
* $NoKeywords: $
*/
#include <vector>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <ctime>
#ifdef _WIN32
#include <direct.h>
#else
#include <unistd.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include "globalincs/pstypes.h"
#include "cfile/cfile.h"
// /////////////////////////////////////////////////////////////////////////////
//
// GLOBAL FUNCTIONS AND VARIABLES
//
// right out of pstypes.h but we don't want to use the INTEL_INT macro here
// since it would require SDL which isn't used on WIN32 platforms
#if BYTE_ORDER == BIG_ENDIAN
#define INT_SWAP(x) ( \
(x << 24) | \
(((ulong)x) >> 24) | \
((x & 0x0000ff00) << 8) | \
((x & 0x00ff0000) >> 8) \
)
#else
#define INT_SWAP(x) (x)
#endif
FILE *fp_in = NULL;
FILE *fp_out = NULL;
#define BLOCK_SIZE (1024*1024)
char tmp_data[BLOCK_SIZE]; // 1 MB
static int have_index = 0;
static int have_header = 0;
#define ERR_NO_FP_IN 0
#define ERR_NO_FP_OUT 1
#define ERR_INVALID_VP 2
#define ERR_NO_INDEX 3
#define ERR_NO_HEADER 4
typedef struct vp_header {
char id[4]; // 'VPVP'
int version;
int index_offset; // offset where the file index starts, also a total file data size count
int num_files; // number of files, including each step in the directory structure
} vp_header;
vp_header VP_Header;
typedef struct vp_fileinfo {
// stuff that is actually written to the VP
int offset; // offset of where this file is in the VP
int file_size; // size of file
char file_name[CF_MAX_FILENAME_LENGTH]; // filename
_fs_time_t write_time; // date/time in _fs_time_t type (a 32-bit version of time_t)
// not in the VP
char file_path[CF_MAX_PATHNAME_LENGTH]; // file path, generated here and not actually in the VP on a per file basis
vp_fileinfo() {
offset = 0;
file_size = 0;
file_name[0] = '\0';
file_path[0] = '\0';
write_time = 0;
}
~vp_fileinfo() {}
} vp_fileinfo;
std::vector<vp_fileinfo> VP_FileInfo;
// just like strlwr() but without actually including it here
void lowercase(char *s)
{
if (s == NULL)
return;
while (*s) {
*s = tolower(*s);
s++;
}
}
//
// /////////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////////
//
// The useful stuff...
//
void print_error(int err)
{
switch (err) {
case ERR_NO_FP_IN:
printf("ERROR: The input file (fp_in) is NULL! Exiting...\n");
break;
case ERR_NO_FP_OUT:
printf("ERROR: The output file (fp_out) is NULL! Exiting...\n");
break;
case ERR_INVALID_VP:
printf("ERROR: The specified VP file is invalid! Exiting...\n");
break;
case ERR_NO_INDEX:
printf("ERROR: No file index is available! Exiting...\n");
break;
case ERR_NO_HEADER:
printf("ERROR: No file header is available! Exiting...\n");
break;
default:
break;
}
exit(1);
}
void read_header()
{
fseek(fp_in, 0, SEEK_SET);
fread(&VP_Header.id, 1, 4, fp_in);
fread(&VP_Header.version, 1, sizeof(int), fp_in);
fread(&VP_Header.index_offset, 1, sizeof(int), fp_in);
fread(&VP_Header.num_files, 1, sizeof(int), fp_in);
VP_Header.version = INT_SWAP(VP_Header.version);
VP_Header.index_offset = INT_SWAP(VP_Header.index_offset);
VP_Header.num_files = INT_SWAP(VP_Header.num_files);
// check for a valid id (VPVP)
if ( (VP_Header.id[0] != 'V') && (VP_Header.id[1] != 'P') && (VP_Header.id[2] != 'V') && (VP_Header.id[3] != 'P') )
print_error(ERR_INVALID_VP);
// the index_offset needs to be greater than the size of vp_header at the very least and there should be at least one file
if ( !(VP_Header.index_offset > (int)sizeof(vp_header)) || !(VP_Header.num_files > 1) )
print_error(ERR_INVALID_VP);
have_header = 1;
}
void read_index(int lc = 0)
{
if (fp_in == NULL)
print_error(ERR_NO_FP_IN);
else if (!have_header)
print_error(ERR_NO_HEADER);
int i;
char path[CF_MAX_PATHNAME_LENGTH];
fseek(fp_in, VP_Header.index_offset, SEEK_SET);
memset(path, 0, CF_MAX_PATHNAME_LENGTH);
for ( i = 0; i < VP_Header.num_files; i++) {
vp_fileinfo vpinfo;
fread(&vpinfo.offset, 1, sizeof(int), fp_in);
fread(&vpinfo.file_size, 1, sizeof(int), fp_in);
fread(&vpinfo.file_name, 1, CF_MAX_FILENAME_LENGTH, fp_in);
fread(&vpinfo.write_time, 1, sizeof(_fs_time_t), fp_in);
vpinfo.offset = INT_SWAP(vpinfo.offset);
vpinfo.file_size = INT_SWAP(vpinfo.file_size);
vpinfo.write_time = INT_SWAP(vpinfo.write_time);
// check if it's a directory and if so then create a path to use for files
if (vpinfo.file_size == 0) {
// if we get a ".." then drop down in the path
if (!strcmp(vpinfo.file_name, "..")) {
char *s = strrchr(path, DIR_SEPARATOR_CHAR);
if (s)
*s = '\0';
// skip, we don't want to add the ".." to the path
continue;
}
// don't add the very first directory separator character, easier to clean later
if (path[0] != 0)
strcat( path, DIR_SEPARATOR_STR );
// always make directory names lower case for ease of use
lowercase( vpinfo.file_name );
strcat( path, vpinfo.file_name );
} // it's a file then
else {
// lowercase the filename if wanted
if (lc == 1)
lowercase( vpinfo.file_name );
strcpy( vpinfo.file_path, path );
VP_FileInfo.push_back(vpinfo);
}
}
have_index = 1;
}
void extract_all_files(char *file)
{
if (fp_in == NULL)
print_error(ERR_NO_FP_IN);
else if (!have_header)
print_error(ERR_NO_HEADER);
else if (!have_index)
print_error(ERR_NO_INDEX);
int status, m_error, nbytes, nbytes_remaining;
char path[CF_MAX_PATHNAME_LENGTH+CF_MAX_FILENAME_LENGTH+1]; // path length + filename length + extra NULL
char *c;
printf("VP file extractor - version 0.01\n");
printf("\n");
printf("Extracting: %s...\n", file);
for (uint i = 0; i < VP_FileInfo.size(); i++) {
// save the file path to a temp location and recursively make the needed directories
sprintf(path, "%s%s", VP_FileInfo[i].file_path, DIR_SEPARATOR_STR);
c = &path[0];
while (c++) {
c = strchr(c, DIR_SEPARATOR_CHAR);
if (c) {
*c = '\0'; // NULL at DIR_SEP char
#ifdef _WIN32
status = _mkdir(path);
#else
status = mkdir(path, 0777);
#endif
m_error = errno;
if (status && (m_error != EEXIST) ) {
printf("Cannot mkdir %s: %s\n", VP_FileInfo[i].file_path, strerror(m_error));
continue;
}
*c = DIR_SEPARATOR_CHAR; // replace DIR_SEP char
}
}
// start writing out the file
fseek(fp_in, VP_FileInfo[i].offset, SEEK_SET);
sprintf(path, "%s%s%s", VP_FileInfo[i].file_path, DIR_SEPARATOR_STR, VP_FileInfo[i].file_name);
fp_out = fopen(path, "wb");
printf(" %s ... ", path);
if (fp_out == NULL) {
printf("can't create file!\n");
continue;
}
nbytes_remaining = VP_FileInfo[i].file_size;
while ( nbytes_remaining > 0 ) {
nbytes = fread( tmp_data, 1, MIN(BLOCK_SIZE, nbytes_remaining), fp_in );
if (nbytes > 0) {
fwrite( tmp_data, 1, nbytes, fp_out );
nbytes_remaining -= nbytes;
}
}
printf("done!\n");
fclose(fp_out);
fp_out = NULL;
}
printf("\n");
}
// TODO: the formatting of this is a bit loco but I don't care enough to make it better...
void list_all_files(char *file)
{
char out_time[20];
float one_k = 1024.0f;
float one_m = 1048576.0f;
char m;
float div_by;
time_t plat_time;
// if we don't have an index then bail
if (!have_index)
print_error(ERR_NO_INDEX);
printf("VP file extractor - version 0.01\n");
printf("\n");
printf("%s:\n", file);
printf("\n");
printf(" Name Size Offset Date/Time Path\n");
printf("-------------------------------------------------------------------------------\n");
for (uint i = 0; i < VP_FileInfo.size(); i++) {
plat_time = VP_FileInfo[i].write_time; // gets rid of some platform strangeness this way
strftime(out_time, 32, "%F %H:%M", localtime(&plat_time)); // YYYY-mm-dd HH:mm (ISO 8601 date format, 24-hr time)
if (VP_FileInfo[i].file_size > (int)one_m) {
m = 'M';
div_by = one_m;
} else {
m = 'K';
div_by = one_k;
}
int len = strlen( VP_FileInfo[i].file_name );
printf("%s %*.1f%c %10i %18s %3s%s\n", VP_FileInfo[i].file_name, 33 - len, (float)VP_FileInfo[i].file_size/div_by, m, VP_FileInfo[i].offset, out_time, DIR_SEPARATOR_STR, VP_FileInfo[i].file_path);
}
printf("\n");
// we use the vector size here since VP_Header.num_files would include each entry
// in the directory tree as well as individual files and that artificially inflates
// the number of files that we show or would extract
printf("Total files: %i\n", (int)VP_FileInfo.size());
// yeah, I'm just that cheap
if (VP_Header.index_offset > (int)one_m) {
m = 'M';
div_by = one_m;
} else {
m = 'K';
div_by = one_k;
}
printf("Total size: %.1f%c\n", (float)VP_Header.index_offset/div_by, m);
printf("\n");
}
void help()
{
printf("VP file extractor - version 0.5\n");
printf("\n");
printf("Usage: cfileextractor [-x | -l] [-L] <vp_filename>\n");
printf("\n");
printf(" Commands (only one at the time):\n");
printf(" -x | --extract Extract all files into current directory.\n");
printf(" -l | --list List all files in VP archive.\n");
printf(" -h | --help Show this help text.\n");
printf("\n");
printf(" Options:\n");
printf(" -L | --lowercase Force all filenames to be lower case.\n");
printf("\n");
printf(" (No command specified will list all files in the VP archive.)\n");
printf("\n");
}
// we end up #include'ing SDL.h which on Windows and Mac will redfine main() which is something
// that we don't want since we don't actually link against SDL, this solves the problem...
#ifdef main
#undef main
#endif
int main(int argc, char *argv[])
{
int extract = 0, lc = 0, list = 0;
if (argc < 2) {
help();
return 0;
}
if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
help();
return 0;
}
// the last option should always be the VP file that we want
fp_in = fopen(argv[argc-1], "rb");
if (fp_in == NULL)
print_error(ERR_NO_FP_IN);
// if the header is invalid then read_header() should exit us out
read_header();
// TODO: add filter based extraction
for (int i = 1; i < argc-1; i++) {
if (!strcmp(argv[i], "-x") || !strcmp(argv[i], "--extract")) {
if (list) {
help();
exit(0);
}
extract = 1;
} else if (!strcmp(argv[i], "-L") || !strcmp(argv[i], "--lowercase")) {
lc = 1;
} else if (!strcmp(argv[i], "-l") || !strcmp(argv[i], "--list")) {
if (extract) {
help();
exit(0);
}
list = 1;
} else {
help();
return 0;
}
}
// read the file index, make all filenames lowercase if wanted
read_index( lc );
if (extract) {
extract_all_files( argv[argc-1] );
return 0;
} else if (list) {
list_all_files( argv[argc-1] );
return 0;
} else {
// if only -L is specified or no command is specified then just list files
list_all_files( argv[argc-1] );
return 0;
}
return 0;
}
File diff suppressed because it is too large. Load diff
+6 -103
View File
@@ -11,83 +11,11 @@
/*
* $Logfile: /Freespace2/code/Cmdline/cmdline.h $
* $Revision: 2.73 $
* $Date: 2005-07-25 05:24:16 $
* $Author: Goober5000 $
* $Revision: 2.54 $
* $Date: 2004-04-26 18:23:47 $
* $Author: Kazan $
*
* $Log: not supported by cvs2svn $
* Revision 2.72 2005/07/13 02:50:49 Goober5000
* remove PreProcDefine #includes in FS2
* --Goober5000
*
* Revision 2.71 2005/07/07 16:32:33 taylor
* compiler warning fixes
* add -noibx troubleshooting cmdline option to disable use of IBX files
* don't try to set thuster object number is only one thruster bank is specified (default method should go into affect)
*
* Revision 2.70 2005/06/29 18:46:13 taylor
* add option to not scale up movies to fit window/screen, default is to scale
* (arguably not a bug but I said I would get it in before 3.6.5 and forgot)
*
* Revision 2.69 2005/03/13 23:07:35 taylor
* enable 32-bit to 16-bit TGA conversion with -tga16 cmdline option (experimental)
* fix crash when upgrading from original campaign stats file to current
*
* Revision 2.68 2005/02/16 10:00:13 wmcoolmon
* "-ingame" command line option
*
* Revision 2.67 2005/01/30 12:50:08 taylor
* merge with Linux/OSX tree - p0130
*
* Revision 2.66 2005/01/29 16:30:46 phreak
* smart shield command line stuff. this will be changed in the future, but i want people to test it.
* -phreak
*
* Revision 2.65 2005/01/21 08:29:04 taylor
* add -rlm cmdline option to switch to local viewpoint lighting calculations (OGL only for now)
*
* Revision 2.64 2004/12/24 19:36:12 Goober5000
* resorted command-line options and added an option for WMC's ballistic gauge
* --Goober5000
*
* Revision 2.63 2004/11/23 19:29:13 taylor
* fix 2d warp in D3D, add cmdline option for 3d warp
*
* Revision 2.62 2004/09/10 13:51:20 et1
* Command line option for TBP for warp stuff, "-tbpwarpeffects"
*
* Revision 2.61 2004/08/11 05:06:19 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.60 2004/08/02 22:40:59 phreak
* added -orbradar to enable orb rendering for the radar
*
* Revision 2.59 2004/08/01 02:31:18 phreak
* -phreak command line changed to -dualscanlines
*
* Revision 2.58 2004/07/25 18:46:28 Kazan
* -fred_no_warn has become -no_warn and applies to both fred and fs2
* added new ai directive (last commit) and disabled afterburners while performing AIM_WAYPOINTS or AIM_FLY_TO_SHIP
* fixed player ship speed bug w/ player-use-ai, now stays in formation correctly and manages speed
* made -radar_reduce ignore itself if no parameter is given (ignoring launcher bug)
*
* Revision 2.57 2004/07/05 05:09:15 bobboau
* FVF code, only the data that is needed is sent off to the card,,
* OGL can take advantage of this if they want but it won't break
* anything if they don't. also state block code has been implemented,
* that's totaly internal to D3D no high level code is involved.
*
* Revision 2.56 2004/06/19 22:15:48 wmcoolmon
* Added -nomotion debris command line option; also re-ordered categories.
*
* Revision 2.55 2004/06/06 12:25:19 randomtiger
* Added new compression option -pcx32dds, build posted in RSB forum.
* Changed flag because of launcher bug, have fixed launcher bug, will distribute later.
* Also removed experimental flag from launcher flag list, stupid people were reporting bugs on unfinished code.
*
* Revision 2.54 2004/04/26 18:23:47 Kazan
* -no_fps_capping
*
* Revision 2.53 2004/04/26 00:23:26 taylor
* novbo and snd_preload cmdline options, fix moddir getting appended space
*
@@ -480,6 +408,7 @@
*
* $NoKeywords: $
*/
#ifndef FS_CMDLINE_HEADER_FILE
#define FS_CMDLINE_HEADER_FILE
@@ -525,16 +454,13 @@ extern int Cmdline_window;
extern char *Cmdline_almission; //DTP for autoload mission
extern int Cmdline_gf4fix; //DTP for Random tigers GF4fix.
extern int Cmdline_allslev;
extern int Cmdline_dualscanlines;
extern int Cmdline_phreak;
extern int Cmdline_dnoshowvid; //WMC Toggles movie playing support
extern int Cmdline_noscalevid; // disables fit-to-window for movies - taylor
extern char *Cmdline_mod; //DTP for mod support
extern int Cmdline_show_fps;//DTP moved here because it is the correct place for it to be.
extern int Cmdline_show_stats;
extern int Cmdline_safeloading;
extern int Cmdline_nospec;
extern int Cmdline_orb_radar;
extern int Cmdline_TBPWarpEffects; // TBP warp effects -Et1
extern int Cmdline_cache_ani;
extern int Cmdline_d3dmipmap;
@@ -554,14 +480,6 @@ extern int Cmdline_jpgtga;
extern int Cmdline_no_set_gamma;
extern int Cmdline_d3d_no_vsync;
extern int Cmdline_pcx32;
extern int Cmdline_pcx32dds;
extern int Cmdline_nomotiondebris;
extern int Cmdline_rlm;
extern int Cmdline_noibx;
#ifdef SCP_UNIX
extern int Cmdline_no_grab;
#endif
extern int Cmdline_noglow;
extern int Cmdline_timerbar;
@@ -572,34 +490,19 @@ extern int Cmdline_d3d_particle;
extern int Cmdline_ambient_factor;
extern int Cmdline_show_mem_usage;
extern int Cmdline_rt;
extern int Cmdline_ingamejoin;
extern char *Cmdline_start_mission;
extern int Cmdline_d3d_lesstmem;
extern int Cmdline_batch_3dunlit;
extern int Cmdline_2d_poof;
extern int Cmdline_3dwarp;
extern int Cmdline_FRED2_htl;
extern int CmdLine_NoWarn;
extern int CmdLine_FRED2_NoWarn;
extern int Cmdline_novbo;
extern int Cmdline_snd_preload;
extern int Cmdline_NoFPSCap;
extern float Cmdline_max_subdivide;
extern int Cmdline_alpha_env;
extern int Cmdline_env;
extern int Cmdline_decals;
extern int Cmdline_ballistic_gauge;
extern int Cmdline_smart_shields;
extern int Cmdline_tga16;
extern int Cmdline_wcsaga;
//extern char FreeSpace_Directory[]; // allievating a cfilesystem problem caused by fred -- Kazan
#endif
+5 -17
View File
@@ -9,23 +9,13 @@
/*
* $Logfile: /Freespace2/code/CMeasure/CMeasure.cpp $
* $Revision: 2.6 $
* $Date: 2005-04-05 05:53:15 $
* $Author: taylor $
* $Revision: 2.3 $
* $Date: 2004-03-05 09:01:57 $
* $Author: Goober5000 $
*
* Counter measures. Created by Mike Kulas, May 12, 1997.
*
* $Log: not supported by cvs2svn $
* Revision 2.5 2004/07/26 20:47:25 Kazan
* remove MCD complete
*
* Revision 2.4 2004/07/12 16:32:43 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.3 2004/03/05 09:01:57 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.2 2003/03/18 10:07:00 unknownplayer
* The big DX/main line merge. This has been uploaded to the main CVS since I can't manage to get it to upload to the DX branch. Apologies to all who may be affected adversely, but I'll work to debug it as fast as I can.
*
@@ -238,8 +228,6 @@
#include "math/staticrand.h"
#include "object/object.h"
cmeasure_info Cmeasure_info[MAX_CMEASURE_TYPES];
cmeasure Cmeasures[MAX_CMEASURES];
@@ -372,7 +360,7 @@ float Skill_level_cmeasure_life_scale[NUM_SKILL_LEVELS] = {3.0f, 2.0f, 1.5f, 1.2
// creates one countermeasure. A ship fires 1 of these per launch. rand_val is used
// in multiplayer. If -1, then create a random number. If non-negative, use this
// number for static_rand functions
int cmeasure_create( object * source_obj, vec3d * pos, int cm_type, int rand_val )
int cmeasure_create( object * source_obj, vector * pos, int cm_type, int rand_val )
{
int n, objnum, parent_objnum, arand;
object * obj;
@@ -442,7 +430,7 @@ int cmeasure_create( object * source_obj, vec3d * pos, int cm_type, int rand_val
Num_cmeasures++;
vec3d vel, rand_vec;
vector vel, rand_vec;
vm_vec_scale_add(&vel, &source_obj->phys_info.vel, &source_obj->orient.vec.fvec, -25.0f);
+4 -14
View File
@@ -9,23 +9,13 @@
/*
* $Logfile: /Freespace2/code/CMeasure/CMeasure.h $
* $Revision: 2.5 $
* $Date: 2005-07-13 02:50:50 $
* $Revision: 2.2 $
* $Date: 2004-03-05 09:01:57 $
* $Author: Goober5000 $
*
* Counter measures. Created by Mike Kulas, May 12, 1997.
*
* $Log: not supported by cvs2svn $
* Revision 2.4 2005/04/05 05:53:15 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.3 2004/08/11 05:06:19 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.2 2004/03/05 09:01:57 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.1 2002/08/01 01:41:04 penguin
* The big include file move
*
@@ -131,7 +121,7 @@
#include "globalincs/globals.h"
struct object;
struct vec3d;
struct vector;
#define MAX_CMEASURES 64
@@ -182,7 +172,7 @@ extern void cmeasure_render( object * obj );
extern void cmeasure_delete( object * obj );
extern void cmeasure_process_pre( object * obj, float frame_time);
extern void cmeasure_process_post( object * obj, float frame_time);
extern int cmeasure_create( object * source_obj, vec3d *pos, int cm_type, int rand_val = -1 );
extern int cmeasure_create( object * source_obj, vector *pos, int cm_type, int rand_val = -1 );
extern void cmeasure_select_next(object *objp);
#endif // _CMEASURE_H
File diff suppressed because it is too large. Load diff
+45 -101
View File
@@ -9,54 +9,13 @@
/*
* $Logfile: /Freespace2/code/ControlConfig/ControlsConfig.cpp $
* $Revision: 2.17 $
* $Date: 2005-07-22 10:18:37 $
* $Revision: 2.5 $
* $Date: 2004-03-05 09:01:58 $
* $Author: Goober5000 $
*
* C module for keyboard, joystick and mouse configuration
*
* $Log: not supported by cvs2svn $
* Revision 2.16 2005/07/13 02:50:50 Goober5000
* remove PreProcDefine #includes in FS2
* --Goober5000
*
* Revision 2.15 2005/07/07 16:36:57 taylor
* various compiler warning fixes (some of these from dizzy)
*
* Revision 2.14 2005/07/02 19:42:14 taylor
* ton of non-standard resolution fixes
*
* Revision 2.13 2005/05/12 17:49:11 taylor
* use vm_malloc(), vm_free(), vm_realloc(), vm_strdup() rather than system named macros
* fixes various problems and is past time to make the switch
*
* Revision 2.12 2005/04/28 05:29:28 wmcoolmon
* Removed FS2_DEMO defines that looked like they wouldn't cause the universe to collapse
*
* Revision 2.11 2005/04/17 05:38:28 taylor
* updated Linux joystick code that's a bit less insane speed wise
* remove ability to build without joystick support, no reason to keep it around
* fix unusable warning flag with libjpeg building
*
* Revision 2.10 2005/03/02 21:24:43 taylor
* more network/inferno goodness for Windows, takes care of a few warnings too
*
* Revision 2.9 2004/07/29 19:37:50 Kazan
* unbug the JS bug i caused --- kazan
*
* Revision 2.8 2004/07/26 20:47:26 Kazan
* remove MCD complete
*
* Revision 2.7 2004/07/25 00:31:28 Kazan
* i have absolutely nothing to say about that subject
*
* Revision 2.6 2004/07/12 16:32:43 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.5 2004/03/05 09:01:58 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.4 2003/11/11 02:15:43 Goober5000
* ubercommit - basically spelling and language fixes with some additional
* warnings disabled
@@ -365,7 +324,6 @@
*
*/
#include "freespace2/freespace.h"
#include "controlconfig/controlsconfig.h"
#include "gamesequence/gamesequence.h"
@@ -392,8 +350,6 @@
#include "hud/hud.h"
#endif
#define NUM_SYSTEM_KEYS 14
#define NUM_BUTTONS 19
#define NUM_TABS 4
@@ -762,8 +718,6 @@ int control_config_detect_axis()
int control_config_valid_action(int n)
{
//WMC - Invalid_demo_keys is never even filled!!
/*
#ifdef FS2_DEMO
int i;
@@ -771,7 +725,7 @@ int control_config_valid_action(int n)
if (n == Invalid_demo_keys[i])
return 0;
#endif
*/
return 1;
}
@@ -877,13 +831,7 @@ void control_config_list_prepare()
if ((Control_config[z].tab == Tab) && control_config_valid_action(z)) {
k = Control_config[z].key_id;
j = Control_config[z].joy_id;
if (Control_config[z].hasXSTR)
Cc_lines[Num_cc_lines].label = XSTR(Control_config[z].text, CONTROL_CONFIG_XSTR + z);
else
Cc_lines[Num_cc_lines].label = Control_config[z].text;
Cc_lines[Num_cc_lines].label = XSTR(Control_config[z].text, CONTROL_CONFIG_XSTR + z);
Cc_lines[Num_cc_lines].cc_index = z;
Cc_lines[Num_cc_lines++].y = y;
y += font_height + 2;
@@ -923,16 +871,16 @@ config_item_undo *get_undo_block(int size)
{
config_item_undo *ptr;
ptr = (config_item_undo *) vm_malloc( sizeof(config_item_undo) );
ptr = (config_item_undo *) malloc( sizeof(config_item_undo) );
Assert(ptr);
ptr->next = Config_item_undo;
Config_item_undo = ptr;
ptr->size = size;
if (size) {
ptr->index = (int *) vm_malloc( sizeof(int) * size );
ptr->index = (int *) malloc( sizeof(int) * size );
Assert(ptr->index);
ptr->list = (config_item *) vm_malloc( sizeof(config_item) * size );
ptr->list = (config_item *) malloc( sizeof(config_item) * size );
Assert(ptr->list);
} else {
@@ -954,11 +902,11 @@ void free_undo_block()
Config_item_undo = ptr->next;
if (ptr->size) {
vm_free(ptr->list);
vm_free(ptr->index);
free(ptr->list);
free(ptr->index);
}
vm_free(ptr);
free(ptr);
}
// undo the most recent binding changes
@@ -1017,9 +965,8 @@ void control_config_save_axis_undo(int axis)
config_item_undo *ptr;
config_item item;
memset( &item, 0, sizeof(config_item) );
item.joy_id = (short) Axis_map_to[axis];
item.used = 0;
item.used = Invert_axis[axis];
ptr = get_undo_block(1);
@@ -1135,8 +1082,6 @@ int control_config_clear_other()
ptr = get_undo_block(total);
for (i=j=0; i<NUM_JOY_AXIS_ACTIONS; i++)
if ((Axis_map_to[i] == Axis_map_to[z]) && (i != z)) {
memset( &item, 0, sizeof(config_item) );
item.joy_id = (short) Axis_map_to[i];
item.used = Invert_axis[i];
@@ -1225,12 +1170,15 @@ int control_config_clear_all()
return 0;
}
#ifndef NO_JOYSTICK
extern Joy_info joystick;
#endif
int control_config_axis_default(int axis)
{
Assert(axis >= 0);
#ifndef NO_JOYSTICK
if ( axis > 1 ) {
if (Axis_map_to_defaults[axis] < 0)
return -1;
@@ -1240,6 +1188,9 @@ int control_config_axis_default(int axis)
}
return Axis_map_to_defaults[axis];
#else
return -1;
#endif
}
int control_config_do_reset()
@@ -1274,8 +1225,6 @@ int control_config_do_reset()
for (i=0; i<NUM_JOY_AXIS_ACTIONS; i++)
if ((Axis_map_to[i] != control_config_axis_default(i)) || (Invert_axis[i] != Invert_axis_defaults[i])) {
memset( &item, 0, sizeof(config_item) );
item.joy_id = (short) Axis_map_to[i];
item.used = Invert_axis[i];
@@ -1613,7 +1562,7 @@ void control_config_init()
Control_config_backup[i] = Control_config[i];
common_set_interface_palette(NOX("ControlConfigPalette")); // set the interface palette
Ui_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0);
Ui_window.create(0, 0, gr_screen.max_w, gr_screen.max_h, 0);
Ui_window.set_mask_bmap(Conflict_background_bitmap_mask_fname[gr_screen.res]);
Ui_window.tooltip_handler = control_config_tooltip_handler;
@@ -1678,26 +1627,26 @@ void control_config_init()
control_config_conflict_check();
// setup strings
Joy_axis_action_text[0] = vm_strdup(XSTR("Turn (Yaw) Axis", 1016));
Joy_axis_action_text[1] = vm_strdup(XSTR("Pitch Axis", 1017));
Joy_axis_action_text[2] = vm_strdup(XSTR("Bank Axis", 1018));
Joy_axis_action_text[3] = vm_strdup(XSTR("Absolute Throttle Axis", 1019));
Joy_axis_action_text[4] = vm_strdup(XSTR("Relative Throttle Axis", 1020));
Joy_axis_text[0] = vm_strdup(XSTR("Joystick/Mouse X Axis", 1021));
Joy_axis_text[1] = vm_strdup(XSTR("Joystick/Mouse Y Axis", 1022));
Joy_axis_text[2] = vm_strdup(XSTR("Joystick Z Axis", 1023));
Joy_axis_text[3] = vm_strdup(XSTR("Joystick rX Axis", 1024));
Joy_axis_text[4] = vm_strdup(XSTR("Joystick rY Axis", 1025));
Joy_axis_text[5] = vm_strdup(XSTR("Joystick rZ Axis", 1026));
Mouse_button_text[0] = vm_strdup("");
Mouse_button_text[1] = vm_strdup(XSTR("Left Button", 1027));
Mouse_button_text[2] = vm_strdup(XSTR("Right Button", 1028));
Mouse_button_text[3] = vm_strdup(XSTR("Mid Button", 1029));
Mouse_button_text[4] = vm_strdup("");
Mouse_axis_text[0] = vm_strdup(XSTR("L/R", 1030));
Mouse_axis_text[1] = vm_strdup(XSTR("U/B", 1031));
Invert_text[0] = vm_strdup(XSTR("N", 1032));
Invert_text[1] = vm_strdup(XSTR("Y", 1033));
Joy_axis_action_text[0] = strdup(XSTR("Turn (Yaw) Axis", 1016));
Joy_axis_action_text[1] = strdup(XSTR("Pitch Axis", 1017));
Joy_axis_action_text[2] = strdup(XSTR("Bank Axis", 1018));
Joy_axis_action_text[3] = strdup(XSTR("Absolute Throttle Axis", 1019));
Joy_axis_action_text[4] = strdup(XSTR("Relative Throttle Axis", 1020));
Joy_axis_text[0] = strdup(XSTR("Joystick/Mouse X Axis", 1021));
Joy_axis_text[1] = strdup(XSTR("Joystick/Mouse Y Axis", 1022));
Joy_axis_text[2] = strdup(XSTR("Joystick Z Axis", 1023));
Joy_axis_text[3] = strdup(XSTR("Joystick rX Axis", 1024));
Joy_axis_text[4] = strdup(XSTR("Joystick rY Axis", 1025));
Joy_axis_text[5] = strdup(XSTR("Joystick rZ Axis", 1026));
Mouse_button_text[0] = strdup("");
Mouse_button_text[1] = strdup(XSTR("Left Button", 1027));
Mouse_button_text[2] = strdup(XSTR("Right Button", 1028));
Mouse_button_text[3] = strdup(XSTR("Mid Button", 1029));
Mouse_button_text[4] = strdup("");
Mouse_axis_text[0] = strdup(XSTR("L/R", 1030));
Mouse_axis_text[1] = strdup(XSTR("U/B", 1031));
Invert_text[0] = strdup(XSTR("N", 1032));
Invert_text[1] = strdup(XSTR("Y", 1033));
control_config_list_prepare();
}
@@ -1714,7 +1663,7 @@ void control_config_close()
help_overlay_unload(CONTROL_CONFIG_OVERLAY);
if (Background_bitmap){
bm_release(Background_bitmap);
bm_unload(Background_bitmap);
}
Ui_window.destroy();
@@ -1726,31 +1675,31 @@ void control_config_close()
// free strings
for(idx=0; idx<NUM_JOY_AXIS_ACTIONS; idx++){
if(Joy_axis_action_text[idx] != NULL){
vm_free(Joy_axis_action_text[idx]);
free(Joy_axis_action_text[idx]);
Joy_axis_action_text[idx] = NULL;
}
}
for(idx=0; idx<NUM_AXIS_TEXT; idx++){
if(Joy_axis_text[idx] != NULL){
vm_free(Joy_axis_text[idx]);
free(Joy_axis_text[idx]);
Joy_axis_text[idx] = NULL;
}
}
for(idx=0; idx<NUM_MOUSE_TEXT; idx++){
if(Mouse_button_text[idx] != NULL){
vm_free(Mouse_button_text[idx]);
free(Mouse_button_text[idx]);
Mouse_button_text[idx] = NULL;
}
}
for(idx=0; idx<NUM_MOUSE_AXIS_TEXT; idx++){
if(Mouse_axis_text[idx] != NULL){
vm_free(Mouse_axis_text[idx]);
free(Mouse_axis_text[idx]);
Mouse_axis_text[idx] = NULL;
}
}
for(idx=0; idx<NUM_INVERT_TEXT; idx++){
if(Invert_text[idx] != NULL){
vm_free(Invert_text[idx]);
free(Invert_text[idx]);
Invert_text[idx] = NULL;
}
}
@@ -2245,11 +2194,7 @@ void control_config_do_frame(float frametime)
gr_get_string_size(&w, NULL, str);
gr_printf(x - w / 2, y - font_height, str);
if (Control_config[i].hasXSTR)
strcpy(buf, XSTR(Control_config[i].text, CONTROL_CONFIG_XSTR + i));
else
strcpy(buf, Control_config[i].text);
strcpy(buf, XSTR(Control_config[i].text, CONTROL_CONFIG_XSTR + i));
gr_force_fit_string(buf, 255, Conflict_wnd_coords[gr_screen.res][CONTROL_W_COORD]);
gr_get_string_size(&w, NULL, buf);
gr_printf(x - w / 2, y, buf);
@@ -2521,7 +2466,6 @@ int check_control(int id, int key)
}
if ((Control_config[id].key_id == key) || joy_down_count(Control_config[id].joy_id, 1) || mouse_down_count(1 << Control_config[id].joy_id)) {
//mprintf(("Key used %d", key));
control_used(id);
return 1;
}
+11 -30
View File
@@ -9,34 +9,13 @@
/*
* $Logfile: /Freespace2/code/ControlConfig/ControlsConfig.h $
* $Revision: 2.13 $
* $Date: 2005-07-13 02:50:50 $
* $Author: Goober5000 $
* $Revision: 2.7 $
* $Date: 2004-05-03 21:22:19 $
* $Author: Kazan $
*
* Header file for keyboard, joystick and mouse configuration
*
* $Log: not supported by cvs2svn $
* Revision 2.12 2005/07/13 02:30:52 Goober5000
* removed autopilot #define
* --Goober5000
*
* Revision 2.11 2005/03/03 06:05:27 wmcoolmon
* Merge of WMC's codebase. "Features and bugs, making Goober say "Grr!", as release would be stalled now for two months for sure"
*
* Revision 2.10 2005/01/16 22:39:08 wmcoolmon
* Added VM_TOPDOWN view; Added 2D mission mode, add 16384 to mission +Flags to use.
*
* Revision 2.9 2004/08/11 05:06:19 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.8 2004/07/25 00:31:28 Kazan
* i have absolutely nothing to say about that subject
*
* Revision 2.7 2004/05/03 21:22:19 Kazan
* Abandon strdup() usage for mod list processing - it was acting odd and causing crashing on free()
* Fix condition where alt_tab_pause() would flipout and trigger failed assert if game minimizes during startup (like it does a lot during debug)
* Nav Point / Auto Pilot code (All disabled via #ifdefs)
*
* Revision 2.6 2004/04/06 03:09:01 phreak
* added a control config option for the wireframe hud targetbox i enabled ages ago
*
@@ -338,7 +317,6 @@ typedef struct config_item {
short key_default; // default key bound to action
short joy_default; // default joystick button bound to action
char tab; // what tab (category) it belongs in
bool hasXSTR; // whether we should translate this with an XSTR
char *text; // describes the action in the config screen
char type; // manner control should be checked in
short key_id; // actual key bound to action
@@ -497,15 +475,18 @@ typedef struct config_item {
#define UP_SLIDE_THRUST 110
#define DOWN_SLIDE_THRUST 111
#define HUD_TARGETBOX_TOGGLE_WIREFRAME 112
#define VIEW_TOPDOWN 113
#define VIEW_TRACK_TARGET 114
#if defined(ENABLE_AUTO_PILOT)
//AutoPilot - Kazan
#define AUTO_PILOT_TOGGLE 115
#define NAV_CYCLE 116
#define AUTO_PILOT_TOGGLE 113
#define NAV_CYCLE 114
// this should be the total number of control action defines above (or last define + 1)
#define CCFG_MAX 117
#define CCFG_MAX 115
#else
#define CCFG_MAX 113
#endif
extern int Failed_key_index;
extern int Invert_heading;
@@ -9,33 +9,13 @@
/*
* $Logfile: /Freespace2/code/ControlConfig/ControlsConfigCommon.cpp $
* $Revision: 2.12 $
* $Date: 2005-07-13 02:30:52 $
* $Author: Goober5000 $
* $Revision: 2.6 $
* $Date: 2004-05-03 21:22:19 $
* $Author: Kazan $
*
* C module for keyboard, joystick and mouse configuration common stuff (between Fred and FreeSpace)
*
* $Log: not supported by cvs2svn $
* Revision 2.11 2005/03/03 06:05:27 wmcoolmon
* Merge of WMC's codebase. "Features and bugs, making Goober say "Grr!", as release would be stalled now for two months for sure"
*
* Revision 2.10 2005/01/16 22:39:08 wmcoolmon
* Added VM_TOPDOWN view; Added 2D mission mode, add 16384 to mission +Flags to use.
*
* Revision 2.9 2004/07/26 20:47:26 Kazan
* remove MCD complete
*
* Revision 2.8 2004/07/25 00:31:28 Kazan
* i have absolutely nothing to say about that subject
*
* Revision 2.7 2004/07/12 16:32:43 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.6 2004/05/03 21:22:19 Kazan
* Abandon strdup() usage for mod list processing - it was acting odd and causing crashing on free()
* Fix condition where alt_tab_pause() would flipout and trigger failed assert if game minimizes during startup (like it does a lot during debug)
* Nav Point / Auto Pilot code (All disabled via #ifdefs)
*
* Revision 2.5 2004/04/06 03:09:01 phreak
* added a control config option for the wireframe hud targetbox i enabled ages ago
*
@@ -418,7 +398,6 @@
#include "io/joy.h"
#include "localization/localize.h"
#define TARGET_TAB 0
#define SHIP_TAB 1
#define WEAPON_TAB 2
@@ -441,155 +420,155 @@ int Invert_axis_defaults[JOY_NUM_AXES] = { 0, 0, 0, 0, 0, 0 };
//XSTR:OFF
config_item Control_config[CCFG_MAX + 1] = {
// targeting a ship
{ KEY_T, -1, TARGET_TAB, true, "Target Next Ship" },
{ KEY_SHIFTED | KEY_T, -1, TARGET_TAB, true, "Target Previous Ship" },
{ KEY_H, 2, TARGET_TAB, true, "Target Next Closest Hostile Ship" },
{ KEY_SHIFTED | KEY_H, -1, TARGET_TAB, true, "Target Previous Closest Hostile Ship" },
{ KEY_ALTED | KEY_H, -1, TARGET_TAB, true, "Toggle Auto Targeting" },
{ KEY_F, -1, TARGET_TAB, true, "Target Next Closest Friendly Ship" },
{ KEY_SHIFTED | KEY_F, -1, TARGET_TAB, true, "Target Previous Closest Friendly Ship" },
{ KEY_Y, 4, TARGET_TAB, true, "Target Ship in Reticle" },
{ KEY_G, -1, TARGET_TAB, true, "Target Target's Nearest Attacker" },
{ KEY_ALTED | KEY_Y, -1, TARGET_TAB, true, "Target Last Ship to Send Transmission" },
{ KEY_ALTED | KEY_T, -1, TARGET_TAB, true, "Turn Off Auto-Targeting" },
{ KEY_T, -1, TARGET_TAB, "Target Next Ship" },
{ KEY_SHIFTED | KEY_T, -1, TARGET_TAB, "Target Previous Ship" },
{ KEY_H, 2, TARGET_TAB, "Target Next Closest Hostile Ship" },
{ KEY_SHIFTED | KEY_H, -1, TARGET_TAB, "Target Previous Closest Hostile Ship" },
{ KEY_ALTED | KEY_H, -1, TARGET_TAB, "Toggle Auto Targeting" },
{ KEY_F, -1, TARGET_TAB, "Target Next Closest Friendly Ship" },
{ KEY_SHIFTED | KEY_F, -1, TARGET_TAB, "Target Previous Closest Friendly Ship" },
{ KEY_Y, 4, TARGET_TAB, "Target Ship in Reticle" },
{ KEY_G, -1, TARGET_TAB, "Target Target's Nearest Attacker" },
{ KEY_ALTED | KEY_Y, -1, TARGET_TAB, "Target Last Ship to Send Transmission" },
{ KEY_ALTED | KEY_T, -1, TARGET_TAB, "Turn Off Auto-Targeting" },
// targeting a ship's subsystem
{ KEY_V, -1, TARGET_TAB, true, "Target Subsystem in Reticle" },
{ KEY_S, -1, TARGET_TAB, true, "Target Next Subsystem" },
{ KEY_SHIFTED | KEY_S, -1, TARGET_TAB, true, "Target Previous Subsystem" },
{ KEY_ALTED | KEY_S, -1, TARGET_TAB, true, "Turn Off Auto-Targeting of Subsystems" },
{ KEY_V, -1, TARGET_TAB, "Target Subsystem in Reticle" },
{ KEY_S, -1, TARGET_TAB, "Target Next Subsystem" },
{ KEY_SHIFTED | KEY_S, -1, TARGET_TAB, "Target Previous Subsystem" },
{ KEY_ALTED | KEY_S, -1, TARGET_TAB, "Turn Off Auto-Targeting of Subsystems" },
// matching speed
{ KEY_M, -1, COMPUTER_TAB, true, "Match Target Speed" },
{ KEY_ALTED | KEY_M, -1, COMPUTER_TAB, true, "Toggle Auto Speed Matching" },
{ KEY_M, -1, COMPUTER_TAB, "Match Target Speed" },
{ KEY_ALTED | KEY_M, -1, COMPUTER_TAB, "Toggle Auto Speed Matching" },
// weapons
{ KEY_LCTRL, 0, WEAPON_TAB, true, "Fire Primary Weapon", CC_TYPE_CONTINUOUS },
{ KEY_SPACEBAR, 1, WEAPON_TAB, true, "Fire Secondary Weapon", CC_TYPE_CONTINUOUS },
{ KEY_PERIOD, -1, WEAPON_TAB, true, "Cycle Forward Primary Weapon" },
{ KEY_COMMA, -1, WEAPON_TAB, true, "Cycle Backward Primary Weapon" },
{ KEY_DIVIDE, -1, WEAPON_TAB, true, "Cycle Secondary Weapon Bank" },
{ KEY_SHIFTED | KEY_DIVIDE, -1, WEAPON_TAB, true, "Cycle Secondary Weapon Firing Rate" },
{ KEY_X, 3, WEAPON_TAB, true, "Launch Countermeasure" },
{ KEY_LCTRL, 0, WEAPON_TAB, "Fire Primary Weapon", CC_TYPE_CONTINUOUS },
{ KEY_SPACEBAR, 1, WEAPON_TAB, "Fire Secondary Weapon", CC_TYPE_CONTINUOUS },
{ KEY_PERIOD, -1, WEAPON_TAB, "Cycle Forward Primary Weapon" },
{ KEY_COMMA, -1, WEAPON_TAB, "Cycle Backward Primary Weapon" },
{ KEY_DIVIDE, -1, WEAPON_TAB, "Cycle Secondary Weapon Bank" },
{ KEY_SHIFTED | KEY_DIVIDE, -1, WEAPON_TAB, "Cycle Secondary Weapon Firing Rate" },
{ KEY_X, 3, WEAPON_TAB, "Launch Countermeasure" },
// controls
{ KEY_A, -1, SHIP_TAB, true, "Forward Thrust", CC_TYPE_CONTINUOUS },
{ KEY_Z, -1, SHIP_TAB, true, "Reverse Thrust", CC_TYPE_CONTINUOUS },
{ KEY_PAD7, -1, SHIP_TAB, true, "Bank Left", CC_TYPE_CONTINUOUS },
{ KEY_PAD9, -1, SHIP_TAB, true, "Bank Right", CC_TYPE_CONTINUOUS },
{ KEY_PAD8, -1, SHIP_TAB, true, "Pitch Forward", CC_TYPE_CONTINUOUS },
{ KEY_PAD2, -1, SHIP_TAB, true, "Pitch Backward", CC_TYPE_CONTINUOUS },
{ KEY_PAD4, -1, SHIP_TAB, true, "Turn Left", CC_TYPE_CONTINUOUS },
{ KEY_PAD6, -1, SHIP_TAB, true, "Turn Right", CC_TYPE_CONTINUOUS },
{ KEY_A, -1, SHIP_TAB, "Forward Thrust", CC_TYPE_CONTINUOUS },
{ KEY_Z, -1, SHIP_TAB, "Reverse Thrust", CC_TYPE_CONTINUOUS },
{ KEY_PAD7, -1, SHIP_TAB, "Bank Left", CC_TYPE_CONTINUOUS },
{ KEY_PAD9, -1, SHIP_TAB, "Bank Right", CC_TYPE_CONTINUOUS },
{ KEY_PAD8, -1, SHIP_TAB, "Pitch Forward", CC_TYPE_CONTINUOUS },
{ KEY_PAD2, -1, SHIP_TAB, "Pitch Backward", CC_TYPE_CONTINUOUS },
{ KEY_PAD4, -1, SHIP_TAB, "Turn Left", CC_TYPE_CONTINUOUS },
{ KEY_PAD6, -1, SHIP_TAB, "Turn Right", CC_TYPE_CONTINUOUS },
// throttle controls
{ KEY_BACKSP, -1, SHIP_TAB, true, "Set Throttle to Zero" },
{ KEY_SLASH, -1, SHIP_TAB, true, "Set Throttle to Max" },
{ KEY_LBRACKET, -1, SHIP_TAB, true, "Set Throttle to One-Third" },
{ KEY_RBRACKET, -1, SHIP_TAB, true, "Set Throttle to Two-Thirds" },
{ KEY_EQUAL, -1, SHIP_TAB, true, "Increase Throttle 5 Percent" },
{ KEY_MINUS, -1, SHIP_TAB, true, "Decrease Throttle 5 Percent" },
{ KEY_BACKSP, -1, SHIP_TAB, "Set Throttle to Zero" },
{ KEY_SLASH, -1, SHIP_TAB, "Set Throttle to Max" },
{ KEY_LBRACKET, -1, SHIP_TAB, "Set Throttle to One-Third" },
{ KEY_RBRACKET, -1, SHIP_TAB, "Set Throttle to Two-Thirds" },
{ KEY_EQUAL, -1, SHIP_TAB, "Increase Throttle 5 Percent" },
{ KEY_MINUS, -1, SHIP_TAB, "Decrease Throttle 5 Percent" },
// squadmate messaging
{ KEY_SHIFTED | KEY_A, -1, COMPUTER_TAB, true, "Attack My Target" },
{ KEY_SHIFTED | KEY_Z, -1, COMPUTER_TAB, true, "Disarm My Target" },
{ KEY_SHIFTED | KEY_D, -1, COMPUTER_TAB, true, "Disable My Target" },
{ KEY_SHIFTED | KEY_V, -1, COMPUTER_TAB, true, "Attack my Subsystem" },
{ KEY_SHIFTED | KEY_X, -1, COMPUTER_TAB, true, "Capture My Target" },
{ KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, true, "Engage Enemy" },
{ KEY_SHIFTED | KEY_W, -1, COMPUTER_TAB, true, "Form on my Wing" },
{ KEY_SHIFTED | KEY_I, -1, COMPUTER_TAB, true, "Ignore my Target" },
{ KEY_SHIFTED | KEY_P, -1, COMPUTER_TAB, true, "Protect my Target" },
{ KEY_SHIFTED | KEY_C, -1, COMPUTER_TAB, true, "Cover me" },
{ KEY_SHIFTED | KEY_J, -1, COMPUTER_TAB, true, "Return to base" },
{ KEY_SHIFTED | KEY_R, -1, COMPUTER_TAB, true, "Rearm me" },
{ KEY_SHIFTED | KEY_A, -1, COMPUTER_TAB, "Attack My Target" },
{ KEY_SHIFTED | KEY_Z, -1, COMPUTER_TAB, "Disarm My Target" },
{ KEY_SHIFTED | KEY_D, -1, COMPUTER_TAB, "Disable My Target" },
{ KEY_SHIFTED | KEY_V, -1, COMPUTER_TAB, "Attack my Subsystem" },
{ KEY_SHIFTED | KEY_X, -1, COMPUTER_TAB, "Capture My Target" },
{ KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, "Engage Enemy" },
{ KEY_SHIFTED | KEY_W, -1, COMPUTER_TAB, "Form on my Wing" },
{ KEY_SHIFTED | KEY_I, -1, COMPUTER_TAB, "Ignore my Target" },
{ KEY_SHIFTED | KEY_P, -1, COMPUTER_TAB, "Protect my Target" },
{ KEY_SHIFTED | KEY_C, -1, COMPUTER_TAB, "Cover me" },
{ KEY_SHIFTED | KEY_J, -1, COMPUTER_TAB, "Return to base" },
{ KEY_SHIFTED | KEY_R, -1, COMPUTER_TAB, "Rearm me" },
{ KEY_R, 6, TARGET_TAB, true, "Target Closest Attacking Ship" },
{ KEY_R, 6, TARGET_TAB, "Target Closest Attacking Ship" },
// Views
{ KEY_PADMULTIPLY, -1, COMPUTER_TAB, true, "Chase View" },
{ KEY_PADPERIOD, -1, COMPUTER_TAB, true, "External View"},
{ KEY_PADENTER, -1, COMPUTER_TAB, true, "Toggle External Camera Lock"},
{ KEY_PAD0, -1, COMPUTER_TAB, true, "Free Look View", CC_TYPE_CONTINUOUS },
{ KEY_PADDIVIDE, -1, COMPUTER_TAB, true, "Current Target View" },
{ KEY_PADPLUS, -1, COMPUTER_TAB, true, "Increase View Distance", CC_TYPE_CONTINUOUS },
{ KEY_PADMINUS, -1, COMPUTER_TAB, true, "Decrease View Distance", CC_TYPE_CONTINUOUS },
{ KEY_PAD5, -1, COMPUTER_TAB, true, "Center View", CC_TYPE_CONTINUOUS },
{ -1, 33, COMPUTER_TAB, true, "View Up", CC_TYPE_CONTINUOUS },
{ -1, 32, COMPUTER_TAB, true, "View Rear", CC_TYPE_CONTINUOUS },
{ -1, 34, COMPUTER_TAB, true, "View Left", CC_TYPE_CONTINUOUS },
{ -1, 35, COMPUTER_TAB, true, "View Right", CC_TYPE_CONTINUOUS },
{ KEY_PADMULTIPLY, -1, COMPUTER_TAB, "Chase View" },
{ KEY_PADPERIOD, -1, COMPUTER_TAB, "External View"},
{ KEY_PADENTER, -1, COMPUTER_TAB, "Toggle External Camera Lock"},
{ KEY_PAD0, -1, COMPUTER_TAB, "Free Look View", CC_TYPE_CONTINUOUS },
{ KEY_PADDIVIDE, -1, COMPUTER_TAB, "Current Target View" },
{ KEY_PADPLUS, -1, COMPUTER_TAB, "Increase View Distance", CC_TYPE_CONTINUOUS },
{ KEY_PADMINUS, -1, COMPUTER_TAB, "Decrease View Distance", CC_TYPE_CONTINUOUS },
{ KEY_PAD5, -1, COMPUTER_TAB, "Center View", CC_TYPE_CONTINUOUS },
{ -1, 33, COMPUTER_TAB, "View Up", CC_TYPE_CONTINUOUS },
{ -1, 32, COMPUTER_TAB, "View Rear", CC_TYPE_CONTINUOUS },
{ -1, 34, COMPUTER_TAB, "View Left", CC_TYPE_CONTINUOUS },
{ -1, 35, COMPUTER_TAB, "View Right", CC_TYPE_CONTINUOUS },
{ KEY_RAPOSTRO, -1, COMPUTER_TAB, true, "Cycle Radar Range" },
{ KEY_C, -1, COMPUTER_TAB, true, "Communications Menu" },
{ -1, -1, -1, true, "Show Objectives" },
{ KEY_ALTED | KEY_J, -1, COMPUTER_TAB, true, "Enter Subspace (End Mission)" },
{ KEY_J, -1, TARGET_TAB, true, "Target Target's Target" },
{ KEY_TAB, 5, SHIP_TAB, true, "Afterburner", CC_TYPE_CONTINUOUS },
{ KEY_RAPOSTRO, -1, COMPUTER_TAB, "Cycle Radar Range" },
{ KEY_C, -1, COMPUTER_TAB, "Communications Menu" },
{ -1, -1, -1, "Show Objectives" },
{ KEY_ALTED | KEY_J, -1, COMPUTER_TAB, "Enter Subspace (End Mission)" },
{ KEY_J, -1, TARGET_TAB, "Target Target's Target" },
{ KEY_TAB, 5, SHIP_TAB, "Afterburner", CC_TYPE_CONTINUOUS },
{ KEY_INSERT, -1, COMPUTER_TAB, true, "Increase Weapon Energy" },
{ KEY_DELETE, -1, COMPUTER_TAB, true, "Decrease Weapon Energy" },
{ KEY_HOME, -1, COMPUTER_TAB, true, "Increase Shield Energy" },
{ KEY_END, -1, COMPUTER_TAB, true, "Decrease Shield Energy" },
{ KEY_PAGEUP, -1, COMPUTER_TAB, true, "Increase Engine Energy" },
{ KEY_PAGEDOWN, -1, COMPUTER_TAB, true, "Decrease Engine Energy" },
{ KEY_ALTED | KEY_D, -1, COMPUTER_TAB, true, "Equalize Energy Settings" },
{ KEY_INSERT, -1, COMPUTER_TAB, "Increase Weapon Energy" },
{ KEY_DELETE, -1, COMPUTER_TAB, "Decrease Weapon Energy" },
{ KEY_HOME, -1, COMPUTER_TAB, "Increase Shield Energy" },
{ KEY_END, -1, COMPUTER_TAB, "Decrease Shield Energy" },
{ KEY_PAGEUP, -1, COMPUTER_TAB, "Increase Engine Energy" },
{ KEY_PAGEDOWN, -1, COMPUTER_TAB, "Decrease Engine Energy" },
{ KEY_ALTED | KEY_D, -1, COMPUTER_TAB, "Equalize Energy Settings" },
{ KEY_Q, 7, COMPUTER_TAB, true, "Equalize Shield" },
{ KEY_UP, -1, COMPUTER_TAB, true, "Augment Forward Shield" },
{ KEY_DOWN, -1, COMPUTER_TAB, true, "Augment Rear Shield" },
{ KEY_LEFT, -1, COMPUTER_TAB, true, "Augment Left Shield" },
{ KEY_RIGHT, -1, COMPUTER_TAB, true, "Augment Right Shield" },
{ KEY_SCROLLOCK, -1, COMPUTER_TAB, true, "Transfer Energy Laser->Shield" },
{ KEY_SHIFTED | KEY_SCROLLOCK, -1, COMPUTER_TAB, true, "Transfer Energy Shield->Laser" },
{ -1, -1, -1, true, "Show Damage Popup Window" },
{ KEY_Q, 7, COMPUTER_TAB, "Equalize Shield" },
{ KEY_UP, -1, COMPUTER_TAB, "Augment Forward Shield" },
{ KEY_DOWN, -1, COMPUTER_TAB, "Augment Rear Shield" },
{ KEY_LEFT, -1, COMPUTER_TAB, "Augment Left Shield" },
{ KEY_RIGHT, -1, COMPUTER_TAB, "Augment Right Shield" },
{ KEY_SCROLLOCK, -1, COMPUTER_TAB, "Transfer Energy Laser->Shield" },
{ KEY_SHIFTED | KEY_SCROLLOCK, -1, COMPUTER_TAB, "Transfer Energy Shield->Laser" },
{ -1, -1, -1, "Show Damage Popup Window" },
{ -1, -1, SHIP_TAB, true, "Bank When Pressed", CC_TYPE_CONTINUOUS },
{ -1, -1, -1, true, "Show NavMap" },
{ KEY_ALTED | KEY_E, -1, COMPUTER_TAB, true, "Add or Remove Escort" },
{ KEY_ALTED | KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, true, "Clear Escort List" },
{ KEY_E, -1, TARGET_TAB, true, "Target Next Escort Ship" },
{ KEY_ALTED | KEY_R, -1, TARGET_TAB, true, "Target Closest Repair Ship" },
{ -1, -1, SHIP_TAB, "Bank When Pressed", CC_TYPE_CONTINUOUS },
{ -1, -1, -1, "Show NavMap" },
{ KEY_ALTED | KEY_E, -1, COMPUTER_TAB, "Add or Remove Escort" },
{ KEY_ALTED | KEY_SHIFTED | KEY_E, -1, COMPUTER_TAB, "Clear Escort List" },
{ KEY_E, -1, TARGET_TAB, "Target Next Escort Ship" },
{ KEY_ALTED | KEY_R, -1, TARGET_TAB, "Target Closest Repair Ship" },
{ KEY_U, -1, TARGET_TAB, true, "Target Next Uninspected Cargo" },
{ KEY_SHIFTED | KEY_U, -1, TARGET_TAB, true, "Target Previous Uninspected Cargo" },
{ KEY_N, -1, TARGET_TAB, true, "Target Newest Ship In Area" },
{ KEY_K, -1, TARGET_TAB, true, "Target Next Live Turret" },
{ KEY_SHIFTED | KEY_K, -1, TARGET_TAB, true, "Target Previous Live Turret" },
{ KEY_U, -1, TARGET_TAB, "Target Next Uninspected Cargo" },
{ KEY_SHIFTED | KEY_U, -1, TARGET_TAB, "Target Previous Uninspected Cargo" },
{ KEY_N, -1, TARGET_TAB, "Target Newest Ship In Area" },
{ KEY_K, -1, TARGET_TAB, "Target Next Live Turret" },
{ KEY_SHIFTED | KEY_K, -1, TARGET_TAB, "Target Previous Live Turret" },
{ KEY_B, -1, TARGET_TAB, true, "Target Next Hostile Bomb or Bomber" },
{ KEY_SHIFTED | KEY_B, -1, TARGET_TAB, true, "Target Previous Hostile Bomb or Bomber" },
{ KEY_B, -1, TARGET_TAB, "Target Next Hostile Bomb or Bomber" },
{ KEY_SHIFTED | KEY_B, -1, TARGET_TAB, "Target Previous Hostile Bomb or Bomber" },
// multiplayer messaging keys
{ KEY_1, -1, COMPUTER_TAB, true, "(Multiplayer) Message All", CC_TYPE_CONTINUOUS },
{ KEY_2, -1, COMPUTER_TAB, true, "(Multiplayer) Message Friendly", CC_TYPE_CONTINUOUS },
{ KEY_3, -1, COMPUTER_TAB, true, "(Multiplayer) Message Hostile", CC_TYPE_CONTINUOUS },
{ KEY_4, -1, COMPUTER_TAB, true, "(Multiplayer) Message Target", CC_TYPE_CONTINUOUS },
{ KEY_ALTED | KEY_X, -1, COMPUTER_TAB, true, "(Multiplayer) Observer zoom to target"},
{ KEY_1, -1, COMPUTER_TAB, "(Multiplayer) Message All", CC_TYPE_CONTINUOUS },
{ KEY_2, -1, COMPUTER_TAB, "(Multiplayer) Message Friendly", CC_TYPE_CONTINUOUS },
{ KEY_3, -1, COMPUTER_TAB, "(Multiplayer) Message Hostile", CC_TYPE_CONTINUOUS },
{ KEY_4, -1, COMPUTER_TAB, "(Multiplayer) Message Target", CC_TYPE_CONTINUOUS },
{ KEY_ALTED | KEY_X, -1, COMPUTER_TAB, "(Multiplayer) Observer zoom to target"},
{ KEY_SHIFTED | KEY_PERIOD, -1, COMPUTER_TAB, true, "Increase time compression" },
{ KEY_SHIFTED | KEY_COMMA, -1, COMPUTER_TAB, true, "Decrease time compression" },
{ KEY_SHIFTED | KEY_PERIOD, -1, COMPUTER_TAB, "Increase time compression" },
{ KEY_SHIFTED | KEY_COMMA, -1, COMPUTER_TAB, "Decrease time compression" },
{ KEY_L, -1, COMPUTER_TAB, true, "Toggle high HUD contrast" },
{ KEY_L, -1, COMPUTER_TAB, "Toggle high HUD contrast" },
{ KEY_SHIFTED | KEY_N, -1, COMPUTER_TAB, true, "(Multiplayer) Toggle network info"},
{ KEY_SHIFTED | KEY_END, -1, COMPUTER_TAB, true, "(Multiplayer) Self destruct"},
{ KEY_SHIFTED | KEY_N, -1, COMPUTER_TAB, "(Multiplayer) Toggle network info"},
{ KEY_SHIFTED | KEY_END, -1, COMPUTER_TAB, "(Multiplayer) Self destruct"},
// Misc
{ KEY_SHIFTED | KEY_O, -1, COMPUTER_TAB, true, "Toggle HUD"},
{ KEY_SHIFTED | KEY_3, -1, SHIP_TAB, true, "Right Thrust", CC_TYPE_CONTINUOUS},
{ KEY_SHIFTED | KEY_1, -1, SHIP_TAB, true, "Left Thrust", CC_TYPE_CONTINUOUS},
{ KEY_SHIFTED | KEY_PADPLUS, -1, SHIP_TAB, true, "Up Thrust", CC_TYPE_CONTINUOUS},
{ KEY_SHIFTED | KEY_PADENTER, -1, SHIP_TAB, true, "Down Thrust", CC_TYPE_CONTINUOUS},
{ KEY_ALTED | KEY_SHIFTED | KEY_Q, -1, COMPUTER_TAB, true, "Toggle HUD Wireframe Targetbox"},
{ -1, -1, COMPUTER_TAB, false, "Top-down View"},
{ -1, -1, COMPUTER_TAB, false, "Track targeted object", CC_TYPE_CONTINUOUS},
{ KEY_SHIFTED | KEY_O, -1, COMPUTER_TAB, "Toggle HUD"},
{ KEY_SHIFTED | KEY_3, -1, SHIP_TAB, "Right Thrust", CC_TYPE_CONTINUOUS},
{ KEY_SHIFTED | KEY_1, -1, SHIP_TAB, "Left Thrust", CC_TYPE_CONTINUOUS},
{ KEY_SHIFTED | KEY_PADPLUS, -1, SHIP_TAB, "Up Thrust", CC_TYPE_CONTINUOUS},
{ KEY_SHIFTED | KEY_PADENTER, -1, SHIP_TAB, "Down Thrust", CC_TYPE_CONTINUOUS},
{ KEY_ALTED | KEY_SHIFTED | KEY_Q, -1, COMPUTER_TAB, "Toggle HUD Wireframe Targetbox"},
#if defined(ENABLE_AUTO_PILOT)
// Auto Navigation Systen
{ KEY_ALTED | KEY_A, -1, COMPUTER_TAB, false, "Toggle Auto Pilot"},
{ KEY_ALTED | KEY_N, -1, COMPUTER_TAB, false, "Cycle Nav Points"},
{ KEY_ALTED | KEY_A, -1, COMPUTER_TAB, "Toggle Auto Pilot"},
{ KEY_ALTED | KEY_N, -1, COMPUTER_TAB, "Cycle Nav Points"},
#endif
{ -1, -1, -1, false, "" }
{ -1, -1, -1, "" }
};
char *Scan_code_text_german[] = {
+3 -13
View File
@@ -9,16 +9,13 @@
/*
* $Logfile: /Freespace2/code/Cryptstring/cryptstring.cpp $
* $Revision: 2.2 $
* $Date: 2005-09-08 00:09:32 $
* $Author: taylor $
* $Revision: 2.1 $
* $Date: 2002-08-01 01:41:04 $
* $Author: penguin $
*
* Applet for crypting strings.
*
* $Log: not supported by cvs2svn $
* Revision 2.1 2002/08/01 01:41:04 penguin
* The big include file move
*
* Revision 2.0 2002/06/03 04:02:21 penguin
* Warpcore CVS sync
*
@@ -36,13 +33,6 @@
#include <string.h>
#include "globalincs/crypt.h"
// we end up #include'ing SDL.h which on Windows and Mac will redfine main() which is something
// that we don't want since we don't actually link against SDL, this solves the problem...
#ifdef main
#undef main
#endif
int main(int argc, char **argv)
{
int i;
+18 -30
View File
@@ -9,35 +9,16 @@
/*
* $Logfile: /Freespace2/code/Cutscene/Cutscenes.cpp $
* $Revision: 2.17 $
* $Date: 2005-07-02 19:42:14 $
* $Revision: 2.11 $
* $Date: 2004-04-26 13:11:11 $
* $Author: taylor $
* $Revision: 2.17 $
* $Date: 2005-07-02 19:42:14 $
* $Revision: 2.11 $
* $Date: 2004-04-26 13:11:11 $
* $Author: taylor $
*
* Code for the cutscenes viewer screen
*
* $Log: not supported by cvs2svn $
* Revision 2.16 2005/05/12 17:49:11 taylor
* use vm_malloc(), vm_free(), vm_realloc(), vm_strdup() rather than system named macros
* fixes various problems and is past time to make the switch
*
* Revision 2.15 2005/02/23 04:51:55 taylor
* some bm_unload() -> bm_release() changes to save bmpman slots
*
* Revision 2.14 2005/01/31 23:27:51 taylor
* merge with Linux/OSX tree - p0131-2
*
* Revision 2.13 2004/07/26 20:47:26 Kazan
* remove MCD complete
*
* Revision 2.12 2004/07/12 16:32:43 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.11 2004/04/26 13:11:11 taylor
* mark view cutscenes ignoring extension and file case
*
* Revision 2.10 2004/03/05 09:01:58 Goober5000
* Uber pass at reducing #includes
* --Goober5000
@@ -238,7 +219,6 @@
#include "localization/localize.h"
#include "parse/parselo.h"
char *Cutscene_bitmap_name[GR_NUM_RESOLUTIONS] = {
"ViewFootage",
"2_ViewFootage"
@@ -256,7 +236,7 @@ cutscene_info Cutscenes[MAX_CUTSCENES];
//extern int All_movies_enabled; // If set, all movies may be viewed. Keyed off cheat code.
void cutsceen_close(){
for(int i = 0; i<MAX_CUTSCENES; i++)
if(Cutscenes[i].description)vm_free(Cutscenes[i].description);
if(Cutscenes[i].description)free(Cutscenes[i].description);
}
// initialization stuff for cutscenes
@@ -290,7 +270,7 @@ void cutscene_init()
stuff_string(buf, F_MULTITEXT, NULL);
drop_white_space(buf);
compact_multitext_string(buf);
Cutscenes[Num_cutscenes].description = vm_strdup(buf);
Cutscenes[Num_cutscenes].description = strdup(buf);
required_string("$cd:");
stuff_int( &Cutscenes[Num_cutscenes].cd );
@@ -309,6 +289,7 @@ void cutscene_init()
// returns -1 on failure.
int cutscenes_get_cd_num( char *filename )
{
#ifdef _WIN32
#if defined(OEM_BUILD)
return 0; // only 1 cd for OEM
#else
@@ -322,6 +303,9 @@ int cutscenes_get_cd_num( char *filename )
return -1;
#endif // defined(OEM_BUILD)
#else // !WIN32
return -1;
#endif // ifdef WIN32
}
// marks a cutscene as viewable
@@ -370,7 +354,7 @@ void cutscene_mark_viewable(char *filename)
static int Num_files;
static int Cutscene_list[MAX_CUTSCENES];
//static int Stats_scroll_offset; // not used - taylor
static int Stats_scroll_offset;
static int Selected_line = 0; // line that is currently selected for binding
static int Scroll_offset;
static int Background_bitmap;
@@ -458,6 +442,7 @@ static char *Text_lines[MAX_TEXT_LINES];
int cutscenes_validate_cd(char *mve_name, int prompt_for_cd)
{
#ifdef _WIN32
int cd_present = 0;
int cd_drive_num;
int cd_mve_is_on;
@@ -524,7 +509,10 @@ int cutscenes_validate_cd(char *mve_name, int prompt_for_cd)
}
return cd_present;
return cd_present;
#else // !WIN32
return 0;
#endif // ifdef WIN32
}
void cutscenes_screen_play()
@@ -662,7 +650,7 @@ void cutscenes_screen_init()
int i;
ui_button_info *b;
Ui_window.create(0, 0, gr_screen.max_w_unscaled, gr_screen.max_h_unscaled, 0);
Ui_window.create(0, 0, gr_screen.max_w, gr_screen.max_h, 0);
Ui_window.set_mask_bmap(Cutscene_mask_name[gr_screen.res]);
for (i=0; i<NUM_BUTTONS; i++) {
@@ -715,7 +703,7 @@ void cutscenes_screen_init()
void cutscenes_screen_close()
{
if (Background_bitmap)
bm_release(Background_bitmap);
bm_unload(Background_bitmap);
Ui_window.destroy();
}
+2 -9
View File
@@ -9,20 +9,13 @@
/*
* $Logfile: /Freespace2/code/Cutscene/Cutscenes.h $
* $Revision: 2.4 $
* $Date: 2005-07-13 02:50:50 $
* $Revision: 2.2 $
* $Date: 2004-03-05 09:01:58 $
* $Author: Goober5000 $
*
* Code for the cutscenes viewer screen
*
* $Log: not supported by cvs2svn $
* Revision 2.3 2004/08/11 05:06:20 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.2 2004/03/05 09:01:58 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.1 2002/08/01 01:41:04 penguin
* The big include file move
*
+24 -46
View File
@@ -9,43 +9,22 @@
/*
* $Logfile: /Freespace2/code/cutscene/movie.cpp $
* $Revision: 2.26 $
* $Date: 2005-05-12 17:37:48 $
* $Revision: 2.20 $
* $Date: 2004-04-26 13:09:20 $
* $Author: taylor $
*
* movie player code
*
* $Log: not supported by cvs2svn $
* Revision 2.25 2005/04/24 06:52:23 wmcoolmon
* Enabled movies in windowed mode; if this causes problems for people, they can always use -dnoshowvid
*
* Revision 2.24 2005/02/05 00:30:49 taylor
* fix a few things post merge
*
* Revision 2.23 2004/11/27 10:42:18 taylor
* this should get movies working again in D3D and help OGL too
*
* Revision 2.22 2004/07/26 20:47:26 Kazan
* remove MCD complete
*
* Revision 2.21 2004/07/12 16:32:43 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.20 2004/04/26 13:09:20 taylor
* cvs log header, mark cutscenes viewable for later, gr_flip() to fix OGL white flash
*
*
*
* $NoKeywords: $
*/
#ifdef _WIN32
#include <windows.h>
#include "directx/dx8show.h"
#include "graphics/grd3dinternal.h"
#endif
#include "cutscene/movie.h"
#include "movie.h"
#include "directx/dx8show.h"
#include "osapi/osapi.h"
#include "cmdline/cmdline.h"
#include "debugconsole/dbugfile.h"
@@ -53,23 +32,21 @@
#include "cutscene/cutscenes.h" // cutscene_mark_viewable()
#include "freespace2/freespace.h" // for Game_mode, etc.
// This module links freespace movie calls to the actual API calls the play the movie.
// This module handles all the different requires of OS and gfx API and finding the file to play
#ifdef _WIN32
void process_messages()
{
#ifdef _WIN32
MSG msg;
while(PeekMessage(&msg, (HWND) os_get_window(), 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
#endif
}
#include "graphics/grd3dinternal.h"
// filename - file to search for
// out_name - output, full path to file
@@ -124,11 +101,16 @@ bool movie_play(char *name)
cutscene_mark_viewable(name);
}
// reset the gr_* stuff before trying to play a movie
// fixes white flash in OGL and possibly other wierd stuff
gr_reset_clip();
gr_clear();
gr_flip();
extern int Is_standalone;
if(Is_standalone) return false;
if(Cmdline_dnoshowvid) return false;
//Commented this out since we have dnoshowvid -WMC
//if(Cmdline_window) return false;
if(Cmdline_window) return false;
char full_name[MAX_PATH];
int rc = 0;
@@ -142,7 +124,6 @@ bool movie_play(char *name)
DBUGFILE_OUTPUT_1("About to play: %s", full_name);
}
#ifdef _WIN32
process_messages();
// This is a bit of a hack but it works nicely
@@ -151,14 +132,9 @@ bool movie_play(char *name)
GlobalD3DVars::D3D_activate = 0;
GlobalD3DVars::lpD3DDevice->EndScene();
GlobalD3DVars::lpD3DDevice->Present(NULL,NULL,NULL,NULL);
// d3d_lost_device();
d3d_lost_device();
}
// reset the gr_* stuff before trying to play a movie
gr_flip(); // in the case of D3D this should recover the device
gr_clear();
gr_flip(); // need an extra flip here to cycle in the clear'd buffer
// This clears the screen
InvalidateRect((HWND) os_get_window(), NULL, TRUE);
PAINTSTRUCT paint_info;
@@ -241,14 +217,7 @@ bool movie_play(char *name)
// We finished playing the movie
CloseClip((HWND) os_get_window());
if (gr_screen.mode == GR_DIRECT3D) {
GlobalD3DVars::D3D_activate = 1;
}
#else
STUB_FUNCTION;
#endif
GlobalD3DVars::D3D_activate = 1;
return true;
}
@@ -260,3 +229,12 @@ bool movie_play_two(char *name1, char *name2)
return result1 && result2;
}
#else
// Stubs, preprocessor calls were making the win32 code more complex for no good reason.
// Using stubs instead.
bool movie_play(char *name) {return true;}
bool movie_play_two(char *name1, char *name2) {return true;}
#endif
-1
View File
@@ -1,4 +1,3 @@
#ifndef _MOVIE_HEADER_FILE
#define _MOVIE_HEADER_FILE
+108 -154
View File
@@ -1,197 +1,142 @@
#include "ddsutils/ddsutils.h"
#include "cfile/cfile.h"
int Texture_compression_enabled=0;
int dds_read_header(char *filename, CFILE *img_cfp, int *width, int *height, int *bpp, int *compression_type, int *levels, int *size)
static int dds_read_header_internal(LPDDSURFACEDESC2 lpddsd, char *filename, int *width, int *height, int *bpp, int *compression_type, int *levels)
{
DDSURFACEDESC2 dds_header;
int code = 0;
char code[5];
CFILE *ddsfile;
char real_name[MAX_FILENAME_LEN];
int retval = DDS_ERROR_NONE;
int ct = DDS_UNCOMPRESSED;
int bits = 0;
int trash;
char *p;
int retval=DDS_ERROR_NONE;
int ct;
int bits=0;
if (img_cfp == NULL) {
// this better not happen.. ever
Assert(filename != NULL);
//this better not happen.. ever
Assert(filename!=NULL);
// make sure there is an extension
strcpy(real_name, filename);
char *p = strchr(real_name, '.');
if (p) { *p=0; }
strcat(real_name, ".dds");
//make sure there is an extension
strcpy(real_name, filename);
p=strchr(real_name, '.');
if (p) *p=0;
strcat(real_name, ".dds");
// try to open the file
ddsfile = cfopen(real_name, "rb");
memset(code,0,sizeof(code));
//try to open the file
ddsfile = cfopen(real_name, "rb");
// file not found
if (ddsfile == NULL)
return DDS_ERROR_INVALID_FILENAME;
} else {
ddsfile = img_cfp;
//file not found
if (!ddsfile)
{
return DDS_ERROR_INVALID_FILENAME;
}
// read the code
code = cfread_int(ddsfile);
//read the code
cfread(code,1,4,ddsfile);
code[4]=0;
// check it
if (code != DDS_FILECODE)
//check it
if (strncmp(code,DDS_FILECODE,4)!=0)
{
return DDS_ERROR_BAD_HEADER;
// read header variables
dds_header.dwSize = cfread_uint(ddsfile); //INTEL_INT( dds_header.dwSize );
dds_header.dwFlags = cfread_uint(ddsfile); //INTEL_INT( dds_header.dwFlags );
dds_header.dwHeight = cfread_uint(ddsfile); //INTEL_INT( dds_header.dwHeight );
dds_header.dwWidth = cfread_uint(ddsfile); //INTEL_INT( dds_header.dwWidth );
dds_header.dwPitchOrLinearSize = cfread_uint(ddsfile); //INTEL_INT( dds_header.dwPitchOrLinearSize );
dds_header.dwDepth = cfread_uint(ddsfile); //INTEL_INT( dds_header.dwDepth);
dds_header.dwMipMapCount = cfread_uint(ddsfile); //INTEL_INT( dds_header.dwMipMapCount );
// skip over the crap we don't care about
for (int i = 0; i < 11; i++)
trash = cfread_uint(ddsfile);
dds_header.ddpfPixelFormat.dwSize = cfread_uint(ddsfile); //INTEL_INT( dds_header.ddpfPixelFormat.dwSize );
dds_header.ddpfPixelFormat.dwFlags = cfread_uint(ddsfile); //INTEL_INT( dds_header.ddpfPixelFormat.dwFlags );
dds_header.ddpfPixelFormat.dwFourCC = cfread_uint(ddsfile); //INTEL_INT( dds_header.ddpfPixelFormat.dwFourCC );
dds_header.ddpfPixelFormat.dwRGBBitCount = cfread_uint(ddsfile); //INTEL_INT( dds_header.ddpfPixelFormat.dwRGBBitCount );
dds_header.ddpfPixelFormat.dwRBitMask = cfread_uint(ddsfile); //INTEL_INT( dds_header.ddpfPixelFormat.dwRBitMask );
dds_header.ddpfPixelFormat.dwGBitMask = cfread_uint(ddsfile); //INTEL_INT( dds_header.ddpfPixelFormat.dwGBitMask );
dds_header.ddpfPixelFormat.dwBBitMask = cfread_uint(ddsfile); //INTEL_INT( dds_header.ddpfPixelFormat.dwBBitMask );
dds_header.ddpfPixelFormat.dwRGBAlphaBitMask = cfread_uint(ddsfile); //INTEL_INT( dds_header.ddpfPixelFormat.dwRGBAlphaBitMask );
// calculate the type and size of the data
if (dds_header.ddpfPixelFormat.dwFlags & DDPF_FOURCC) {
// did I mention lately that I hate Microsoft?
// this is here to fix the situation where Microsoft doesn't follow their own docs
if ( dds_header.dwPitchOrLinearSize <= 0 ) {
if (dds_header.dwDepth == 0)
dds_header.dwDepth = 1;
// calculate the block size, mult by 8 for DXT1, 16 for DXT3 & 5
*size = ((dds_header.dwWidth + 3)/4) * ((dds_header.dwHeight + 3)/4) * ((dds_header.dwDepth + 3)/4) * ((dds_header.ddpfPixelFormat.dwFourCC == FOURCC_DXT1) ? 8 : 16);
} else {
*size = dds_header.dwMipMapCount > 1 ? dds_header.dwPitchOrLinearSize * 2 : dds_header.dwPitchOrLinearSize;
}
switch (dds_header.ddpfPixelFormat.dwFourCC) {
case FOURCC_DXT1:
bits=24;
ct=DDS_DXT1;
break;
case FOURCC_DXT3:
bits=32;
ct=DDS_DXT3;
break;
case FOURCC_DXT5:
bits=32;
ct=DDS_DXT5;
break;
// dxt2 and dxt4 aren't supported
case FOURCC_DXT2:
case FOURCC_DXT4:
retval = DDS_ERROR_INVALID_FORMAT;
ct = DDS_DXT_INVALID;
break;
// none of the above
default:
retval = DDS_ERROR_UNSUPPORTED;
ct = DDS_DXT_INVALID;
break;
}
} else if (dds_header.ddpfPixelFormat.dwFlags & DDPF_RGB) {
if (dds_header.dwDepth == 0)
dds_header.dwDepth = 1;
*size = dds_header.dwWidth * dds_header.dwHeight * dds_header.dwDepth * (dds_header.ddpfPixelFormat.dwRGBBitCount / 8);
bits = dds_header.ddpfPixelFormat.dwRGBBitCount;
ct = DDS_UNCOMPRESSED;
} else {
// it's not a readable format
retval = DDS_ERROR_UNSUPPORTED;
}
// stuff important info
if (bpp)
*bpp = bits;
if (compression_type)
*compression_type = ct;
//read the header
cfread(lpddsd,sizeof(DDSURFACEDESC2),1,ddsfile);
//stuff important info
if (width)
*width = dds_header.dwWidth;
*width = lpddsd->dwWidth;
if (height)
*height = dds_header.dwHeight;
*height = lpddsd->dwHeight;
if (levels)
*levels = dds_header.dwMipMapCount;
*levels = lpddsd->dwMipMapCount;
if (img_cfp == NULL) {
// close file and return
cfclose(ddsfile);
ddsfile = NULL;
switch(lpddsd->ddpfPixelFormat.dwFourCC)
{
case FOURCC_DXT1:
bits=24;
ct=DDS_DXT1;
break;
case FOURCC_DXT3:
bits=32;
ct=DDS_DXT3;
break;
case FOURCC_DXT5:
bits=32;
ct=DDS_DXT5;
break;
//dxt2 and dxt4 aren't supported
case FOURCC_DXT2:
case FOURCC_DXT4:
retval=DDS_ERROR_INVALID_FORMAT;
ct=DDS_DXT_INVALID;
break;
//none of the above
default:
retval=DDS_ERROR_UNCOMPRESSED;
ct=DDS_DXT_INVALID;
break;
}
if (bpp) *bpp=bits;
if (compression_type) *compression_type=ct;
//close file and return
cfclose(ddsfile);
return retval;
}
int dds_read_header(char *filename, int *width, int *height, int *bpp, int *compression_type, int *levels)
{
DDSURFACEDESC2 ddsd;
return dds_read_header_internal(&ddsd, filename, width, height, bpp, compression_type, levels);
}
//reads pixel info from a dds file
int dds_read_bitmap(char *filename, ubyte *data, ubyte *bpp)
int dds_read_bitmap(char *filename, int *size, uint* data)
{
int retval;
int w,h,ct,lvl;
int size = 0, bits = 0;
DDSURFACEDESC2 ddsd;
int w,h,ct,lvl,bpp;
CFILE *cfp;
char real_name[MAX_FILENAME_LEN];
ubyte* tmp;
// this better not happen.. ever
Assert(filename != NULL);
//this must be set
Assert(size!=NULL);
//read the header -- if its at this stage, it should be legal.
retval=dds_read_header_internal(&ddsd, filename, &w, &h, &bpp, &ct, &lvl);
Assert(retval==DDS_ERROR_NONE);
// make sure there is an extension
strcpy(real_name, filename);
char *p = strchr(real_name, '.');
if (p) { *p = 0; }
strcat(real_name, ".dds");
//get some more info from the surface
*size=ddsd.dwMipMapCount > 1 ? ddsd.dwLinearSize * 2 : ddsd.dwLinearSize;
// open it up and go to the data section
cfp = cfopen(real_name, "rb");
//open it up and go to the data section
cfp=cfopen(filename,"rb");
cfseek(cfp,DDS_OFFSET, CF_SEEK_SET);
// just in case
if (cfp == NULL)
return DDS_ERROR_INVALID_FILENAME;
// read the header -- if its at this stage, it should be legal.
retval = dds_read_header(real_name, cfp, &w, &h, &bits, &ct, &lvl, &size);
Assert(retval == DDS_ERROR_NONE);
// this really shouldn't be needed but better safe than sorry
if (retval != DDS_ERROR_NONE) {
return retval;
//get the data
tmp=(ubyte*)malloc(*size);
if (!tmp)
{
cfclose(cfp);
return DDS_ERROR_NO_MEM; //barf
}
cfseek(cfp, DDS_OFFSET, CF_SEEK_SET);
cfread(tmp,1,*size,cfp);
// read in the data
cfread(data, 1, size, cfp);
if (bpp)
*bpp = (ubyte)bits;
// we look done here
*data=(uint)tmp;
//we look done here
cfclose(cfp);
return DDS_ERROR_NONE;
}
@@ -215,8 +160,8 @@ const char *dds_error_string(int code)
case DDS_ERROR_INVALID_FORMAT:
return "File was compressed, but it was DXT2 or DXT4";
case DDS_ERROR_UNSUPPORTED:
return "*.DDS files must be uncompressed or use DXT1, DXT3, or DXT5 compression";
case DDS_ERROR_UNCOMPRESSED:
return "*.DDS files must be compressed and use DXT1, DXT3, or DXT5 compression";
default:
return "Abort, retry, fail?";
@@ -225,3 +170,12 @@ const char *dds_error_string(int code)
//get a warning otherwise
return "Abort, retry, fail?";
}
+47 -18
View File
@@ -5,22 +5,17 @@
#define __DDS_H
#include "globalincs/pstypes.h"
#ifdef _WIN32
#include "directx/vddraw.h"
#endif
struct CFILE;
#define DDS_ERROR_NONE 0 //everything went fine
#define DDS_ERROR_INVALID_FILENAME 1 //bad filename
#define DDS_ERROR_NO_MEM 2 //not enough mem to load
#define DDS_ERROR_UNSUPPORTED 3 //not a readable format
#define DDS_ERROR_UNCOMPRESSED 3 //not using dxtc compression
#define DDS_ERROR_INVALID_FORMAT 4 //can only use dxtc1, dxtc3, dxtc5
#define DDS_ERROR_BAD_HEADER 5 //header was not "DDS "
#define DDS_DXT_INVALID -1
#define DDS_UNCOMPRESSED 0
#define DDS_DXT1 1
#define DDS_DXT3 3
#define DDS_DXT5 5
@@ -38,7 +33,7 @@ struct CFILE;
#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4'))
#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5'))
#define DDS_FILECODE 0x20534444 // "DDS " in file
#define DDS_FILECODE "DDS "
#ifndef DUMMYUNIONNAMEN
#if defined(__cplusplus) || !defined(NONAMELESSUNION)
@@ -48,12 +43,18 @@ struct CFILE;
#endif
#endif
//these structures are the headers for a dds file
typedef struct _DDSCAPS2
{
DWORD dwCaps1;
DWORD dwCaps2;
DWORD Reserved[2];
DWORD dwCaps; // capabilities of surface wanted
DWORD dwCaps2;
DWORD dwCaps3;
union
{
DWORD dwCaps4;
DWORD dwVolumeDepth;
} DUMMYUNIONNAMEN(1);
} DDSCAPS2;
typedef struct _DDSURFACEDESC2
@@ -62,13 +63,41 @@ typedef struct _DDSURFACEDESC2
DWORD dwFlags; // determines what fields are valid
DWORD dwHeight; // height of surface to be created
DWORD dwWidth; // width of input surface
DWORD dwPitchOrLinearSize;
DWORD dwDepth;
DWORD dwMipMapCount;
DWORD dwReserved1[11];
DDPIXELFORMAT ddpfPixelFormat;
union
{
LONG lPitch; // distance to start of next line (return value only)
DWORD dwLinearSize; // Formless late-allocated optimized surface size
} DUMMYUNIONNAMEN(1);
union
{
DWORD dwBackBufferCount; // number of back buffers requested
DWORD dwDepth; // the depth if this is a volume texture
} DUMMYUNIONNAMEN(5);
union
{
DWORD dwMipMapCount; // number of mip-map levels requestde
// dwZBufferBitDepth removed, use ddpfPixelFormat one instead
DWORD dwRefreshRate; // refresh rate (used when display mode is described)
DWORD dwSrcVBHandle; // The source used in VB::Optimize
} DUMMYUNIONNAMEN(2);
DWORD dwAlphaBitDepth; // depth of alpha buffer requested
DWORD dwReserved; // reserved
LPVOID lpSurface; // pointer to the associated surface memory
union
{
DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use
DWORD dwEmptyFaceColor; // Physical color for empty cubemap faces
} DUMMYUNIONNAMEN(3);
DDCOLORKEY ddckCKDestBlt; // color key for destination blt use
DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use
DDCOLORKEY ddckCKSrcBlt; // color key for source blt use
union
{
DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface
DWORD dwFVF; // vertex format description of vertex buffers
} DUMMYUNIONNAMEN(4);
DDSCAPS2 ddsCaps; // direct draw surface capabilities
DWORD dwReserved2;
DWORD dwTextureStage; // stage in multitexture cascade
} DDSURFACEDESC2, FAR* LPDDSURFACEDESC2;
#define DDS_OFFSET 4+sizeof(DDSURFACEDESC2) //place where the data starts -- should be 128
@@ -76,11 +105,11 @@ typedef struct _DDSURFACEDESC2
//reads a dds header
//returns one of the error values
//'compression_type' comes back as one of the DDS_DXTC* defines
int dds_read_header(char *filename, CFILE *img_cfp = NULL, int *width = 0, int *height = 0, int *bpp = 0, int *compression_type = 0, int *levels = 0, int *size = 0);
int dds_read_header(char *filename, int *width, int *height, int *bpp, int *compression_type, int *levels);
//reads bitmap
//size of the data it stored in size
int dds_read_bitmap(char *filename, ubyte *data, ubyte *bpp = NULL);
int dds_read_bitmap(char *filename, int *size, uint* data);
//returns a string from a DDS error code
const char* dds_error_string(int code);
+53 -73
View File
@@ -9,54 +9,13 @@
/*
* $Logfile: /Freespace2/code/Debris/Debris.cpp $
* $Revision: 2.17 $
* $Date: 2005-07-22 10:18:37 $
* $Revision: 2.6 $
* $Date: 2004-03-31 05:42:26 $
* $Author: Goober5000 $
*
* Code for the pieces of exploding object debris.
*
* $Log: not supported by cvs2svn $
* Revision 2.16 2005/07/13 02:50:51 Goober5000
* remove PreProcDefine #includes in FS2
* --Goober5000
*
* Revision 2.15 2005/07/13 02:01:28 Goober5000
* fixed a bunch of "issues" caused by me with the species stuff
* --Goober5000
*
* Revision 2.14 2005/07/13 00:44:21 Goober5000
* improved species support and removed need for #define
* --Goober5000
*
* Revision 2.13 2005/04/05 05:53:15 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.12 2005/03/27 12:28:32 Goober5000
* clarified max hull/shield strength names and added ship guardian thresholds
* --Goober5000
*
* Revision 2.11 2005/03/02 21:24:43 taylor
* more network/inferno goodness for Windows, takes care of a few warnings too
*
* Revision 2.10 2005/01/30 09:27:39 Goober5000
* nitpicked some boolean tests, and fixed two small bugs
* --Goober5000
*
* Revision 2.9 2004/07/26 20:47:26 Kazan
* remove MCD complete
*
* Revision 2.8 2004/07/12 16:32:44 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.7 2004/07/01 01:52:20 phreak
* function pointer radar update.
* will enable us to make different radar styles that we can switch between
*
* Revision 2.6 2004/03/31 05:42:26 Goober5000
* got rid of all those nasty warnings from xlocale and so forth; also added comments
* for #pragma warning disable to indicate the message being disabled
* --Goober5000
*
* Revision 2.5 2004/03/05 09:01:59 Goober5000
* Uber pass at reducing #includes
* --Goober5000
@@ -279,11 +238,11 @@
* $NoKeywords: $
*/
#include "debris/debris.h"
#include "render/3d.h"
#include "fireball/fireballs.h"
#include "radar/radar.h"
#include "mission/missionparse.h" // For MAX_SPECIES_NAMES
#include "gamesnd/gamesnd.h"
#include "object/objectsnd.h"
#include "globalincs/linklist.h"
@@ -293,7 +252,6 @@
#include "io/timer.h"
#include "species_defs/species_defs.h"
#include "ship/ship.h"
#include "radar/radarsetup.h"
#ifndef NO_NETWORK
#include "network/multi.h"
@@ -301,9 +259,6 @@
#include "network/multiutil.h"
#endif
#define MAX_LIFE 10.0f
#define MIN_RADIUS_FOR_PERSISTANT_DEBRIS 50 // ship radius at which debris from it becomes persistant
#define DEBRIS_SOUND_DELAY 2000 // time to start debris sound after created
@@ -322,10 +277,31 @@ int Debris_model = -1;
int Debris_vaporize_model = -1;
int Debris_num_submodels = 0;
char Debris_texture_files[MAX_SPECIES][FILESPEC_LENGTH];
#if defined(MORE_SPECIES)
char Debris_texture_files[MAX_SPECIES_NAMES][MAX_DEBRIS_TNAME_LEN+1];
int Debris_textures[MAX_SPECIES];
/*char * Debris_texture_files[MAX_SPECIES_NAMES] = {
NOX("debris01a"), // Terran
NOX("debris01b"), // Species B
NOX("debris01c"), // Shivan
NOX("debris01a"), // Ancient
NOX("debris01a"), // User1
NOX("debris01a"), // User2
NOX("debris01a"), // User3
NOX("debris01a"), // User4
};*/
#else
char * Debris_texture_files[MAX_SPECIES_NAMES] = {
NOX("debris01a"), // Terran
NOX("debris01b"), // Species B
NOX("debris01c"), // Shivan
};
#endif
int Debris_textures[MAX_SPECIES_NAMES];
#define MAX_DEBRIS_DIST 10000.0f // Debris goes away if it's this far away.
#define DEBRIS_DISTANCE_CHECK_TIME (10*1000) // Check every 10 seconds.
@@ -398,7 +374,7 @@ void debris_page_in()
int i;
Debris_model = model_load( NOX("debris01.pof"), 0, NULL );
if (Debris_model >= 0) {
if (Debris_model>-1) {
polymodel * pm;
pm = model_get(Debris_model);
Debris_num_submodels = pm->n_models;
@@ -406,7 +382,11 @@ void debris_page_in()
Debris_vaporize_model = model_load( NOX("debris02.pof"), 0, NULL );
for (i=0; i<True_NumSpecies; i++ ) {
#if defined(MORE_SPECIES)
for (i=0; i<MAX_SPECIES_NAMES && i<True_NumSpecies; i++ ) {
#else
for (i=0; i<MAX_SPECIES_NAMES; i++ ) {
#endif
nprintf(( "Paging", "Paging in debris texture '%s'\n", Debris_texture_files[i] ));
Debris_textures[i] = bm_load( Debris_texture_files[i] );
if ( Debris_textures[i] < 0 ) {
@@ -441,7 +421,7 @@ void debris_render(object * obj)
Assert( db->flags & DEBRIS_USED );
// Swap in a different texture depending on the species
if ( (db->species > -1) && (db->species < MAX_SPECIES) ) {
if ( (db->species > -1) && (db->species < MAX_SPECIES_NAMES) ) {
pm = model_get( db->model_num );
@@ -607,7 +587,7 @@ void debris_process_post(object * obj, float frame_time)
int n, n_arcs = ((rand()>>5) % 3)+1; // Create 1-3 sparks
vec3d v1, v2, v3, v4;
vector v1, v2, v3, v4;
submodel_get_two_random_points( db->model_num, db->submodel_num, &v1, &v2 );
submodel_get_two_random_points( db->model_num, db->submodel_num, &v3, &v4 );
@@ -650,7 +630,7 @@ void debris_process_post(object * obj, float frame_time)
// rotate v2 out of local coordinates into world.
// Use v2 since it is used in every bolt. See above switch().
vec3d snd_pos;
vector snd_pos;
vm_vec_unrotate(&snd_pos, &v2, &obj->orient);
vm_vec_add2(&snd_pos, &obj->pos );
@@ -687,7 +667,7 @@ void debris_process_post(object * obj, float frame_time)
// Maybe move a vertex.... 20% of the time maybe?
int mr = myrand();
if ( mr < RAND_MAX/5 ) {
vec3d v1, v2;
vector v1, v2;
submodel_get_two_random_points( db->model_num, db->submodel_num, &v1, &v2 );
db->arc_pts[i][mr % 2] = v1;
}
@@ -723,7 +703,7 @@ int debris_find_oldest()
}
#define DEBRIS_ROTVEL_SCALE 5.0f
void calc_debris_physics_properties( physics_info *pi, vec3d *min, vec3d *max );
void calc_debris_physics_properties( physics_info *pi, vector *min, vector *max );
// ---------------------------------------------------------------------------------------
// debris_create()
//
@@ -731,7 +711,7 @@ void calc_debris_physics_properties( physics_info *pi, vec3d *min, vec3d *max );
//
// exp_force: Explosion force, used to assign velocity to pieces.
// 1.0f assigns velocity like before. 2.0f assigns twice as much to non-inherited part of velocity
object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d *pos, vec3d *exp_center, int hull_flag, float exp_force)
object *debris_create(object *source_obj, int model_num, int submodel_num, vector *pos, vector *exp_center, int hull_flag, float exp_force)
{
int i, n, objnum, parent_objnum;
object *obj;
@@ -806,7 +786,7 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
for (i=0; i<MAX_DEBRIS_ARCS; i++ ) {
db->arc_timestamp[i] = timestamp(-1);
// vec3d arc_pts[MAX_DEBRIS_ARCS][2]; // The endpoints of each arc
// vector arc_pts[MAX_DEBRIS_ARCS][2]; // The endpoints of each arc
}
if ( db->is_hull ) {
@@ -863,13 +843,13 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
// -- No long need shield: bset_shield_strength(obj, 100.0f); // Hey! Set to some meaningful value!
if (source_obj->type == OBJ_SHIP) {
obj->hull_strength = Ships[source_obj->instance].ship_max_hull_strength/8.0f;
obj->hull_strength = Ships[source_obj->instance].ship_initial_hull_strength/8.0f;
} else
obj->hull_strength = 10.0f;
Num_debris_pieces++;
vec3d rotvel, radial_vel, to_center;
vector rotvel, radial_vel, to_center;
if ( exp_center )
vm_vec_sub( &to_center,pos, exp_center );
@@ -885,7 +865,7 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
// set up physics mass and I_inv for hull debris pieces
pm = model_get(model_num);
vec3d *min, *max;
vector *min, *max;
min = &pm->submodel[submodel_num].min;
max = &pm->submodel[submodel_num].max;
calc_debris_physics_properties( &obj->phys_info, min, max );
@@ -924,7 +904,7 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
// DA: here we need to vel_from_rot = w x to_center, where w is world is unrotated to world coords and offset is the
// displacement fromt the center of the parent object to the center of the debris piece
vec3d world_rotvel, vel_from_rotvel;
vector world_rotvel, vel_from_rotvel;
vm_vec_unrotate ( &world_rotvel, &source_obj->phys_info.rotvel, &source_obj->orient );
vm_vec_crossprod ( &vel_from_rotvel, &world_rotvel, &to_center );
vm_vec_scale ( &vel_from_rotvel, DEBRIS_ROTVEL_SCALE);
@@ -1001,7 +981,7 @@ object *debris_create(object *source_obj, int model_num, int submodel_num, vec3d
// Alas, poor debris_obj got whacked. Fortunately, we know who did it, where and how hard, so we
// can do something about it.
//
void debris_hit(object *debris_obj, object *other_obj, vec3d *hitpos, float damage)
void debris_hit(object *debris_obj, object *other_obj, vector *hitpos, float damage)
{
debris *debris_p = &Debris[debris_obj->instance];
@@ -1013,7 +993,7 @@ void debris_hit(object *debris_obj, object *other_obj, vec3d *hitpos, float dama
pe.pos = *hitpos; // Where the particles emit from
pe.vel = debris_obj->phys_info.vel; // Initial velocity of all the particles
vec3d tmp_norm;
vector tmp_norm;
vm_vec_sub( &tmp_norm, hitpos, &debris_obj->pos );
vm_vec_normalize_safe(&tmp_norm);
@@ -1067,7 +1047,7 @@ void debris_hit(object *debris_obj, object *other_obj, vec3d *hitpos, float dama
//
#pragma warning ( push )
#pragma warning ( disable : 4701 ) // possible use of variable without initialization
int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, collision_info_struct *debris_hit_info)
int debris_check_collision(object *pdebris, object *other_obj, vector *hitpos, collision_info_struct *debris_hit_info)
{
mc_info mc;
int num;
@@ -1108,7 +1088,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
object *heavy_obj = heavy;
object *light_obj = light;
vec3d zero, p0, p1;
vector zero, p0, p1;
vm_vec_zero(&zero);
vm_vec_sub(&p0, &light->last_pos, &heavy->last_pos);
vm_vec_sub(&p1, &light->pos, &heavy->pos);
@@ -1118,7 +1098,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
mc.p1 = &p1; // Point 2 of ray to check
// find the light object's position in the heavy object's reference frame at last frame and also in this frame.
vec3d p0_temp, p0_rotated;
vector p0_temp, p0_rotated;
// Collision detection from rotation enabled if at rotaion is less than 30 degree in frame
// This should account for all ships
@@ -1145,7 +1125,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
// copy important data
int copy_flags = mc.flags; // make a copy of start end positions of sphere in big ship RF
vec3d copy_p0, copy_p1;
vector copy_p0, copy_p1;
copy_p0 = *mc.p0;
copy_p1 = *mc.p1;
@@ -1216,7 +1196,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
}
// find position in submodel RF of light object at collison
vec3d int_light_pos, diff;
vector int_light_pos, diff;
vm_vec_sub(&diff, mc.p1, mc.p0);
vm_vec_scale_add(&int_light_pos, mc.p0, &diff, mc.hit_dist);
model_find_world_point(&debris_hit_info->light_collision_cm_pos, &int_light_pos, mc.model_num, mc.hit_submodel, &heavy_obj->orient, &zero);
@@ -1248,7 +1228,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
}
// find position in submodel RF of light object at collison
vec3d diff;
vector diff;
vm_vec_sub(&diff, mc.p1, mc.p0);
vm_vec_scale_add(&debris_hit_info->light_collision_cm_pos, mc.p0, &diff, mc.hit_dist);
@@ -1280,7 +1260,7 @@ int debris_check_collision(object *pdebris, object *other_obj, vec3d *hitpos, co
}
// find position in submodel RF of light object at collison
vec3d diff;
vector diff;
vm_vec_sub(&diff, mc.p1, mc.p0);
vm_vec_scale_add(&debris_hit_info->light_collision_cm_pos, mc.p0, &diff, mc.hit_dist);
@@ -1330,7 +1310,7 @@ int debris_get_team(object *objp)
}
// fills in debris physics properties when created, specifically mass and moment of inertia
void calc_debris_physics_properties( physics_info *pi, vec3d *mins, vec3d *maxs )
void calc_debris_physics_properties( physics_info *pi, vector *mins, vector *maxs )
{
float dx, dy, dz, mass;
dx = maxs->xyz.x - mins->xyz.x;
+11 -20
View File
@@ -9,26 +9,13 @@
/*
* $Logfile: /Freespace2/code/Debris/Debris.h $
* $Revision: 2.5 $
* $Date: 2005-07-13 02:50:51 $
* $Revision: 2.1 $
* $Date: 2004-03-05 09:01:59 $
* $Author: Goober5000 $
*
* Code for the pieces of exploding object debris.
*
* $Log: not supported by cvs2svn $
* Revision 2.4 2005/04/28 05:29:29 wmcoolmon
* Removed FS2_DEMO defines that looked like they wouldn't cause the universe to collapse
*
* Revision 2.3 2005/04/05 05:53:15 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.2 2004/08/11 05:06:20 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.1 2004/03/05 09:01:59 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.0 2002/06/03 04:02:21 penguin
* Warpcore CVS sync
*
@@ -183,7 +170,7 @@ typedef struct debris {
fix time_started; // time when debris was created
int next_distance_check; // timestamp to determine whether to delete this piece of debris.
vec3d arc_pts[MAX_DEBRIS_ARCS][2]; // The endpoints of each arc
vector arc_pts[MAX_DEBRIS_ARCS][2]; // The endpoints of each arc
int arc_timestamp[MAX_DEBRIS_ARCS]; // When this times out, the spark goes away. -1 is not used
int arc_frequency; // Starts at 0, gets bigger
@@ -195,7 +182,11 @@ typedef struct debris {
#define DEBRIS_EXPIRE (1<<1) // debris can expire (ie hull chunks from small ships)
#define MAX_DEBRIS_PIECES 64
#ifdef FS2_DEMO
#define MAX_DEBRIS_PIECES 48
#else
#define MAX_DEBRIS_PIECES 64
#endif
extern debris Debris[MAX_DEBRIS_PIECES];
@@ -208,9 +199,9 @@ void debris_render( object * obj );
void debris_delete( object * obj );
void debris_process_pre( object * obj, float frame_time);
void debris_process_post( object * obj, float frame_time);
object *debris_create( object * source_obj, int model_num, int submodel_num, vec3d *pos, vec3d *exp_center, int hull_flag, float exp_force );
int debris_check_collision( object * obj, object * other_obj, vec3d * hitpos, collision_info_struct *debris_hit_info=NULL );
void debris_hit( object * debris_obj, object * other_obj, vec3d * hitpos, float damage );
object *debris_create( object * source_obj, int model_num, int submodel_num, vector *pos, vector *exp_center, int hull_flag, float exp_force );
int debris_check_collision( object * obj, object * other_obj, vector * hitpos, collision_info_struct *debris_hit_info=NULL );
void debris_hit( object * debris_obj, object * other_obj, vector * hitpos, float damage );
int debris_get_team(object *objp);
void debris_clear_expired_flag(debris *db);
+5 -16
View File
@@ -9,23 +9,13 @@
/*
* $Logfile: /Freespace2/code/DebugConsole/Console.cpp $
* $Revision: 2.6 $
* $Date: 2005-04-25 00:07:22 $
* $Author: wmcoolmon $
* $Revision: 2.3 $
* $Date: 2004-03-05 09:01:58 $
* $Author: Goober5000 $
*
* Routines for managing the debug console window.
*
* $Log: not supported by cvs2svn $
* Revision 2.5 2004/07/26 20:47:27 Kazan
* remove MCD complete
*
* Revision 2.4 2004/07/12 16:32:44 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.3 2004/03/05 09:01:58 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.2 2003/03/18 10:07:01 unknownplayer
* The big DX/main line merge. This has been uploaded to the main CVS since I can't manage to get it to upload to the DX branch. Apologies to all who may be affected adversely, but I'll work to debug it as fast as I can.
*
@@ -134,7 +124,6 @@
#include "osapi/osapi.h"
#include "debugconsole/dbugfile.h"
#define MAX_COMMANDS 300
static int Num_debug_commands = 0;
@@ -632,7 +621,7 @@ void debug_output( char c )
void dc_printf(char *format, ...)
{
char tmp[DCOLS*DROWS];
char tmp[DCOLS*2];
va_list args;
va_start(args, format);
@@ -640,7 +629,7 @@ void dc_printf(char *format, ...)
va_end(args);
char *p = tmp;
while( *p != '\0' ) {
while( *p ) {
debug_output(*p);
p++;
}
-2
View File
@@ -9,8 +9,6 @@
#include "dbugfile.h"
#pragma warning(disable:4711) // function selected for inlining
int dbugfile_counters[MAX_COUNTERS];
-1
View File
@@ -1,4 +1,3 @@
#ifndef _DBUGFILE_HEADER_
#define _DBUGFILE_HEADER_
+3 -4
View File
@@ -16,11 +16,9 @@
#ifdef _WIN32
#include <windows.h>
#include <winbase.h>
#endif
#include "timerbar.h"
#include "globalincs/pstypes.h"
#include "globalincs\pstypes.h"
// Internal structure for handling frame data
typedef struct
@@ -40,7 +38,7 @@ LARGE_INTEGER timerbar_ultimate_start_value;
LARGE_INTEGER timerbar_last_start_value;
// Data needed for push and pop functionality
const int MAX_TB_STACK_SIZE = 100;
const MAX_TB_STACK_SIZE = 100;
int timerbar_stack[MAX_TB_STACK_SIZE];
int timerbar_current_stack_layer = 0;
@@ -224,3 +222,4 @@ void timerbar_set_draw_func(void (*new_draw_func_ptr)(int colour, float x, float
draw_func_ptr = new_draw_func_ptr;
}
#endif
+3 -13
View File
@@ -8,21 +8,11 @@
/*
* $Logfile: /Freespace2/code/debugconsole/timerbar.h $
* $Revision: 1.10 $
* $Date: 2005-07-13 02:50:50 $
* $Author: Goober5000 $
* $Revision: 1.8 $
* $Date: 2004-02-16 11:47:31 $
* $Author: randomtiger $
*
* $Log: not supported by cvs2svn $
* Revision 1.9 2004/08/11 05:06:20 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 1.8 2004/02/16 11:47:31 randomtiger
* Removed a lot of files that we dont need anymore.
* Changed htl to be on by default, command now -nohtl
* Changed D3D to use a 2D vertex for 2D operations which should cut down on redundant data having to go though the system.
* Added small change to all -start_mission flag to take you to any mission by filename, very useful for testing.
* Removed old dshow code and took away timerbar compile flag condition since it uses a runtime flag now.
*
* Revision 1.7 2003/11/19 20:37:23 randomtiger
* Almost fully working 32 bit pcx, use -pcx32 flag to activate.
* Made some commandline variables fit the naming standard.
File diff suppressed because it is too large. Load diff
+51 -80
View File
@@ -1,24 +1,14 @@
//header file for making decals-Bobboau
//header file for makeing decals-Bobboau
#ifndef _DECAL_H
#define _DECAL_H
#include "object/object.h"
#define MAX_DECAL_POLY 40
#define MAX_DECAL_POLY 20
#define MAX_DECAL_POLY_POINT 10
#define MAX_DECAL_DEFPOINTS 10000
#define MAX_DECAL_DEFPOINTS 1000
#define MAX_DECAL_POINT 10
#define MAX_SHIP_DECALS 25
#define MAX_GLOBAL_DECAL_POLYS 11000
#define QUICKFIND_SUBDIVISION 100
#define QUICKFIND_SEGMENT_LENGTH (MAX_GLOBAL_DECAL_POLYS/QUICKFIND_SUBDIVISION)
#define MAX_GLOBAL_DECALS 5000
#include "globalincs/pstypes.h"
//#include "ship/ship.h"
#define DP_EOF 0
#define DP_DEFPOINTS 1
@@ -27,82 +17,63 @@
#define DP_SORTNORM 4
#define DP_BOUNDBOX 5
struct decal;
struct decal_list;
struct decal_list_controle;
typedef struct decal_model{ //this will store a triangulated version of the ships polygons
struct{
int point[3]; //an index to the vert list-Bobboau
vector center; //the center of the poly
float radius; //the max radius of the poly
}poly[MAX_DECAL_POLY];
vector vert[MAX_DECAL_DEFPOINTS]; //the defpoints-Bobboau
int n_polys;
}decal_model;
struct decal_poly{
vec3d norm[3];
vertex point[3];
decal_poly *next;
decal* parent;
int idx;
};
//extern decal_model d_model;
struct decal{
int n_poly;
int timestamp; //when this decal was created
int burn_time; //how long it takes for the glow texture to fade
int vertex_buffer_start; //were is the start of this decal's polys in the vertex buffer
decal_poly* poly;
decal_poly* add_poly();
decal_poly* get_last_poly();
void remove_last_poly();
decal_list_controle *parent;
};
struct decal_list{
decal dec;
decal_list *next;
};
struct decal_item{
decal_list dec;
bool used;
};
struct decal_list_controle{
int n_decals;
int buffer;
int texture;
int n_poly;
int burn_texture;
int glow_texture;
bool modifyed;
decal_list *d_list;
decal_list *end;
decal_list *add_new();
void trim();
void clear();
~decal_list_controle();
decal_list_controle();
};
struct decal_system{
decal_list_controle *decals;
int n_decal_textures;
bool decals_modified;
int max_decals;
decal_system():decals(NULL),n_decal_textures(0),decals_modified(false){};
};
//this is used to give all the data to the generation data to the functions that make them
struct decal_point{
vec3d pnt;
matrix orient;
typedef struct decal{
struct{
int backfaced; //flag that this poly uses the backfaced texture
uv_pair uv[MAX_DECAL_POLY_POINT]; //uv coordanants
int point[MAX_DECAL_POLY_POINT]; //an index to the vert list-Bobboau
int n_poly;
vector norm; //the normal used for lighting
}poly[MAX_DECAL_POLY];
vector position;
float radius;
};
int submodel_parent; //the submodel this is part of
vector vert[1000]; //the defpoints-Bobboau
int frames; //number of frames in an animation
int fps; //frames per second
int starting_keyframe; //the frame that indicates the end of the inital nonlooped portion and the start of the middle looped part
int ending_keyframe; //the frame that indicates the end of the loopable portion and the start of the end part
int texture; //the texture to be used, first in animation
int backfaced_texture; //the texture to be used by backfaced polys, first in animation
int is_valid; //this means it is a good decal that should be rendered-Bobboau
int n_poly; //the number of polys
int timestamp; //this is when the decal was made-Bobboau
int lifetime; //this is how long the decal should be alive for-Bobboau
int importance; //this is for big things large beam marks and bomb craters should last longer than the odd laser impacts-Bobboau
int state; //1 starting, 2 looping(mostly for beams), 3 ending, 4 static
}decal;
int decal_create(object * obj, decal_point *point, int subobject, int texture, int backfaced_texture = -1, int glow_texture = -1, int burn_texture = -1, int burn_time = 1000);//makes the decal
typedef struct decal_point{
vector pnt;
matrix orient;
float radius;
}decal_point;
int decal_create(object * obj, decal_point *point, int subobject, int texture, int backfaced_texture = -1);//makes the decal
#endif
int decal_create_simple(object * obj, decal_point *point, int texture);//makes a simple non-clipped decal
void decal_render_all(object * obj); //renders all decals
int decal_create(object * obj, decal_point *point, int subobject, int texture, int backfaced_texture);//makes the decal
int decal_create_sub(void *model_ptr);
void clear_decals(decal_system *system);
/*
#endif
int decal_is_in_face(int n, vertex vertlist[n]);//sees if a poly is inside a decal: 0 is yes, 1 is sort of, -1 is no
*/
+9 -27
View File
@@ -9,28 +9,12 @@
/*
* $Logfile: /Freespace2/code/Demo/Demo.cpp $
* $Revision: 2.8 $
* $Date: 2005-05-12 17:49:11 $
* $Author: taylor $
* $Revision: 2.3 $
* $Date: 2004-03-05 09:01:59 $
* $Author: Goober5000 $
*
*
* $Log: not supported by cvs2svn $
* Revision 2.7 2005/04/05 05:53:15 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.6 2005/01/31 23:27:52 taylor
* merge with Linux/OSX tree - p0131-2
*
* Revision 2.5 2004/07/26 20:47:27 Kazan
* remove MCD complete
*
* Revision 2.4 2004/07/12 16:32:45 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.3 2004/03/05 09:01:59 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.2 2002/08/01 01:41:04 penguin
* The big include file move
*
@@ -68,7 +52,7 @@
#include "demo/demo.h"
#include "ship/ship.h"
#include "weapon/weapon.h"
#include "Weapon/weapon.h"
#include "globalincs/linklist.h"
#include "freespace2/freespace.h"
#include "object/object.h"
@@ -80,8 +64,6 @@
#include "ship/shiphit.h"
#include "cfile/cfile.h"
// -----------------------------------------------------------------------------------------------------------------------------
// DEMO DEFINES/VARS
//
@@ -157,7 +139,7 @@ int Demo_error = DEMO_ERROR_NONE;
#define DEMO_BYTE(vl) do { DEMO_DATA(vl, sizeof(char)); } while(0)
#define DEMO_UBYTE(vl) do { DEMO_DATA(vl, sizeof(ubyte)); } while(0)
#define DEMO_FLOAT(vl) do { DEMO_DATA(vl, sizeof(float)); } while(0)
#define DEMO_VECTOR(vl) do { DEMO_DATA(vl, sizeof(vec3d)); } while(0)
#define DEMO_VECTOR(vl) do { DEMO_DATA(vl, sizeof(vector)); } while(0)
#define DEMO_MATRIX(vl) do { DEMO_DATA(vl, sizeof(matrix)); } while(0)
#define DEMO_STRING(vl) do { int stlen; if(Game_mode & GM_DEMO_RECORD){ stlen = strlen(vl); if(stlen <= 0){ break; } DEMO_DATA(stlen, sizeof(ushort)); DEMO_DATA(*vl, strlen(vl)); } else { ushort len = 0; DEMO_USHORT(len); DEMO_DATA(*vl, len); vl[len] = '\0'; } } while(0)
@@ -304,7 +286,7 @@ int demo_start_record(char *file)
char full_name[MAX_FILENAME_LEN] = "";
// try and allocate the buffer
Demo_buf = (char*)vm_malloc(DEMO_BUF_SIZE);
Demo_buf = (char*)malloc(DEMO_BUF_SIZE);
if(Demo_buf == NULL){
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);
return 0;
@@ -348,7 +330,7 @@ int demo_start_playback(char *file)
char full_name[MAX_FILENAME_LEN] = "";
// try and allocate the buffer
Demo_buf = (char*)vm_malloc(DEMO_BUF_SIZE);
Demo_buf = (char*)malloc(DEMO_BUF_SIZE);
if(Demo_buf == NULL){
DEMO_ERROR(DEMO_ERROR_DISK_ACCESS);
return 0;
@@ -398,7 +380,7 @@ void demo_close()
// free the buffer
if(Demo_buf != NULL){
vm_free(Demo_buf);
free(Demo_buf);
Demo_buf = NULL;
}
@@ -836,7 +818,7 @@ int demo_playback_seek_sub(int frame_size)
ushort obj_count = 0;
int obj_sig = 0;
ubyte team = 0;
vec3d obj_pos = vmd_zero_vector;
vector obj_pos = vmd_zero_vector;
matrix obj_orient = vmd_identity_matrix;
float obj_fthrust = 0;
int ship_index = 0;
+3 -10
View File
@@ -9,18 +9,12 @@
/*
* $Logfile: /Freespace2/code/Demo/Demo.h $
* $Revision: 2.2 $
* $Date: 2005-07-13 02:50:51 $
* $Author: Goober5000 $
* $Revision: 2.0 $
* $Date: 2002-06-03 04:02:21 $
* $Author: penguin $
*
*
* $Log: not supported by cvs2svn $
* Revision 2.1 2004/08/11 05:06:21 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.0 2002/06/03 04:02:21 penguin
* Warpcore CVS sync
*
* Revision 1.1 2002/05/02 18:03:04 mharris
* Initial checkin - converted filenames and includes to lower case
*
@@ -37,7 +31,6 @@
* $NoKeywords: $
*/
#ifndef _FS2_DEMO_SYSTEM_HEADER_FILE
#define _FS2_DEMO_SYSTEM_HEADER_FILE
+7 -24
View File
@@ -2,15 +2,14 @@
#include <stdio.h>
#include "osapi/osapi.h"
#include "directx/dx8show.h"
#include "dx8show.h"
#include "debugconsole/dbugfile.h"
#include "graphics/2d.h"
#include <commctrl.h>
#include <commdlg.h>
#include <tchar.h>
//#include <atlbase.h> // No dependecy on ATL!!!
#include <atlbase.h>
enum PLAYSTATE {Stopped, Paused, Running, Init};
@@ -94,7 +93,7 @@ BOOL IsAudioOnly()
HRESULT PlayMovieInWindow(HWND ghApp, LPTSTR szFile)
{
// USES_CONVERSION;
USES_CONVERSION;
WCHAR wFile[MAX_PATH];
HRESULT hr;
@@ -102,8 +101,7 @@ HRESULT PlayMovieInWindow(HWND ghApp, LPTSTR szFile)
UpdateWindow(ghApp);
// Convert filename to wide character string
// wcscpy(wFile, T2W(szFile)); // requires ATL
swprintf(wFile, L"%S", szFile); // Uses libc to convert instead
wcscpy(wFile, T2W(szFile));
// Get the interface for DirectShow's GraphBuilder
JIF(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
@@ -159,8 +157,7 @@ HRESULT PlayMovieInWindow(HWND ghApp, LPTSTR szFile)
return hr;
}
extern int Cmdline_window;
extern int Cmdline_noscalevid;
HRESULT InitVideoWindow(HWND ghApp, long video_w, long video_h)
{
HRESULT hr = S_OK;
@@ -171,25 +168,11 @@ HRESULT InitVideoWindow(HWND ghApp, long video_w, long video_h)
int screen_w = rect.right;
int screen_h = rect.bottom;
int video_rescale_w;
int video_rescale_h;
if (Cmdline_noscalevid && (video_w < screen_w) && (video_h < screen_h)) {
video_rescale_w = video_w;
video_rescale_h = video_h;
} else {
video_rescale_w = (video_w * screen_w) / video_w;
video_rescale_h = (video_rescale_w * video_h) / video_w;
}
int video_rescale_w = (video_w * screen_w) / video_w;
int video_rescale_h = (video_rescale_w * video_h) / video_w;
int extra_w = (screen_w - video_rescale_w) / 2;
int extra_h = (screen_h - video_rescale_h) / 2;
if (Cmdline_window)
{
rect.right += GetSystemMetrics(SM_CXFIXEDFRAME) * 2;
rect.bottom += 2 * GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION);
}
if(SetWindowPos(ghApp, 0, 0, 0, rect.right, rect.bottom, SWP_NOMOVE | SWP_NOOWNERZORDER) == FALSE) {
-1
View File
@@ -1,4 +1,3 @@
#ifndef _DX8SHOW_HEADER_FILE
#define _DX8SHOW_HEADER_FILE
-1
View File
@@ -5,7 +5,6 @@
* File: async.h
* Content: AsyncData object include file
***************************************************************************/
#ifndef __ASYNC_INCLUDED__
#define __ASYNC_INCLUDED__
-1
View File
@@ -5,7 +5,6 @@
* File: dplobby.h
* Content: DirectPlayLobby include file
***************************************************************************/
#ifndef __DPLOBBY_INCLUDED__
#define __DPLOBBY_INCLUDED__
-1
View File
@@ -6,7 +6,6 @@
* Content: DirectXSetup, error codes and flags
***************************************************************************/
#ifndef __DSETUP_H__
#define __DSETUP_H__
-1
View File
@@ -7,7 +7,6 @@
*
**************************************************************************/
#ifndef __DSOUND_INCLUDED__
#define __DSOUND_INCLUDED__
-1
View File
@@ -7,7 +7,6 @@
*
***************************************************************************/
#ifndef __DVP_INCLUDED__
#define __DVP_INCLUDED__
#if defined( _WIN32 ) && !defined( _NO_COM )
@@ -9,24 +9,13 @@
/*
* $Logfile: /Freespace2/code/ExceptionHandler/ExceptionHandler.cpp $
* $Revision: 2.8 $
* $Date: 2005-01-31 23:27:52 $
* $Author: taylor $
* $Revision: 2.5 $
* $Date: 2004-03-31 05:42:26 $
* $Author: Goober5000 $
*
* Main file for dealing with exception handling
*
* $Log: not supported by cvs2svn $
* Revision 2.7 2004/07/26 20:47:27 Kazan
* remove MCD complete
*
* Revision 2.6 2004/07/12 16:32:45 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.5 2004/03/31 05:42:26 Goober5000
* got rid of all those nasty warnings from xlocale and so forth; also added comments
* for #pragma warning disable to indicate the message being disabled
* --Goober5000
*
* Revision 2.4 2004/03/06 23:28:22 bobboau
* fixed motion debris
* animated laser textures
@@ -76,11 +65,9 @@ information after crashes. See exceptionhandler.h for information
on how to hook it in.
*/
#ifdef _WIN32
#include <windows.h>
#pragma warning(disable:4711) // function selected for inlining
// --------------------
@@ -563,5 +550,3 @@ int __cdecl RecordExceptionInfo(PEXCEPTION_POINTERS data, const char *Message)
return EXCEPTION_CONTINUE_SEARCH;
}
#endif // _WIN32
@@ -9,23 +9,13 @@
/*
* $Logfile: /Freespace2/code/ExceptionHandler/ExceptionHandler.h $
* $Revision: 2.4 $
* $Date: 2005-07-13 02:50:52 $
* $Author: Goober5000 $
* $Revision: 2.1 $
* $Date: 2002-07-07 19:55:58 $
* $Author: penguin $
*
* Header file for program exception handling
*
* $Log: not supported by cvs2svn $
* Revision 2.3 2005/04/12 05:26:36 taylor
* many, many compiler warning and header fixes (Jens Granseuer)
* fix free on possible NULL in modelinterp.cpp (Jens Granseuer)
*
* Revision 2.2 2004/08/11 05:06:22 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.1 2002/07/07 19:55:58 penguin
* Back-port to MSVC
*
* Revision 2.0 2002/06/03 04:02:22 penguin
* Warpcore CVS sync
*
@@ -45,12 +35,13 @@
* $NoKeywords: $
*/
#ifdef _MSC_VER
#pragma once // Include this file only once
#endif
#ifndef __EXCEPTION_HANDLER_H
#define __EXCEPTION_HANDLER_H
// --------------------
//
// Defines
+14 -101
View File
@@ -9,73 +9,13 @@
/*
* $Logfile: /Freespace2/code/Fireball/FireBalls.cpp $
* $Revision: 2.26 $
* $Date: 2005-04-05 05:53:15 $
* $Author: taylor $
* $Revision: 2.12 $
* $Date: 2004-05-12 22:49:14 $
* $Author: phreak $
*
* Code to move, render and otherwise deal with fireballs.
*
* $Log: not supported by cvs2svn $
* Revision 2.25 2005/03/19 18:02:33 bobboau
* added new graphic functions for state blocks
* also added a class formanageing a new effect
*
* Revision 2.24 2005/03/14 03:24:25 taylor
* speedup grow/shrink time for the warp to avoid the big size skips
*
* Revision 2.23 2005/03/10 08:00:02 taylor
* change min/max to MIN/MAX to fix GCC problems
* add lab stuff to Makefile
* build unbreakage for everything that's not MSVC++ 6
* lots of warning fixes
* fix OpenGL rendering problem with ship insignias
* no Warnings() in non-debug mode for Linux (like Windows)
* some campaign savefile fixage to stop reverting everyones data
*
* Revision 2.22 2005/03/01 06:55:40 bobboau
* oh, hey look I've commited something :D
* animation system, weapon models detail box alt-tab bug, probly other stuff
*
* Revision 2.21 2005/02/23 05:05:39 taylor
* compiler warning fixes (for MSVC++ 6)
* have the warp effect only load as many LODs as will get used
* head off strange bug in release when corrupt soundtrack number gets used
* (will still Assert in debug)
* don't ever try and save a campaign savefile in multi or standalone modes
* first try at 32bit->16bit color conversion for TGA code (for TGA only ship textures)
*
* Revision 2.20 2005/01/30 09:27:39 Goober5000
* nitpicked some boolean tests, and fixed two small bugs
* --Goober5000
*
* Revision 2.19 2004/11/01 20:57:03 taylor
* make use of Knossos_warp_ani_used flag - thanks Goober5000
*
* Revision 2.18 2004/10/31 02:26:15 Goober5000
* whoops
* --Goober5000
*
* Revision 2.17 2004/10/31 02:04:33 Goober5000
* added Knossos_warp_ani_used flag for taylor
* --Goober5000
*
* Revision 2.16 2004/09/17 07:12:22 Goober5000
* changed around the logic for the 3D warp effect
* --Goober5000
*
* Revision 2.15 2004/08/23 04:32:39 Goober5000
* warp effect is back to FS2 default
* --Goober5000
*
* Revision 2.14 2004/07/26 20:47:28 Kazan
* remove MCD complete
*
* Revision 2.13 2004/07/12 16:32:45 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.12 2004/05/12 22:49:14 phreak
* renamed the warp model variable from 'wm' to 'Warp_model'
*
* Revision 2.11 2004/03/17 04:07:29 bobboau
* new fighter beam code
* fixed old after burner trails
@@ -448,18 +388,14 @@
#include "cmdline/cmdline.h"
#include "parse/parselo.h"
int Warp_model;
int Knossos_warp_ani_used;
#define WARPHOLE_GROW_TIME (2.5f) // time for warphole to reach max size (also time to shrink to nothing once it begins to shrink)
#define WARPHOLE_GROW_TIME (3.5f) // time for warphole to reach max size (also time to shrink to nothing once it begins to shrink)
#define MAX_FIREBALL_LOD 4
#define MAX_FIREBALLS 200
#define MAX_WARP_LOD 0
fireball Fireballs[MAX_FIREBALLS];
fireball_info Fireball_info[MAX_FIREBALL_TYPES];
@@ -469,7 +405,6 @@ int Num_fireballs = 0;
int fireballs_inited = 0;
int Warp_glow_bitmap = -1;
int Warp_ball_bitmap = -1;
#define FB_INDEX(fb) (fb-Fireballs)
@@ -589,10 +524,6 @@ void fireball_load_data()
fd = &Fireball_info[i];
for(idx=0; idx<fd->lod_count; idx++){
// we won't use a warp effect lod greater than MAX_WARP_LOD so don't load it either
if ( (i == FIREBALL_WARP_EFFECT) && (idx > MAX_WARP_LOD) )
continue;
fd->lod[idx].bitmap_id = bm_load_animation( fd->lod[idx].filename, &fd->lod[idx].num_frames, &fd->lod[idx].fps, 1 );
if ( fd->lod[idx].bitmap_id < 0 ) {
Error(LOCATION, "Could not load %s anim file\n", fd->lod[idx].filename);
@@ -603,9 +534,6 @@ void fireball_load_data()
if ( Warp_glow_bitmap == -1 ) {
Warp_glow_bitmap = bm_load( NOX("warpglow01") );
}
if ( Warp_ball_bitmap == -1 ) {
Warp_ball_bitmap = bm_load( NOX("warpball01") );
}
// polymodel Warp_pm;
@@ -636,9 +564,6 @@ void fireball_init()
Fireballs[i].objnum = -1;
}
// Goober5000 - reset Knossos warp flag
Knossos_warp_ani_used = 0;
mprintf(("loading warp model"));
Warp_model = -1;
Warp_model = model_load("warp.pof", 0, NULL, 0);
@@ -727,7 +652,7 @@ void fireball_render(object * obj)
// obj->alt_rad = rad;
warpin_render(obj, &obj->orient, &obj->pos, Fireballs[num].current_bitmap, rad, percent_life, obj->radius, (Fireballs[num].flags & FBF_WARP_3D) );
warpin_render(obj, &obj->orient, &obj->pos, Fireballs[num].current_bitmap, rad, percent_life, obj->radius, (Fireballs[num].flags & FBF_WARP_FORCE_OLD) );
}
break;
@@ -870,7 +795,7 @@ int fireball_free_one()
fb = &Fireballs[i];
// only remove the ones that aren't warp effects
if ( (fb->objnum >= 0) && fireball_is_perishable(&Objects[fb->objnum]) ) {
if ( (fb->objnum>-1) && fireball_is_perishable(&Objects[fb->objnum]) ) {
lifeleft = fb->total_time - fb->time_elapsed;
if ( (oldest_objnum < 0) || (lifeleft < oldest_lifeleft) ) {
@@ -986,15 +911,11 @@ float fireball_lifeleft_percent( object *obj )
fb = &Fireballs[num];
// Assert((fb->total_time - fb->time_elapsed) / fb->total_time >=0);
float p = (fb->total_time - fb->time_elapsed) / fb->total_time;
if (p < 0)p=0.0f;
return p;
return (fb->total_time - fb->time_elapsed) / fb->total_time;
}
// determine LOD to use
int fireball_get_lod(vec3d *pos, fireball_info *fd, float size)
int fireball_get_lod(vector *pos, fireball_info *fd, float size)
{
vertex v;
int x, y, w, h, bm_size;
@@ -1023,7 +944,7 @@ int fireball_get_lod(vec3d *pos, fireball_info *fd, float size)
// if vertex is behind, find size if in front, then drop down 1 LOD
if (v.codes & CC_BEHIND) {
float dist = vm_vec_dist_quick(&Eye_position, pos);
vec3d temp;
vector temp;
behind = 1;
vm_vec_scale_add(&temp, &Eye_position, &Eye_matrix.vec.fvec, dist);
@@ -1072,11 +993,11 @@ int fireball_get_lod(vec3d *pos, fireball_info *fd, float size)
}
// return the best lod
return MIN(ret_lod, fd->lod_count - 1);
return min(ret_lod, fd->lod_count - 1);
}
// Create a fireball, return object index.
int fireball_create( vec3d * pos, int fireball_type, int parent_obj, float size, int reverse, vec3d *velocity, float warp_lifetime, int ship_class, matrix *orient_override, int low_res, int extra_flags, int warp_open_sound, int warp_close_sound)
int fireball_create( vector * pos, int fireball_type, int parent_obj, float size, int reverse, vector *velocity, float warp_lifetime, int ship_class, matrix *orient_override, int low_res, int extra_flags, int warp_open_sound, int warp_close_sound)
{
int n, objnum, fb_lod;
object *obj;
@@ -1130,7 +1051,7 @@ int fireball_create( vec3d * pos, int fireball_type, int parent_obj, float size,
// change lod if low res is desired
if (low_res) {
fb_lod++;
fb_lod = MIN(fb_lod, fd->lod_count - 1);
fb_lod = min(fb_lod, fd->lod_count - 1);
}
// if this is a warpout fireball, never go higher than LOD 1
@@ -1140,7 +1061,7 @@ int fireball_create( vec3d * pos, int fireball_type, int parent_obj, float size,
fb_lod = 1;
}
*/
fb_lod = MAX_WARP_LOD;
fb_lod = 0;
}
fl = &fd->lod[fb_lod];
@@ -1270,15 +1191,7 @@ void fireballs_page_in()
for ( i = 0; i < MAX_FIREBALL_TYPES ; i++ ) {
fd = &Fireball_info[i];
// if this is a Knossos ani, only load if Knossos_warp_ani_used is true
if ( (i == FIREBALL_KNOSSOS_EFFECT) && !Knossos_warp_ani_used)
continue;
for(idx=0; idx<fd->lod_count; idx++) {
// we won't use a warp effect lod greater than MAX_WARP_LOD so don't load it either
if ( (i == FIREBALL_WARP_EFFECT) && (idx > MAX_WARP_LOD) )
continue;
for(idx=0; idx<fd->lod_count; idx++){
bm_page_in_texture( fd->lod[idx].bitmap_id, fd->lod[idx].num_frames );
}
}
+6 -35
View File
@@ -9,38 +9,13 @@
/*
* $Logfile: /Freespace2/code/Fireball/FireBalls.h $
* $Revision: 2.14 $
* $Date: 2005-07-13 02:50:52 $
* $Author: Goober5000 $
* $Revision: 2.7 $
* $Date: 2004-05-12 22:49:13 $
* $Author: phreak $
*
* Prototypes for fireball functions
*
* $Log: not supported by cvs2svn $
* Revision 2.13 2005/04/05 05:53:15 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.12 2005/03/19 18:02:33 bobboau
* added new graphic functions for state blocks
* also added a class formanageing a new effect
*
* Revision 2.11 2004/10/31 02:04:33 Goober5000
* added Knossos_warp_ani_used flag for taylor
* --Goober5000
*
* Revision 2.10 2004/09/17 07:12:22 Goober5000
* changed around the logic for the 3D warp effect
* --Goober5000
*
* Revision 2.9 2004/08/23 04:32:39 Goober5000
* warp effect is back to FS2 default
* --Goober5000
*
* Revision 2.8 2004/08/11 05:06:22 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.7 2004/05/12 22:49:13 phreak
* renamed the warp model variable from 'wm' to 'Warp_model'
*
* Revision 2.6 2004/03/17 04:07:29 bobboau
* new fighter beam code
* fixed old after burner trails
@@ -245,7 +220,7 @@ typedef struct fireball_info {
#define FBF_WARP_CLOSE_SOUND_PLAYED (1<<0)
#define FBF_WARP_CAPITAL_SIZE (1<<1)
#define FBF_WARP_CRUISER_SIZE (1<<2)
#define FBF_WARP_3D (1<<3) // Goober5000
#define FBF_WARP_FORCE_OLD (1<<3) // Goober5000
#define FBF_WARP_VIA_SEXP (1<<4) // Goober5000
typedef struct fireball {
@@ -271,7 +246,7 @@ void fireball_process_post(object * obj, float frame_time);
// reversed is for warp_in/out effects
// Velocity: If not NULL, the fireball will move at a constant velocity.
// warp_lifetime: If warp_lifetime > 0.0f then makes the explosion loop so it lasts this long. Only works for warp effect
int fireball_create(vec3d *pos, int fireball_type, int parent_obj, float size, int reversed=0, vec3d *velocity=NULL, float warp_lifetime=0.0f, int ship_class=-1, matrix *orient=NULL, int low_res=0, int extra_flags=0, int warp_open_sound=0, int warp_close_sound=0);
int fireball_create(vector *pos, int fireball_type, int parent_obj, float size, int reversed=0, vector *velocity=NULL, float warp_lifetime=0.0f, int ship_class=-1, matrix *orient=NULL, int low_res=0, int extra_flags=0, int warp_open_sound=0, int warp_close_sound=0);
void fireball_render_plane(int plane);
void fireball_close();
void fireball_level_close();
@@ -290,13 +265,9 @@ float fireball_lifeleft( object *obj );
float fireball_lifeleft_percent( object *obj );
// internal function to draw warp grid.
extern void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_num, float radius, float life_percent, float max_radius, int warp_3d = 0 );
extern void warpin_render(object *obj, matrix *orient, vector *pos, int texture_bitmap_num, float radius, float life_percent, float max_radius, int force_old = 0 );
extern int Warp_glow_bitmap; // Internal
extern int Warp_ball_bitmap; // Internal
extern int Warp_model;
// Goober5000
extern int Knossos_warp_ani_used;
#endif /* _FIREBALLS_H */
+74 -154
View File
@@ -9,66 +9,13 @@
/*
* $Logfile: /Freespace2/code/Fireball/WarpInEffect.cpp $
* $Revision: 2.30 $
* $Date: 2005-08-25 22:40:02 $
* $Author: taylor $
* $Revision: 2.15 $
* $Date: 2004-05-12 22:49:13 $
* $Author: phreak $
*
* Code for rendering the warp in effects for ships
*
* $Log: not supported by cvs2svn $
* Revision 2.29 2005/07/25 05:24:17 Goober5000
* cleaned up some command line and mission flag stuff
* --Goober5000
*
* Revision 2.28 2005/07/23 17:27:50 Goober5000
* remove Bobboau's extra warp thing
* --Goober5000
*
* Revision 2.27 2005/05/22 22:47:19 phreak
* compile warning fixage.
*
* Revision 2.26 2005/04/05 05:53:15 taylor
* s/vector/vec3d/g, better support for different compilers (Jens Granseuer)
*
* Revision 2.25 2005/03/25 06:57:33 wmcoolmon
* Big, massive, codebase commit. I have not removed the old ai files as the ones I uploaded aren't up-to-date (But should work with the rest of the codebase)
*
* Revision 2.24 2005/03/19 18:02:33 bobboau
* added new graphic functions for state blocks
* also added a class formanageing a new effect
*
* Revision 2.23 2005/01/01 19:47:26 taylor
* make use of MR_NO_FOGGING to render models without fog
*
* Revision 2.22 2004/11/23 19:29:13 taylor
* fix 2d warp in D3D, add cmdline option for 3d warp
*
* Revision 2.21 2004/09/17 07:12:22 Goober5000
* changed around the logic for the 3D warp effect
* --Goober5000
*
* Revision 2.20 2004/08/23 04:32:39 Goober5000
* warp effect is back to FS2 default
* --Goober5000
*
* Revision 2.19 2004/07/26 20:47:28 Kazan
* remove MCD complete
*
* Revision 2.18 2004/07/17 09:29:13 taylor
* make old warpmap and new glow bitmap 3D unlit to render right in OGL
*
* Revision 2.17 2004/07/12 16:32:46 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.16 2004/07/05 05:09:18 bobboau
* FVF code, only the data that is needed is sent off to the card,,
* OGL can take advantage of this if they want but it won't break
* anything if they don't. also state block code has been implemented,
* that's totaly internal to D3D no high level code is involved.
*
* Revision 2.15 2004/05/12 22:49:13 phreak
* renamed the warp model variable from 'wm' to 'Warp_model'
*
* Revision 2.14 2004/05/08 01:08:48 Goober5000
* small fix
* --Goober5000
@@ -239,31 +186,26 @@
#include "render/3d.h"
#include "fireball/fireballs.h"
#include "mission/missionparse.h"
#include "nebula/neb.h"
#include "Nebula/Neb.h"
#include "globalincs/pstypes.h"
#include "model/model.h"
extern int Warp_model;
extern int Cmdline_nohtl;
extern int Cmdline_3dwarp;
DCF(norm,"normalize a zero length vector")
{
if ( Dc_command ) {
vec3d tmp = vmd_zero_vector;
vector tmp = vmd_zero_vector;
vm_vec_normalize(&tmp);
}
}
void draw_face( vertex *v1, vertex *v2, vertex *v3 )
{
vec3d norm;
vector norm;
vertex *vertlist[3];
vm_vec_perp(&norm,(vec3d *)&v1->x,(vec3d *)&v2->x,(vec3d *)&v3->x);
if ( vm_vec_dot(&norm,(vec3d *)&v1->x ) >= 0.0 ) {
vm_vec_perp(&norm,(vector *)&v1->x,(vector *)&v2->x,(vector *)&v3->x);
if ( vm_vec_dot(&norm,(vector *)&v1->x ) >= 0.0 ) {
vertlist[0] = v3;
vertlist[1] = v2;
vertlist[2] = v1;
@@ -273,7 +215,7 @@ void draw_face( vertex *v1, vertex *v2, vertex *v3 )
vertlist[2] = v3;
}
g3_draw_poly( 3, vertlist, TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT );
g3_draw_poly( 3, vertlist, TMAP_FLAG_TEXTURED );
}
@@ -281,10 +223,8 @@ void draw_face( vertex *v1, vertex *v2, vertex *v3 )
#define wR_VERTICES() do { g3_rotate_vertex(verts[0], &bottom1); g3_rotate_vertex(verts[1], &bottom2); g3_rotate_vertex(verts[2], &top2); g3_rotate_vertex(verts[3], &top1); } while(0);
#define wP_VERTICES() do { for(idx=0; idx<4; idx++){ g3_project_vertex(verts[idx]); } } while(0);
void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_num, float radius, float life_percent, float max_radius, int warp_3d)
void warpin_render(object *obj, matrix *orient, vector *pos, int texture_bitmap_num, float radius, float life_percent, float max_radius, int force_old)
{
static flash_ball warp_ball(20, .1f,.25f, &vmd_z_vector, &vmd_zero_vector, 4.0f, 0.5f);
int i;
int saved_gr_zbuffering = gr_zbuffer_get();
@@ -294,87 +234,35 @@ void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_n
float Grid_depth = radius/2.5f;
vec3d center;
vector center;
vm_vec_scale_add( &center, pos, &orient->vec.fvec, -(max_radius/2.5f)/3.0f );
// Warp_Map = texture_bitmap_num;//sets the warp map, and thus sets the interp flag for this being a warpin effect
vec3d vecs[5];
vector vecs[5];
vertex verts[5];
vecs[4] = center; //this is for the warp glow-Bobboau
verts[4].u = 0.5f; verts[4].v = 0.5f;
if(Warp_model > -1 && !force_old && !(The_mission.flags & MISSION_FLAG_OLD_WARP_EFFECT)){
float model_Interp_scale_x = radius /20;
float model_Interp_scale_y = radius /20;
float model_Interp_scale_z = radius /20;
if (Cmdline_nohtl) {
g3_rotate_vertex( &verts[4], &vecs[4] );
} else {
g3_transfer_vertex( &verts[4], &vecs[4] );
}
if ( Warp_glow_bitmap != -1 ) {
gr_set_bitmap( Warp_glow_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, (The_mission.flags & MISSION_FLAG_FULLNEB)?(1.0f - neb2_get_fog_intensity(obj)):1.0f );
float r = radius;
int render_it;
#define OUT_PERCENT1 0.80f
#define OUT_PERCENT2 0.90f
#define IN_PERCENT1 0.10f
#define IN_PERCENT2 0.20f
if ( life_percent < IN_PERCENT1 ) {
// do nothing
render_it = 1;
} else if ( life_percent < IN_PERCENT2 ) {
r *= ( life_percent-IN_PERCENT1 ) / (IN_PERCENT2-IN_PERCENT1);
render_it = 1;
} else if ( life_percent < OUT_PERCENT1 ) {
// do nothing
render_it = 1;
} else if ( life_percent < OUT_PERCENT2 ) {
r *= (OUT_PERCENT2 - life_percent) / (OUT_PERCENT2-OUT_PERCENT1);
render_it = 1;
} else {
// do nothing
render_it = 1;
}
if (render_it) {
int saved_gr_zbuffering = gr_zbuffer_get();
gr_zbuffer_set(GR_ZBUFF_READ);
// Add in noise
//float Noise[NOISE_NUM_FRAMES] = {
int noise_frame = fl2i(Missiontime/15.0f) % NOISE_NUM_FRAMES;
r *= (0.40f + Noise[noise_frame]*0.30f);
//Bobboau's warp thingie; this should be an option somewhere
//r += (float)pow((2.0f*life_percent) - 1.0f,24.0f)*max_radius*2.0f;
g3_draw_bitmap( &verts[4], 0, r, TMAP_FLAG_TEXTURED | TMAP_HTL_3D_UNLIT );
gr_zbuffer_set(saved_gr_zbuffering);
}
}
if((Warp_model >= 0) && (warp_3d || Cmdline_3dwarp))
{
float model_Interp_scale_xyz = radius / 20.0f;
set_warp_globals(model_Interp_scale_xyz, model_Interp_scale_xyz, model_Interp_scale_xyz, texture_bitmap_num, (radius/max_radius) );
set_warp_globals(model_Interp_scale_x, model_Interp_scale_y, model_Interp_scale_z, texture_bitmap_num, (radius/max_radius) );
float dist = vm_vec_dist_quick( pos, &Eye_position );
model_set_detail_level((int)(dist / (radius * 10.0f)));
gr_set_cull(0);
model_render( Warp_model, orient, pos, MR_NO_LIGHTING | MR_NORMAL | MR_NO_FOGGING);
model_render( Warp_model, orient, pos, MR_NO_LIGHTING | MR_NORMAL);
gr_set_cull(1);
// Warp_Map = -1;//un sets the warp map
set_warp_globals(1.0f, 1.0f, 1.0f, -1, -1.0f);
model_Interp_scale_x = 1.0f;
model_Interp_scale_y = 1.0f;
model_Interp_scale_z = 1.0f;
set_warp_globals(model_Interp_scale_x, model_Interp_scale_y, model_Interp_scale_z, -1, -1.0f);
/*
//this is that half done effect that was pissing people off-Bobboau
@@ -382,7 +270,7 @@ void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_n
gr_set_cull(0);
matrix m;
vec3d ray_dir;
vector ray_dir;
vm_vector_2_matrix(&m, &orient->vec.fvec, NULL, NULL);//this is the beam things that will come outof the point-Bobboau
float angle = ANG_TO_RAD(135.0f);
if(life_percent < 0.2f){
@@ -391,13 +279,13 @@ void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_n
for(int idx=0; idx<1; idx++){
vm_vec_random_cone(&ray_dir, &orient->vec.fvec, angle, &m);
mprintf(( "ray direction %f %f %f, orentation %f %f %f, angle %f\n",ray_dir.xyz.x, ray_dir.xyz.y, ray_dir.xyz.z, orient->vec.fvec.xyz.x, orient->vec.fvec.xyz.y, orient->vec.fvec.xyz.z, angle));
vec3d p_temp = *pos;
vector p_temp = *pos;
vm_vec_scale_add(&p_temp, pos, &ray_dir, (max_radius * 10 * frand_range(0.75f, 0.9f)));
mprintf(( "end %f %f %f",p_temp.xyz.x, p_temp.xyz.y, p_temp.xyz.z));
vertex h1[4]; // halves of a beam section
vertex *verts[4] = { &h1[0], &h1[1], &h1[2], &h1[3] };
vec3d top1, bottom1, top2, bottom2;
vector top1, bottom1, top2, bottom2;
beam_calc_facing_pts(&top1, &bottom1, &ray_dir, pos, 1.0f, 1.0f);
beam_calc_facing_pts(&top2, &bottom2, &ray_dir, &p_temp, 1.0f, 1.0f);
@@ -415,6 +303,9 @@ void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_n
gr_set_cull(1);
*/
vecs[4] = center; //this is for the warp glow-Bobboau
verts[4].u = 0.5f; verts[4].v = 0.5f;
g3_rotate_vertex( &verts[4], &vecs[4] );
}else{
gr_set_bitmap( texture_bitmap_num, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 1.0f );
@@ -445,30 +336,59 @@ void warpin_render(object *obj, matrix *orient, vec3d *pos, int texture_bitmap_n
verts[4].u = 0.5f; verts[4].v = 0.5f;
for (i=0; i<5; i++ ) {
if (Cmdline_nohtl) {
g3_rotate_vertex( &verts[i], &vecs[i] );
} else {
g3_transfer_vertex( &verts[i], &vecs[i] );
}
g3_rotate_vertex( &verts[i], &vecs[i] );
}
gr_set_cull(0); // fixes rendering problem in D3D - taylor
draw_face( &verts[0], &verts[4], &verts[1] );
draw_face( &verts[1], &verts[4], &verts[2] );
draw_face( &verts[4], &verts[3], &verts[2] );
draw_face( &verts[0], &verts[3], &verts[4] );
gr_set_cull(1);
}
if ( Warp_glow_bitmap != -1 ) {
gr_set_bitmap( Warp_glow_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, (The_mission.flags & MISSION_FLAG_FULLNEB)?(1.0f - neb2_get_fog_intensity(obj)):1.0f );
float r = radius;
int render_it;
#define OUT_PERCENT1 0.80f
#define OUT_PERCENT2 0.90f
#define IN_PERCENT1 0.10f
#define IN_PERCENT2 0.20f
if ( life_percent < IN_PERCENT1 ) {
// do nothing
render_it = 0;
} else if ( life_percent < IN_PERCENT2 ) {
r *= ( life_percent-IN_PERCENT1 ) / (IN_PERCENT2-IN_PERCENT1);
render_it = 1;
} else if ( life_percent < OUT_PERCENT1 ) {
// do nothing
render_it = 1;
} else if ( life_percent < OUT_PERCENT2 ) {
r *= (OUT_PERCENT2 - life_percent) / (OUT_PERCENT2-OUT_PERCENT1);
render_it = 1;
} else {
// do nothing
render_it = 0;
}
if (render_it) {
int saved_gr_zbuffering = gr_zbuffer_get();
gr_zbuffer_set(GR_ZBUFF_READ);
// Add in noise
//float Noise[NOISE_NUM_FRAMES] = {
int noise_frame = fl2i(Missiontime/15.0f) % NOISE_NUM_FRAMES;
r *= (0.40f + Noise[noise_frame]*0.30f);
g3_draw_bitmap( &verts[4], 0,r, TMAP_FLAG_TEXTURED );
gr_zbuffer_set(saved_gr_zbuffering);
}
}
if ( Warp_ball_bitmap > -1 ){
g3_start_instance_matrix(pos,orient, true);
gr_set_bitmap(Warp_ball_bitmap, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, 0.9999f);
float adg = (2.0f*life_percent) - 1.0f;
float pct= (float)(pow(adg,4.0f)-pow(adg,128.0f))*4.0f;
if(pct > 0.00001f)
warp_ball.render(max_radius*pct/2.0f,adg*adg,adg*adg*6.0f);
g3_done_instance(true);
}
gr_zbuffer_set( saved_gr_zbuffering );
}
File diff suppressed because it is too large. Load diff
+6 -35
View File
@@ -9,28 +9,13 @@
/*
* $Logfile: /Freespace2/code/FREESPACE2/FreeSpace.h $
* $Revision: 2.7 $
* $Date: 2005-07-13 02:50:52 $
* $Author: Goober5000 $
* $Revision: 2.2 $
* $Date: 2004-04-07 03:31:53 $
* $Author: righteous1 $
*
* FreeSpace, the game, not the project, header information.
*
* $Log: not supported by cvs2svn $
* Revision 2.6 2005/06/03 06:39:26 taylor
* better audio pause/unpause support when game window loses focus or is minimized
*
* Revision 2.5 2005/03/03 06:05:27 wmcoolmon
* Merge of WMC's codebase. "Features and bugs, making Goober say "Grr!", as release would be stalled now for two months for sure"
*
* Revision 2.4 2004/10/31 21:31:34 taylor
* bump COUNT_ESTIMATE, reset time compression at the start of a mission, new pilot file support, add feature_disabled popup
*
* Revision 2.3 2004/08/11 05:06:22 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.2 2004/04/07 03:31:53 righteous1
* Updated to add alt_tab_pause() function to draw pause screen and discontinue sounds when the game is minimized. -R1
*
* Revision 2.1 2002/08/01 01:41:04 penguin
* The big include file move
*
@@ -204,7 +189,6 @@
// frametime/missiontime variables
extern fix Frametime;
extern float flRealframetime;
extern float flFrametime;
extern fix Missiontime;
@@ -219,7 +203,6 @@ extern int Game_mode;
extern int Game_do_state_should_skip;
// time compression
extern bool Time_compression_locked;
extern fix Game_time_compression;
// Set if subspace is active this level
@@ -283,15 +266,6 @@ int game_poll();
// function to read keyboard stuff
void game_process_keys();
// call this when you don't want the user changing time compression
void lock_time_compression(bool is_locked);
// call this to set time compression properly
void set_time_compression(float multiplier, float change_time = 0);
//call this to change the relative time compression (ie double it)
void change_time_compression(float multiplier);
// call this to set frametime properly (once per frame)
void game_set_frametime(int state);
@@ -370,9 +344,6 @@ int game_do_cd_mission_check(char *filename);
// Used to tell the player that a feature isn't available in the demo version of FreeSpace
void game_feature_not_in_demo_popup();
// Used to tell the player that a feature is disabled by build settings
void game_feature_disabled_popup();
// Return version string for demo or full version, depending on build.
void get_version_string(char *str);
@@ -385,9 +356,9 @@ int game_hacked_data();
// show the oem upsell screens (end of campaign, or close of game
void oem_upsell_show_screens();
// calls to be executed when the game is put in or restored from minimized or inactive state
void game_pause();
void game_unpause();
// function to handle pausing the game when the game is minimized
// called from osapi.cpp
void alt_tab_pause();
#endif // endif of #ifndef STAMPER_PROGRAM
#endif
+9 -34
View File
@@ -9,33 +9,13 @@
/*
* $Logfile: /Freespace2/code/Freespace2/LevelPaging.cpp $
* $Revision: 2.8 $
* $Date: 2005-04-21 15:58:07 $
* $Author: taylor $
* $Revision: 2.2 $
* $Date: 2004-03-05 09:02:01 $
* $Author: Goober5000 $
*
* Code to page in all the bitmaps at the beginning of a level.
*
* $Log: not supported by cvs2svn $
* Revision 2.7 2005/02/04 20:06:03 taylor
* merge with Linux/OSX tree - p0204-2
*
* Revision 2.6 2004/07/26 20:47:29 Kazan
* remove MCD complete
*
* Revision 2.5 2004/07/12 16:32:46 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 2.4 2004/07/01 01:53:00 phreak
* function pointer radar update.
* will enable us to make different radar styles that we can switch between
*
* Revision 2.3 2004/06/18 04:59:53 wmcoolmon
* Only used weapons paged in instead of all, fixed music box in FRED, sound quality settable with SoundSampleRate and SoundSampleBits registry values
*
* Revision 2.2 2004/03/05 09:02:01 Goober5000
* Uber pass at reducing #includes
* --Goober5000
*
* Revision 2.1 2002/08/01 01:41:04 penguin
* The big include file move
*
@@ -82,14 +62,13 @@
#include "freespace2/freespace.h"
#include "freespace2/levelpaging.h"
// All the page in functions
extern void ship_page_in();
extern void debris_page_in();
extern void particle_page_in();
extern void stars_page_in();
extern void hud_page_in();
extern void (*radar_page_in)();
extern void radar_page_in();
extern void weapons_page_in();
extern void fireballs_page_in();
extern void shockwave_page_in();
@@ -98,23 +77,20 @@ extern void asteroid_page_in();
extern void training_mission_page_in();
extern void neb2_page_in();
extern void message_pagein_mission_messages();
extern void model_page_in_stop();
// Pages in all the texutures for the currently
// loaded mission. Call game_busy() occasionally...
void level_page_in()
{
// moved to freespace.cpp on 2005/04/18 - taylor
// mprintf(( "Beginning level bitmap paging...\n" ));
//
// if(!(Game_mode & GM_STANDALONE_SERVER)){
// bm_page_in_start();
// }
mprintf(( "Beginning level bitmap paging...\n" ));
if(!(Game_mode & GM_STANDALONE_SERVER)){
bm_page_in_start();
}
// Most important ones first
ship_page_in();
//Must be called after paging in ships
weapons_page_in();
fireballs_page_in();
particle_page_in();
@@ -134,7 +110,6 @@ void level_page_in()
}
if(!(Game_mode & GM_STANDALONE_SERVER)){
model_page_in_stop(); // free any loaded models that aren't used
bm_page_in_stop();
}
+3 -9
View File
@@ -9,19 +9,13 @@
/*
* $Logfile: /Freespace2/code/FREESPACE2/LevelPaging.h $
* $Revision: 2.2 $
* $Date: 2005-07-13 02:50:52 $
* $Author: Goober5000 $
* $Revision: 2.0 $
* $Date: 2002-06-03 04:02:22 $
* $Author: penguin $
*
* Code to page in all the bitmaps at the beginning of a level.
*
* $Log: not supported by cvs2svn $
* Revision 2.1 2004/08/11 05:06:22 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 2.0 2002/06/03 04:02:22 penguin
* Warpcore CVS sync
*
* Revision 1.1 2002/05/02 18:03:07 mharris
* Initial checkin - converted filenames and includes to lower case
*
+15 -64
View File
@@ -10,45 +10,12 @@
/*
* $Logfile: /Freespace2/code/fs2open_pxo/Client.cpp $
* $Revision: 1.21 $
* $Date: 2005-07-13 02:50:49 $
* $Author: Goober5000 $
* $Revision: 1.13 $
* $Date: 2004-03-07 23:07:20 $
* $Author: Kazan $
*
*
* $Log: not supported by cvs2svn $
* Revision 1.20 2005/03/02 21:18:18 taylor
* better support for Inferno builds (in PreProcDefines.h now, no networking support)
* make sure NO_NETWORK builds are as friendly on Windows as it is on Linux/OSX
* revert a timeout in Client.h back to the original value before Linux merge
*
* Revision 1.19 2005/02/23 13:17:04 taylor
* few more compiler warning fixes (didn't mean to commit iostream.h change)
* lower warning level to 3 to stop MSVC6 from complaining about C++ headers
*
* Revision 1.18 2005/02/23 05:05:37 taylor
* compiler warning fixes (for MSVC++ 6)
* have the warp effect only load as many LODs as will get used
* head off strange bug in release when corrupt soundtrack number gets used
* (will still Assert in debug)
* don't ever try and save a campaign savefile in multi or standalone modes
* first try at 32bit->16bit color conversion for TGA code (for TGA only ship textures)
*
* Revision 1.17 2005/02/04 20:06:03 taylor
* merge with Linux/OSX tree - p0204-2
*
* Revision 1.16 2004/11/21 16:07:22 Kazan
* dumbbugfix
*
* Revision 1.15 2004/11/18 00:05:36 Goober5000
* #pragma'd a bunch of warnings
* --Goober5000
*
* Revision 1.14 2004/05/25 00:21:39 wmcoolmon
* Updated to use <iostream> instead of <iostream.h>
*
* Revision 1.13 2004/03/07 23:07:20 Kazan
* [Incomplete] Readd of Software renderer so Standalone server works
*
* Revision 1.12 2004/03/05 09:01:56 Goober5000
* Uber pass at reducing #includes
* --Goober5000
@@ -84,29 +51,15 @@
*
*/
#ifndef NO_NETWORK
// 4711 = function selected for automatic inline expansion
#pragma warning(disable: 4711)
#include <iostream>
#include "Client.h"
//#include "protocol.h"
#include "udpsocket.h"
#include <iostream.h>
#include <time.h>
#include "fs2open_pxo/Client.h"
//#include "fs2open_pxo/protocol.h"
#include "fs2open_pxo/udpsocket.h"
#include "network/multi_log.h"
#include "playerman/player.h"
#include "ship/ship.h"
PXO_Socket FS2OpenPXO_Socket;
// NOTE: CLK_TCK is depreciated but available for compatibility, use CLOCKS_PER_SEC instead
#ifndef CLK_TCK
#define CLK_TCK CLOCKS_PER_SEC
#endif
#define PXO_ADDINT(n) *((int *)cur) = (n); cur += sizeof(int);
#define PXO_ADDSTRING(x, y) memcpy(cur, x, y); cur += y;
@@ -131,7 +84,7 @@ int CheckSingleMission(const char* mission, unsigned int crc32, UDP_Socket &Sock
if (Socket.SendPacket((char *) &checkpack, sizeof(fs2open_file_check_single), sender, port) == -1)
return -1;
return NULL;
fs2open_fcheck_reply c_reply;
@@ -215,7 +168,7 @@ int SendPlayerData(int SID, const char* player_name, const char* user, player *p
// send Packet
if (Socket.SendPacket(PacketBuffer, packet_size, sender, port) == -1)
return -1;
return NULL;
fs2open_pilot_updatereply u_reply;
@@ -263,7 +216,7 @@ int GetPlayerData(int SID, const char* player_name, player *pl, const char* mast
// send Packet
if (Socket.SendPacket((char *)&prq_packet, sizeof(fs2open_get_pilot), sender, port) == -1)
return -1;
return NULL;
char PacketBuffer[16384]; // 16K should be enough i think..... I HOPE!
fs2open_pilot_reply *p_reply = (fs2open_pilot_reply *) PacketBuffer;
@@ -455,7 +408,7 @@ int Fs2OpenPXO_Login(const char* username, const char* password, UDP_Socket &Soc
if (Socket.SendPacket((char *) &loginpckt, sizeof(loginpckt), sender, port) == -1)
{
std::cout << "Error Sending Packet" << std::endl;
cout << "Error Sending Packet" << endl;
}
// await reply
@@ -504,8 +457,8 @@ void SendHeartBeat(const char* masterserver, int targetport, UDP_Socket &Socket,
hbpack.players = (short) players;
hbpack.port = port;
std::string ms = masterserver;
Socket.SendPacket((char *) &hbpack, (int)sizeof(serverlist_hb_packet), ms, targetport);
Socket.SendPacket((char *) &hbpack, sizeof(serverlist_hb_packet), std::string(masterserver), targetport);
}
@@ -588,7 +541,7 @@ int Ping(const char* target)
UDP_Socket Socket(FS2OPEN_CLIENT_PORT);
if (!Socket.InitSocket())
{
std::cout << "Initialization Error!" << std::endl;
cout << "Initialization Error!" << endl;
exit(1);
}
@@ -604,6 +557,4 @@ int Ping(const char* target)
Socket.GetPacket((char *)&rping, sizeof(fs2open_pingreply), rctp);
return int( float(time(0) - rping.time)/2.0 );
}
#endif // !NO_NETWORK
}
+41 -45
View File
@@ -10,31 +10,12 @@
/*
* $Logfile: /Freespace2/code/fs2open_pxo/Client.h $
* $Revision: 1.19 $
* $Date: 2005-07-13 02:50:49 $
* $Revision: 1.14 $
* $Date: 2004-03-31 05:42:26 $
* $Author: Goober5000 $
*
*
* $Log: not supported by cvs2svn $
* Revision 1.18 2005/03/02 21:18:18 taylor
* better support for Inferno builds (in PreProcDefines.h now, no networking support)
* make sure NO_NETWORK builds are as friendly on Windows as it is on Linux/OSX
* revert a timeout in Client.h back to the original value before Linux merge
*
* Revision 1.17 2005/02/04 20:06:03 taylor
* merge with Linux/OSX tree - p0204-2
*
* Revision 1.16 2004/08/11 05:06:23 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 1.15 2004/07/07 21:00:06 Kazan
* FS2NetD: C2S Ping/Pong, C2S Ping/Pong, Global IP Banlist, Global Network Messages
*
* Revision 1.14 2004/03/31 05:42:26 Goober5000
* got rid of all those nasty warnings from xlocale and so forth; also added comments
* for #pragma warning disable to indicate the message being disabled
* --Goober5000
*
* Revision 1.13 2004/03/09 00:02:16 Kazan
* more fs2netd stuff
*
@@ -68,11 +49,6 @@
*
*/
#if !defined(__pxo_client_h_)
#define __pxo_client_h_
#pragma warning(disable:4018) // signed/unsigned mismatch
#pragma warning(disable:4100) // unreferenced formal parameter
#pragma warning(disable:4511) // copy constructor could not be generated
@@ -80,20 +56,18 @@
#pragma warning(disable:4663) // new template specification syntax
#pragma warning(disable:4710) // function not inlined
#if !defined(__pxo_client_h_)
#define __pxo_client_h_
#define MAX_SERVERS 512
#include "fs2open_pxo/protocol.h"
#include "protocol.h"
#if !defined(PXO_TCP)
#include "fs2open_pxo/udpsocket.h"
typedef UDP_Socket PXO_Socket;
#include "udpsocket.h"
#else
#include "fs2open_pxo/TCP_Socket.h"
typedef TCP_Socket PXO_Socket;
#include "TCP_Socket.h"
#endif
extern PXO_Socket FS2OpenPXO_Socket;
struct player;
struct net_server
@@ -109,21 +83,43 @@ struct net_server
int port;
};
int SendPlayerData(int SID, const char* player_name, const char* user, player *pl, const char* masterserver, PXO_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=15);
int GetPlayerData(int SID, const char* player_name, player *pl, const char* masterserver, PXO_Socket &Socket, int port=FS2OPEN_PXO_PORT, bool CanCreate=false, int timeout=15);
int CheckSingleMission(const char* mission, unsigned int crc32, PXO_Socket &Socket, const char* masterserver, int port=FS2OPEN_PXO_PORT, int timeout=15);
net_server* GetServerList(const char* masterserver, int &numServersFound, PXO_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=15);
int Ping(const char* target, PXO_Socket &Socket);
void SendHeartBeat(const char* masterserver, int targetport, PXO_Socket &Socket, const char* myName, const char* MisName, const char* title, int flags, int port, int players);
int Fs2OpenPXO_Login(const char* username, const char* password, PXO_Socket &Socket, const char* masterserver, int port=FS2OPEN_PXO_PORT, int timeout=15);
int GetPingReply(PXO_Socket &Socket);
void SendPingReply(PXO_Socket &Socket, int tstamp);
fs2open_banmask* GetBanList(int &numBanMasks, PXO_Socket &Socket, int timeout=15);
#if !defined(PXO_TCP)
// ********************************************************************************************************
// UDP Version of PXO
// ********************************************************************************************************
// Variants of the above functions with persistant connections
int SendPlayerData(int SID, const char* player_name, const char* user, player *pl, const char* masterserver, UDP_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=15);
int GetPlayerData(int SID, const char* player_name, player *pl, const char* masterserver, UDP_Socket &Socket, int port=FS2OPEN_PXO_PORT, bool CanCreate=false, int timeout=15);
int CheckSingleMission(const char* mission, unsigned int crc32, UDP_Socket &Socket, const char* masterserver, int port=FS2OPEN_PXO_PORT, int timeout=15);
net_server* GetServerList(const char* masterserver, int &numServersFound, UDP_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=15);
int Ping(const char* target, UDP_Socket &Socket);
void SendHeartBeat(const char* masterserver, int targetport, UDP_Socket &Socket, const char* myName, const char* MisName, const char* title, int flags, int port, int players)
int Fs2OpenPXO_Login(const char* username, const char* password, UDP_Socket &Socket, const char* masterserver, int port=FS2OPEN_PXO_PORT, int timeout=15);
// longer timeouts - mySQL operations
file_record* GetTablesList(int &numTables, const char *masterserver, PXO_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=30);
file_record* GetMissionsList(int &numMissions, const char *masterserver, PXO_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=30);
file_record* GetTablesList(int &numTables, const char *masterserver, UDP_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=30);
file_record* GetMissionsList(int &numMissions, const char *masterserver, UDP_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=30);
#else
// ********************************************************************************************************
// TCP Version of PXO
// ********************************************************************************************************
int SendPlayerData(int SID, const char* player_name, const char* user, player *pl, const char* masterserver, TCP_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=15);
int GetPlayerData(int SID, const char* player_name, player *pl, const char* masterserver, TCP_Socket &Socket, int port=FS2OPEN_PXO_PORT, bool CanCreate=false, int timeout=15);
int CheckSingleMission(const char* mission, unsigned int crc32, TCP_Socket &Socket, const char* masterserver, int port=FS2OPEN_PXO_PORT, int timeout=15);
net_server* GetServerList(const char* masterserver, int &numServersFound, TCP_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=15);
int Ping(const char* target, TCP_Socket &Socket);
void SendHeartBeat(const char* masterserver, int targetport, TCP_Socket &Socket, const char* myName, const char* MisName, const char* title, int flags, int port, int players);
int Fs2OpenPXO_Login(const char* username, const char* password, TCP_Socket &Socket, const char* masterserver, int port=FS2OPEN_PXO_PORT, int timeout=15);
int GetPingReply(TCP_Socket &Socket);
// longer timeouts - mySQL operations
file_record* GetTablesList(int &numTables, const char *masterserver, TCP_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=30);
file_record* GetMissionsList(int &numMissions, const char *masterserver, TCP_Socket &Socket, int port=FS2OPEN_PXO_PORT, int timeout=30);
#endif
#endif
+75 -258
View File
@@ -11,76 +11,11 @@
/*
* $Logfile: /Freespace2/code/fs2open_pxo/TCP_Client.cpp $
* $Revision: 1.31 $
* $Date: 2005-07-13 02:50:49 $
* $Revision: 1.15 $
* $Date: 2004-03-31 05:42:26 $
* $Author: Goober5000 $
*
* $Log: not supported by cvs2svn $
* Revision 1.30 2005/06/29 18:49:37 taylor
* various FS2NetD fixes:
* - replace timer stuff with something that more accurately works cross-platform and without being affected by load
* - better sanity checking for the server list
* - working Linux compatibility that's not dog slow
* - when calling DataReady() make sure that the data is properly valid
* - fix messed up cvs merge cleanup from the Linux merge which did nasty things
*
* Revision 1.29 2005/06/21 00:13:47 taylor
* add some better error checking/handling for when GetServerList messes up
*
* Revision 1.28 2005/05/08 20:28:57 wmcoolmon
* Dynamically allocated medals
*
* Revision 1.27 2005/03/08 03:50:25 Goober5000
* edited for language ;)
* --Goober5000
*
* Revision 1.26 2005/03/02 21:18:18 taylor
* better support for Inferno builds (in PreProcDefines.h now, no networking support)
* make sure NO_NETWORK builds are as friendly on Windows as it is on Linux/OSX
* revert a timeout in Client.h back to the original value before Linux merge
*
* Revision 1.25 2005/02/23 13:17:04 taylor
* few more compiler warning fixes (didn't mean to commit iostream.h change)
* lower warning level to 3 to stop MSVC6 from complaining about C++ headers
*
* Revision 1.24 2005/02/23 05:05:37 taylor
* compiler warning fixes (for MSVC++ 6)
* have the warp effect only load as many LODs as will get used
* head off strange bug in release when corrupt soundtrack number gets used
* (will still Assert in debug)
* don't ever try and save a campaign savefile in multi or standalone modes
* first try at 32bit->16bit color conversion for TGA code (for TGA only ship textures)
*
* Revision 1.23 2005/02/04 20:06:03 taylor
* merge with Linux/OSX tree - p0204-2
*
* Revision 1.22 2004/11/18 00:05:36 Goober5000
* #pragma'd a bunch of warnings
* --Goober5000
*
* Revision 1.21 2004/07/26 20:47:29 Kazan
* remove MCD complete
*
* Revision 1.20 2004/07/12 16:32:46 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 1.19 2004/07/09 22:05:32 Kazan
* fs2netd 1.0 RC5 full support - Rank and Medal updates
*
* Revision 1.18 2004/07/07 21:00:06 Kazan
* FS2NetD: C2S Ping/Pong, C2S Ping/Pong, Global IP Banlist, Global Network Messages
*
* Revision 1.17 2004/07/06 23:45:34 Kazan
* minor multi fix
*
* Revision 1.16 2004/05/25 00:21:39 wmcoolmon
* Updated to use <iostream> instead of <iostream.h>
*
* Revision 1.15 2004/03/31 05:42:26 Goober5000
* got rid of all those nasty warnings from xlocale and so forth; also added comments
* for #pragma warning disable to indicate the message being disabled
* --Goober5000
*
* Revision 1.14 2004/03/09 17:59:01 Kazan
* Disabled multithreaded TCP_Socket in favor of safer single threaded
* FS2NetD doesn't kill the game on connection failure now - just gives warning message and effectively dsiables itself until they try to connect again
@@ -127,7 +62,7 @@
*
* Revision 1.3 2003/10/13 05:57:47 Kazan
* Removed a bunch of Useless *_printf()s in the rendering pipeline that were just slowing stuff down
* Commented out the "warning null vector in vector normalize" crap
* Commented out the "warning null vector in vector normalize" crap since we don't give a rats arse
* Added "beam no whack" flag for beams - said beams NEVER whack
* Some reliability updates in FS2NetD
*
@@ -135,25 +70,19 @@
*
*/
#ifndef NO_NETWORK
// 4018 = signed/unsigned mismatch
// 4663 = new template specification syntax
// 4245 = signed/unsigned mismatch in conversion of const value
// 4711 = function selected for automatic inline expansion
#pragma warning(disable: 4663 4018 4663 4245 4711)
#pragma warning(disable: 4663 4018 4663 4245)
#include <iostream>
#include "fs2open_pxo/Client.h"
#include "fs2open_pxo/protocol.h"
#include "fs2open_pxo/TCP_Socket.h"
#include "network/multi_log.h"
#include "Client.h"
#include "protocol.h"
#include "TCP_Socket.h"
#include <iostream.h>
#include "playerman/player.h"
#include "ship/ship.h"
#include "io/timer.h"
#include <time.h>
#include "network/multi_log.h"
#define PXO_ADDINT(n) *((int *)cur) = (n); cur += sizeof(int);
@@ -169,7 +98,8 @@ int CheckSingleMission(const char* mission, unsigned int crc32, TCP_Socket &Sock
// Clear any old dead crap data
Socket.IgnorePackets();
fix end_time = timer_get_fixed_seconds() + (timeout * F1_0);
timeout = timeout * CLK_TCK;
int starttime = clock();
std::string sender = masterserver;
@@ -183,12 +113,12 @@ int CheckSingleMission(const char* mission, unsigned int crc32, TCP_Socket &Sock
if (Socket.SendData((char *) &checkpack, sizeof(fs2open_file_check_single)) == -1)
return -1;
return NULL;
fs2open_fcheck_reply c_reply;
while ( timer_get_fixed_seconds() <= end_time )
while ((clock() - starttime) <= timeout)
{
if (Socket.DataReady() && Socket.GetData((char *) &c_reply, sizeof(fs2open_fcheck_reply)) != -1)
@@ -218,23 +148,25 @@ int SendPlayerData(int SID, const char* player_name, const char* user, player *p
// Clear any old dead crap data
Socket.IgnorePackets();
fix end_time = timer_get_fixed_seconds() + (timeout * F1_0);
timeout = timeout * CLK_TCK;
int starttime = clock();
std::string sender = masterserver;
char PacketBuffer[16384]; // 16K should be enough i think..... I HOPE!
memset(PacketBuffer,0, 16384);
// char *cur = PacketBuffer;
fs2open_pilot_update *p_update = (fs2open_pilot_update *) PacketBuffer;
fs2open_ship_typekill *type_kills = (fs2open_ship_typekill *) (PacketBuffer + 204);
int *medals = (int*)(PacketBuffer + 204 + (sizeof(fs2open_ship_typekill) * MAX_SHIP_TYPES));
fs2open_ship_typekill *type_kills = (fs2open_ship_typekill *) (PacketBuffer + (sizeof(fs2open_pilot_update) - sizeof(fs2open_ship_typekill *)));
p_update->pid = PCKT_PILOT_UPDATE2;
p_update->pid = PCKT_PILOT_UPDATE;
p_update->sid = SID;
strncpy(p_update->name, player_name, 65);
@@ -254,38 +186,29 @@ int SendPlayerData(int SID, const char* player_name, const char* user, player *p
p_update->SecHits = pl->stats.s_shots_hit;
p_update->SecFHits = pl->stats.s_bonehead_hits;
p_update->ship_types = MAX_SHIP_TYPES;
p_update->num_medals = MAX_MEDALS;
p_update->rank = pl->stats.rank;
int i;
for (i = 0; i < MAX_SHIP_TYPES; i++)
for (int i = 0; i < MAX_SHIP_TYPES; i++)
{
strncpy(type_kills[i].name, Ship_info[i].name, 32);
type_kills[i].kills = pl->stats.kills[i];
}
for (i = 0; i < MAX_MEDALS; i++)
{
medals[i] = pl->stats.medals[i];
}
int packet_size = 204; // size of all the ints only
int packet_size = 194; // size of all the ints only
packet_size += sizeof(fs2open_ship_typekill) * MAX_SHIP_TYPES; // add the size of the ship_kills array
packet_size += sizeof(int) * MAX_MEDALS; // add the size of the ship_kills array
// send Packet
if (Socket.SendData(PacketBuffer, packet_size) == -1)
return -1;
return NULL;
fs2open_pilot_updatereply u_reply;
while ( timer_get_fixed_seconds() <= end_time )
while ((clock() - starttime) <= timeout)
{
if (Socket.DataReady() && (Socket.GetData((char *) &u_reply, sizeof(fs2open_pilot_updatereply)) != -1))
if (Socket.DataReady() && Socket.GetData((char *) &u_reply, sizeof(fs2open_pilot_updatereply)) != -1)
{
if (u_reply.pid != PCKT_PILOT_UREPLY) // ignore packet
@@ -315,8 +238,10 @@ int GetPlayerData(int SID, const char* player_name, player *pl, const char* mast
fs2open_get_pilot prq_packet;
timeout = timeout * CLK_TCK;
memset((char *) &prq_packet, 0, sizeof(fs2open_get_pilot));
prq_packet.pid = PCKT_PILOT_GET2;
prq_packet.pid = PCKT_PILOT_GET;
prq_packet.sid = SID;
strncpy(prq_packet.pilotname, player_name, 64);
prq_packet.create = CanCreate;
@@ -325,23 +250,23 @@ int GetPlayerData(int SID, const char* player_name, player *pl, const char* mast
// send Packet
if (Socket.SendData((char *)&prq_packet, sizeof(fs2open_get_pilot)) == -1)
return -1;
return NULL;
char PacketBuffer[16384]; // 16K should be enough i think..... I HOPE!
fs2open_pilot_reply *p_reply = (fs2open_pilot_reply *) PacketBuffer;
memset(PacketBuffer, 0, 16384);
fs2open_ship_typekill *type_kills = (fs2open_ship_typekill *) (PacketBuffer + 72);
int *medals = NULL; //(int*)(PacketBuffer+72+(sizeof(fs2open_ship_typekill) * pilotrep.ship_types));
fs2open_ship_typekill *type_kills = (fs2open_ship_typekill *) (PacketBuffer + sizeof(fs2open_pilot_reply) - sizeof(fs2open_ship_typekill *));
int CheckSize = 72, i;
int CheckSize = sizeof(fs2open_pilot_reply) - sizeof(fs2open_ship_typekill *) - 2; //2 for the weird stinking msvc stuff
int recvsize = 0, rs2;
Sleep(2); // give them a second
int starttime = clock();
fix end_time = timer_get_fixed_seconds() + (timeout * F1_0);
while ( timer_get_fixed_seconds() <= end_time )
while ((clock() - starttime) <= timeout)
{
if (Socket.DataReady() && ((recvsize = Socket.GetData((char *) &PacketBuffer, 16384)) != -1))
if (Socket.DataReady() && (recvsize = Socket.GetData((char *) &PacketBuffer, 16384)) != -1)
{
if (p_reply->pid != PCKT_PILOT_REPLY) // ignore packet
@@ -349,13 +274,10 @@ int GetPlayerData(int SID, const char* player_name, player *pl, const char* mast
continue;
}
if (p_reply->replytype == 0)
CheckSize += (sizeof(fs2open_ship_typekill) * p_reply->ship_types) + (sizeof(int) * p_reply->num_medals);
else
CheckSize = 8;
CheckSize += sizeof(fs2open_ship_typekill) * p_reply->ship_types;
ml_printf("Precompletion Pilot Update: CheckSize = %d, recvsize = %d", CheckSize, recvsize);
while (CheckSize - recvsize > 0 && timer_get_fixed_seconds() <= end_time)
while (CheckSize - recvsize > 0 && (clock() - starttime) <= timeout)
{
if (Socket.DataReady())
{
@@ -367,14 +289,13 @@ int GetPlayerData(int SID, const char* player_name, player *pl, const char* mast
ml_printf("PostCompletion Tables Get: CheckSize = %u, recvsize = %u", CheckSize, recvsize);
// if we timed out
if ( timer_get_fixed_seconds() >= end_time )
if ((clock() - starttime) >= timeout)
{
ml_printf("Pilot Update completetion timed out");
break;
}
medals = (int*)(PacketBuffer+72+(sizeof(fs2open_ship_typekill) * p_reply->ship_types));
if (p_reply->replytype > 1)
@@ -394,7 +315,6 @@ int GetPlayerData(int SID, const char* player_name, player *pl, const char* mast
pl->stats.s_shots_fired = p_reply->SecShots;
pl->stats.s_shots_hit = p_reply->SecHits;
pl->stats.s_bonehead_hits = p_reply->SecFHits;
pl->stats.rank = p_reply->rank;
if (p_reply->ship_types == 0)
@@ -402,22 +322,12 @@ int GetPlayerData(int SID, const char* player_name, player *pl, const char* mast
else
{
// i should really assert p_reply->ship_types == MAX_SHIP_TYPES
for (i = 0; i < MAX_SHIP_TYPES && p_reply->ship_types; i++)
for (int i = 0; i < MAX_SHIP_TYPES && p_reply->ship_types; i++)
{
pl->stats.kills[i] = type_kills[i].kills;
}
}
if (p_reply->num_medals == 0)
memset(pl->stats.medals, 0, sizeof(int) * MAX_MEDALS);
else
{
// i should really assert p_reply->ship_types == MAX_SHIP_TYPES
for (i = 0; i < MAX_MEDALS && p_reply->num_medals; i++)
{
pl->stats.medals[i] = medals[i];
}
}
// ignored on load... fs2 doesn't need this
// type_kills[index].name[65] = Ship_info[index].name[32]
@@ -432,85 +342,7 @@ int GetPlayerData(int SID, const char* player_name, player *pl, const char* mast
return -1;
}
//**************************************************************************************************************************************************
fs2open_banmask* GetBanList(int &numBanMasks, TCP_Socket &Socket, int timeout)
{
// Clear any old dead crap data
Socket.IgnorePackets();
fs2open_banlist_request br_packet;
br_packet.pid = PCKT_BANLIST_RQST;
br_packet.reserved = 0;
//std::string sender = masterserver;
// send Packet
if (Socket.SendData((char *)&br_packet, sizeof(fs2open_banlist_request)) == -1)
return NULL;
char PacketBuffer[16384]; // 16K should be enough i think..... I HOPE!
fs2open_banlist_reply *banreply_ptr = (fs2open_banlist_reply *) PacketBuffer;
fs2open_banmask *masks = NULL;
numBanMasks = 0;
Sleep(1); //lets give them a second
fix end_time = timer_get_fixed_seconds() + (timeout * F1_0);
int recvsize = 0, rs2;
int CheckSize = sizeof(int) * 2;
while ( timer_get_fixed_seconds() <= end_time )
{
if (Socket.DataReady() && ((recvsize = Socket.GetData(PacketBuffer, 16384)) != -1))
{
if (banreply_ptr->pid != PCKT_BANLIST_RPLY)
{
continue; // skip and ignore this packet
}
CheckSize += banreply_ptr->num_ban_masks * sizeof(fs2open_banmask);
ml_printf("Precompletion Table Get: CheckSize = %d, recvsize = %d", CheckSize, recvsize);
while (CheckSize - recvsize > 0 && timer_get_fixed_seconds() <= end_time)
{
if (Socket.DataReady())
{
rs2 = Socket.GetData(PacketBuffer+recvsize, 16384-recvsize);
ml_printf("Banlist Completetion: Got Additional %u bytes", rs2);
recvsize += rs2;
}
}
ml_printf("PostCompletion Banlist Get: CheckSize = %u, recvsize = %u", CheckSize, recvsize);
if ( timer_get_fixed_seconds() >= end_time )
{
ml_printf("Banlist Transfer completetion timed out");
break;
}
masks = new fs2open_banmask[banreply_ptr->num_ban_masks];
memcpy(masks, PacketBuffer + 8, sizeof(fs2open_banmask) * banreply_ptr->num_ban_masks); // packet buffer will be two ints then the array;
numBanMasks = banreply_ptr->num_ban_masks;
return masks;
}
}
return NULL;
}
//**************************************************************************************************************************************************
@@ -523,6 +355,8 @@ file_record* GetTablesList(int &numTables, const char *masterserver, TCP_Socket
fs2open_file_check fc_packet;
fc_packet.pid = PCKT_TABLES_RQST;
timeout = timeout * CLK_TCK;
std::string sender = masterserver;
// send Packet
@@ -536,14 +370,15 @@ file_record* GetTablesList(int &numTables, const char *masterserver, TCP_Socket
numTables = 0;
Sleep(2); //lets give them a second
fix end_time = timer_get_fixed_seconds() + (timeout * F1_0);
int starttime = clock();
int recvsize = 0, rs2;
int CheckSize = sizeof(int) * 2;
while ( timer_get_fixed_seconds() <= end_time )
while ((clock() - starttime) <= timeout)
{
if (Socket.DataReady() && ((recvsize = Socket.GetData(PacketBuffer, 16384)) != -1))
if (Socket.DataReady() && (recvsize = Socket.GetData(PacketBuffer, 16384)) != -1)
{
if (misreply_ptr->pid != PCKT_TABLES_REPLY)
{
@@ -554,7 +389,7 @@ file_record* GetTablesList(int &numTables, const char *masterserver, TCP_Socket
CheckSize += misreply_ptr->num_files * sizeof(file_record);
ml_printf("Precompletion Table Get: CheckSize = %d, recvsize = %d", CheckSize, recvsize);
while (CheckSize - recvsize > 0 && timer_get_fixed_seconds() <= end_time)
while (CheckSize - recvsize > 0 && (clock() - starttime) <= timeout)
{
if (Socket.DataReady())
{
@@ -565,7 +400,7 @@ file_record* GetTablesList(int &numTables, const char *masterserver, TCP_Socket
}
ml_printf("PostCompletion Tables Get: CheckSize = %u, recvsize = %u", CheckSize, recvsize);
if ( timer_get_fixed_seconds() >= end_time )
if ((clock() - starttime) >= timeout)
{
ml_printf("Tables Transfer completetion timed out");
break;
@@ -609,6 +444,7 @@ file_record* GetMissionsList(int &numMissions, const char *masterserver, TCP_Soc
fs2open_file_check fc_packet;
fc_packet.pid = PCKT_MISSIONS_RQST;
timeout = timeout * CLK_TCK;
std::string sender = masterserver;
@@ -625,16 +461,15 @@ file_record* GetMissionsList(int &numMissions, const char *masterserver, TCP_Soc
numMissions = 0;
//int depth = 0;
Sleep(2); // lets give it a second
fix end_time = timer_get_fixed_seconds() + (timeout * F1_0);
int starttime = clock();
int recvsize = 0, rs2;
int CheckSize = sizeof(int) * 2;
while ( timer_get_fixed_seconds() <= end_time )
while ((clock() - starttime) <= timeout)
{
if (Socket.DataReady() && ((recvsize = Socket.GetData(PacketBuffer, 16384)) != -1))
if (Socket.DataReady() && (recvsize = Socket.GetData(PacketBuffer, 16384)) != -1)
{
if (misreply_ptr->pid != PCKT_MISSIONS_REPLY)
@@ -645,7 +480,7 @@ file_record* GetMissionsList(int &numMissions, const char *masterserver, TCP_Soc
CheckSize += misreply_ptr->num_files * sizeof(file_record);
ml_printf("Precompletion Missions Get: CheckSize = %d, recvsize = %d", CheckSize, recvsize);
while (CheckSize - recvsize > 0 && timer_get_fixed_seconds() <= end_time)
while (CheckSize - recvsize > 0 && (clock() - starttime) <= timeout)
{
if (Socket.DataReady())
{
@@ -656,7 +491,7 @@ file_record* GetMissionsList(int &numMissions, const char *masterserver, TCP_Soc
}
ml_printf("PostCompletion Missions Get: CheckSize = %u, recvsize = %u", CheckSize, recvsize);
if ( timer_get_fixed_seconds() >= end_time )
if ((clock() - starttime) >= timeout)
{
ml_printf("Missions Transfer completetion timed out");
break;
@@ -696,6 +531,9 @@ int Fs2OpenPXO_Login(const char* username, const char* password, TCP_Socket &Soc
// Clear any old dead crap data
Socket.IgnorePackets();
timeout = timeout * CLK_TCK;
int starttime = clock();
std::string sender = masterserver;
// create and send login packet
@@ -708,16 +546,13 @@ int Fs2OpenPXO_Login(const char* username, const char* password, TCP_Socket &Soc
if (Socket.SendData((char *) &loginpckt, sizeof(loginpckt)) == -1)
{
std::cout << "Error Sending Packet" << std::endl;
cout << "Error Sending Packet" << endl;
return -1;
}
fix end_time = timer_get_fixed_seconds() + (timeout * F1_0);
// await reply
fs2open_pxo_lreply loginreply;
while ( timer_get_fixed_seconds() <= end_time )
while ((clock() - starttime) <= timeout)
{
if (Socket.DataReady() && Socket.GetData((char *)&loginreply, sizeof(fs2open_pxo_lreply)) != -1)
@@ -728,9 +563,7 @@ int Fs2OpenPXO_Login(const char* username, const char* password, TCP_Socket &Soc
}
if (loginreply.login_status == false)
{
return -1;
}
else
return loginreply.sid;
}
@@ -780,7 +613,10 @@ net_server* GetServerList(const char* masterserver, int &numServersFound, TCP_So
numServersFound = 0;
timeout = timeout * CLK_TCK;
int starttime = clock();
// ---------- Prepair and send request packet ------------
serverlist_request_packet rpack;
rpack.pid = PCKT_SLIST_REQUEST;
@@ -794,32 +630,28 @@ net_server* GetServerList(const char* masterserver, int &numServersFound, TCP_So
// ---------- Receive Reply ------------
serverlist_reply_packet NewServer;
net_server *retlist = NULL, templist[MAX_SERVERS];
net_server *retlist, templist[MAX_SERVERS];
fix end_time = timer_get_fixed_seconds() + (timeout * F1_0);
while ( timer_get_fixed_seconds() <= end_time )
while ((clock() - starttime) <= timeout)
{
if (Socket.DataReady() && Socket.GetData((char *)&NewServer, sizeof(serverlist_reply_packet)) == sizeof(serverlist_reply_packet))
if (Socket.DataReady() && Socket.GetData((char *)&NewServer, sizeof(serverlist_reply_packet)) != -1)
{
if (!strcmp(NewServer.name, "TERM") && NewServer.flags == 0 && NewServer.players == 0)
{
starttime = 0;
break;
}
memcpy((char *)&templist[numServersFound], (char *)&NewServer, sizeof(serverlist_reply_packet));
numServersFound++;
if (numServersFound >= MAX_SERVERS) {
numServersFound = MAX_SERVERS;
break;
}
}
}
if (!numServersFound)
return NULL;
// ---------- Prepair and return list ------------
retlist = new net_server[numServersFound];
@@ -867,19 +699,4 @@ int GetPingReply(TCP_Socket &Socket)
Socket.GetData((char *)&rping, sizeof(fs2open_pingreply));
return int( float(clock() - rping.time)/2.0 );
}
//**************************************************************************************************************************************************
void SendPingReply(TCP_Socket &Socket, int tstamp)
{
fs2open_pingreply rping;
rping.pid = PCKT_PINGREPLY;
rping.time = tstamp;
Socket.SendData((char*)&rping, sizeof(rping));
}
#endif // !NO_NETWORK
}
+11 -69
View File
@@ -10,43 +10,12 @@
/*
* $Logfile: /Freespace2/code/fs2open_pxo/TCP_Socket.cpp $
* $Revision: 1.16 $
* $Date: 2005-07-13 02:50:49 $
* $Revision: 1.9 $
* $Date: 2004-03-31 05:42:26 $
* $Author: Goober5000 $
*
*
* $Log: not supported by cvs2svn $
* Revision 1.15 2005/06/29 18:49:37 taylor
* various FS2NetD fixes:
* - replace timer stuff with something that more accurately works cross-platform and without being affected by load
* - better sanity checking for the server list
* - working Linux compatibility that's not dog slow
* - when calling DataReady() make sure that the data is properly valid
* - fix messed up cvs merge cleanup from the Linux merge which did nasty things
*
* Revision 1.14 2005/03/02 21:18:18 taylor
* better support for Inferno builds (in PreProcDefines.h now, no networking support)
* make sure NO_NETWORK builds are as friendly on Windows as it is on Linux/OSX
* revert a timeout in Client.h back to the original value before Linux merge
*
* Revision 1.13 2005/02/04 20:06:03 taylor
* merge with Linux/OSX tree - p0204-2
*
* Revision 1.12 2004/11/18 00:05:36 Goober5000
* #pragma'd a bunch of warnings
* --Goober5000
*
* Revision 1.11 2004/07/26 20:47:29 Kazan
* remove MCD complete
*
* Revision 1.10 2004/07/12 16:32:46 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 1.9 2004/03/31 05:42:26 Goober5000
* got rid of all those nasty warnings from xlocale and so forth; also added comments
* for #pragma warning disable to indicate the message being disabled
* --Goober5000
*
* Revision 1.8 2004/03/09 17:59:01 Kazan
* Disabled multithreaded TCP_Socket in favor of safer single threaded
* FS2NetD doesn't kill the game on connection failure now - just gives warning message and effectively dsiables itself until they try to connect again
@@ -78,30 +47,16 @@
*
*/
#pragma warning(disable:4100) // unreferenced formal parameter
#pragma warning(disable:4511) // copy constructor could not be generated
#pragma warning(disable:4512) // assignment operator could not be generated
#pragma warning(disable:4711) // function selected for inlining
#ifndef NO_NETWORK
// 4100 = unreferenced formal parameter
// 4511 = copy constructor could not be generated
// 4512 = assignment operator could not be generated
// 4711 = function selected for inlining
#pragma warning(disable:4100 4511 4512 4711)
#include <iostream>
#ifdef SCP_UNIX
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include "fs2open_pxo/TCP_Socket.h"
#include "TCP_Socket.h"
//#include <process.h>
//#include <iostream.h>
using namespace std;
//**************************************************************************
// TCP_Socket Implementation
//**************************************************************************
@@ -232,7 +187,7 @@ bool TCP_Socket::InitSocket(std::string rem_host, int rem_port)
if (connect(mySocket, (sockaddr *)&adr_inet, sizeof(sockaddr_in)) == -1)
{
cout << "Couldn't Connect to Remote system" << endl;
return false;
return fasle;
}
}
#endif
@@ -259,16 +214,12 @@ bool TCP_Socket::DataReady()
FD_ZERO(&recvs);
FD_SET(mySocket, &recvs);
#ifndef SCP_UNIX
int status = select(1, &recvs, NULL, NULL, &wait);
#else
int status = select(mySocket+1, &recvs, NULL, NULL, &wait);
#endif
#if defined(FS2_TCP_RMultithread)
return (status != 0 && status != SOCKET_ERROR) || this->MT_DataReady();
#else
return (status != 0 && status != SOCKET_ERROR && FD_ISSET(mySocket, &recvs));
return (status != 0 && status != SOCKET_ERROR);
#endif
}
@@ -300,11 +251,7 @@ bool TCP_Socket::OOBDataReady()
FD_ZERO(&recvs);
FD_SET(mySocket, &recvs);
#ifndef SCP_UNIX
int status = select(1, NULL, NULL, &recvs, &wait);
#else
int status = select(mySocket+1, NULL, NULL, &recvs, &wait);
#endif
return (status != 0 && status != SOCKET_ERROR);
}
@@ -416,12 +363,8 @@ STYPE TCP_Socket::AcceptConnections()
{
sockaddr_in adr_client;
int len = sizeof(sockaddr_in);
#ifndef SCP_UNIX
STYPE client = accept(mySocket, (sockaddr *) &adr_client, &len);
#else
STYPE client = accept(mySocket, (sockaddr *) &adr_client, (socklen_t*)&len);
#endif
return client; // some sort of error
}
@@ -466,4 +409,3 @@ bool TCP_Socket::AcceptConnections(sproc server_process)
#endif
#endif // !NO_NETWORK
+30 -41
View File
@@ -11,34 +11,12 @@
/*
* $Logfile: /Freespace2/code/fs2open_pxo/TCP_Socket.h $
* $Revision: 1.11 $
* $Date: 2005-07-13 02:50:49 $
* $Revision: 1.6 $
* $Date: 2004-03-31 05:42:26 $
* $Author: Goober5000 $
*
*
* $Log: not supported by cvs2svn $
* Revision 1.10 2005/06/29 18:49:37 taylor
* various FS2NetD fixes:
* - replace timer stuff with something that more accurately works cross-platform and without being affected by load
* - better sanity checking for the server list
* - working Linux compatibility that's not dog slow
* - when calling DataReady() make sure that the data is properly valid
* - fix messed up cvs merge cleanup from the Linux merge which did nasty things
*
* Revision 1.9 2005/06/21 00:12:11 taylor
* add virtual destructor so that GCC4 can shut up
*
* Revision 1.8 2005/02/04 20:06:03 taylor
* merge with Linux/OSX tree - p0204-2
*
* Revision 1.7 2004/08/11 05:06:23 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 1.6 2004/03/31 05:42:26 Goober5000
* got rid of all those nasty warnings from xlocale and so forth; also added comments
* for #pragma warning disable to indicate the message being disabled
* --Goober5000
*
* Revision 1.5 2004/03/09 17:59:01 Kazan
* Disabled multithreaded TCP_Socket in favor of safer single threaded
* FS2NetD doesn't kill the game on connection failure now - just gives warning message and effectively dsiables itself until they try to connect again
@@ -53,9 +31,6 @@
*
*/
#if !defined(__TCP_SOCKET_H_)
#define __TCP_SOCKET_H_
// Enable Multithread
//#define MT_TCP_Socket
@@ -73,25 +48,42 @@
//#include <winsock2.h>
#else
#include <cstdio>
#include <stdlib.h>
#include <unistd.h>
#include <cerrno>
#include <string>
#if !defined(STYPE)
#define STYPE SOCKET
#endif
#include "globalincs/pstypes.h" // make sure _cdecl is defined correctly on *nix
#if !defined(CLOSEFUNC)
#define CLOSEFUNC closesocket
#endif
#else
// Unix Version
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string>
#if !defined(STYPE)
#define STYPE SOCKET
#define STYPE int
#endif
#if !defined(CLOSEFUNC)
#define CLOSEFUNC close
#endif
#endif
#if !defined(__TCP_SOCKET_H_)
#define __TCP_SOCKET_H_
// From UDP_Socket
int startWinsock();
@@ -107,7 +99,6 @@ class Generic_Socket
public:
Generic_Socket() : Initialized(false), port(0) {}
virtual ~Generic_Socket() {}
bool isInitialized() { return Initialized; }
void Close() { CLOSEFUNC(mySocket); Initialized = false; }
@@ -152,9 +143,8 @@ class TCP_Socket : public Generic_Socket
#endif
public:
// TCP_Socket(int aport = 0, bool WillbeServer = false) : ServerMode(WillbeServer), Generic_Socket() { port = aport; }
TCP_Socket(int aport = 0, bool WillbeServer = false) { ServerMode = WillbeServer; Generic_Socket::SetPort(aport); }
virtual ~TCP_Socket()
TCP_Socket(int aport = 0, bool WillbeServer = false) : ServerMode(WillbeServer), Generic_Socket() { port = aport; }
~TCP_Socket()
{
#if defined(FS2_TCP_RMultithread)
@@ -217,5 +207,4 @@ class TCP_Socket : public Generic_Socket
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#endif // __TCP_SOCKET_H_
#endif
+6 -93
View File
@@ -10,29 +10,12 @@
/*
* $Logfile: /Freespace2/code/fs2open_pxo/protocol.h $
* $Revision: 1.16 $
* $Date: 2005-07-13 02:50:49 $
* $Revision: 1.11 $
* $Date: 2004-03-31 05:42:26 $
* $Author: Goober5000 $
*
*
* $Log: not supported by cvs2svn $
* Revision 1.15 2005/02/04 20:06:03 taylor
* merge with Linux/OSX tree - p0204-2
*
* Revision 1.14 2004/08/11 05:06:23 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 1.13 2004/07/09 22:05:32 Kazan
* fs2netd 1.0 RC5 full support - Rank and Medal updates
*
* Revision 1.12 2004/07/07 21:00:06 Kazan
* FS2NetD: C2S Ping/Pong, C2S Ping/Pong, Global IP Banlist, Global Network Messages
*
* Revision 1.11 2004/03/31 05:42:26 Goober5000
* got rid of all those nasty warnings from xlocale and so forth; also added comments
* for #pragma warning disable to indicate the message being disabled
* --Goober5000
*
* Revision 1.10 2004/03/07 23:07:20 Kazan
* [Incomplete] Readd of Software renderer so Standalone server works
*
@@ -56,9 +39,6 @@
#if !defined(__pxo_protocol_h_)
#define __pxo_protocol_h_
#include "globalincs/pstypes.h" // for _fs_time_t
#pragma warning(disable:4663) // new template specification syntax
#define PXO_PROTO_VER "1.2"
@@ -85,17 +65,6 @@
#define PCKT_MISSION_CHECK 0xF
#define PCKT_MCHECK_REPLY 0x10
#define PCKT_BANLIST_RQST 0x11
#define PCKT_BANLIST_RPLY 0x12
// this only goes from the server out
#define PCKT_NETOWRK_WALL 0x13
// more advanced version of this packet
// different ID's for backward compat
#define PCKT_PILOT_UPDATE2 0x14
#define PCKT_PILOT_GET2 0x15
#define FS2OPEN_PXO_PORT 12000
#define FS2OPEN_CLIENT_PORT FS2OPEN_PXO_PORT + 1
@@ -215,7 +184,6 @@ struct fs2open_pxo_missreply
//+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// ----- Pilot Management -----
@@ -223,7 +191,6 @@ struct fs2open_pxo_missreply
struct fs2open_get_pilot
{
int pid; // 0x9 ( PCKT_PILOT_GET )
// 0x15 (PCKT_PILOT_GET2)
int sid; // session id returned upon login
char pilotname[65];
bool create; // create pilot
@@ -259,18 +226,7 @@ struct fs2open_pilot_reply
unsigned int SecFHits;
unsigned int ship_types;
// if request was a PCKT_PILOT_GET2
int rank;
int num_medals;
// ----------------------
fs2open_ship_typekill *type_kills;
// if request was a PCKT_PILOT_GET2
int *medals;
// ----------------------
};
@@ -278,8 +234,7 @@ struct fs2open_pilot_reply
struct fs2open_pilot_update
{
int pid; // 0x0B (PCKT_PILOT_UPDATE)
// 0x14 (PCKT_PILOT_UPDATE2)
int sid; //session id
int sid; // session id
char name[65];
char user[65];
@@ -298,22 +253,10 @@ struct fs2open_pilot_update
unsigned int SecShots;
unsigned int SecHits;
unsigned int SecFHits;
unsigned int ship_types;
fs2open_ship_typekill *type_kills;
unsigned int ship_types;
// if PCKT_PILOT_UPDATE2
int rank;
int num_medals;
// ----------------------
// added with update2.. but always been there TYVM MSVC
short reserved; // realign to 4-byte boundry --- MSVC does this automagically.. let's force it
fs2open_ship_typekill *type_kills;
// if PCKT_PILOT_UPDATE2
int *medals;
// ----------------------
};
@@ -325,7 +268,6 @@ struct fs2open_pilot_updatereply
};
// ---------------- Generic Ping -----------------
// ping time is in ticks returned by clock()
@@ -341,34 +283,5 @@ struct fs2open_pingreply
int time;
};
// ---------------- Banlist Packets -----------------
struct fs2open_banlist_request
{
int pid; // 0x11 (PCKT_BANLIST_RQST)
int reserved;
};
struct fs2open_banmask
{
char ip_mask[16]; // up to 15 chars (123.123.123.123) and a NULL
};
struct fs2open_banlist_reply
{
int pid; // 0x12 (PCKT_BANLIST_RPLY)
int num_ban_masks;
fs2open_banmask* masks;
};
// ---------------- Global Message Packet -----------------
struct fs2open_network_wall
{
int pid; // 0x13 (PCKT_NETOWRK_WALL)
char message[252];
};
#endif
+15 -50
View File
@@ -10,31 +10,12 @@
/*
* $Logfile: /Freespace2/code/fs2open_pxo/udpsocket.cpp $
* $Revision: 1.10 $
* $Date: 2005-07-13 02:50:49 $
* $Revision: 1.5 $
* $Date: 2004-03-31 05:42:26 $
* $Author: Goober5000 $
*
*
* $Log: not supported by cvs2svn $
* Revision 1.9 2005/03/02 21:18:18 taylor
* better support for Inferno builds (in PreProcDefines.h now, no networking support)
* make sure NO_NETWORK builds are as friendly on Windows as it is on Linux/OSX
* revert a timeout in Client.h back to the original value before Linux merge
*
* Revision 1.8 2005/02/04 20:06:03 taylor
* merge with Linux/OSX tree - p0204-2
*
* Revision 1.7 2004/07/26 20:47:29 Kazan
* remove MCD complete
*
* Revision 1.6 2004/07/12 16:32:46 Kazan
* MCD - define _MCD_CHECK to use memory tracking
*
* Revision 1.5 2004/03/31 05:42:26 Goober5000
* got rid of all those nasty warnings from xlocale and so forth; also added comments
* for #pragma warning disable to indicate the message being disabled
* --Goober5000
*
* Revision 1.4 2004/02/21 00:59:43 Kazan
* FS2NETD License Comments
*
@@ -50,27 +31,10 @@
*
*/
#ifndef NO_NETWORK
#pragma warning(disable:4710) // function not inlined
#pragma warning(disable:4711) // function inlined
#include <iostream>
#ifdef SCP_UNIX
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include "fs2open_pxo/udpsocket.h"
using namespace std;
#include "udpsocket.h"
#if defined(WIN32)
//*******************************************************************************
@@ -119,14 +83,14 @@ bool UDP_Socket::InitSocket()
this->socket = ::socket(AF_INET, SOCK_DGRAM, 0);
if (this->socket == -1)
{
cout << "Couldn't Get Socket (" << strerror(errno) << ")" << endl;
Out << "Couldn't Get Socket (" << strerror(errno) << ")" << endl;
return false;
}
if (bind(this->socket, (sockaddr *)&adr_inet, sizeof(adr_inet)) == -1)
{
cout << "Couldn't Bind Socket" << endl;
Out << "Couldn't Bind Socket" << endl;
return false;
}
@@ -154,23 +118,25 @@ int UDP_Socket::GetPacket(char *buffer, int blen, std::string &from)
int recvbytes = -1;
int from_size = sizeof(from_addr);
#if defined(WIN32)
timeval wait;
wait.tv_sec = 0;
wait.tv_usec = 1;
fd_set recvs;
FD_ZERO(&recvs);
FD_SET(this->socket, &recvs);
recvs.fd_count = 1;
recvs.fd_array[0] = this->socket;
int status = select(-1, &recvs, NULL, NULL, &wait);
int status = select(NULL, &recvs, NULL, NULL, &wait);
if (status != 0 && status != SOCKET_ERROR)
#if defined(WIN32)
recvbytes = recvfrom(this->socket, buffer, blen, 0, (sockaddr *)&from_addr, &from_size);
#else
recvbytes = recvfrom(this->socket, buffer, blen, 0, (sockaddr *)&from_addr, (socklen_t *)&from_size);
#endif
#else
// +#@$++#@$+ +#@$++#@$+ CRITICAL FIX REQURED +#@$++#@$+ +#@$++#@$+
// FIX THIS FOR IT NOT TO BLOCK LIKE I DID ON WINDOWS!
// +#@$++#@$+ +#@$++#@$+ CRITICAL FIX REQURED +#@$++#@$+ +#@$++#@$+
recvbytes = recvfrom(this->socket, buffer, blen, 0, (sockaddr *)&from_addr, (socklen_t *)&from_size);
#endif
from = inet_ntoa(from_addr.sin_addr);
return recvbytes;
@@ -197,4 +163,3 @@ int UDP_Socket::SendPacket(char *buffer, int plen, std::string &to, int toport)
return sent;
}
#endif // !NO_NETWORK
+13 -23
View File
@@ -10,23 +10,12 @@
/*
* $Logfile: /Freespace2/code/fs2open_pxo/udpsocket.h $
* $Revision: 1.7 $
* $Date: 2005-07-13 02:50:49 $
* $Revision: 1.4 $
* $Date: 2004-03-31 05:42:26 $
* $Author: Goober5000 $
*
*
* $Log: not supported by cvs2svn $
* Revision 1.6 2005/02/04 20:06:03 taylor
* merge with Linux/OSX tree - p0204-2
*
* Revision 1.5 2004/08/11 05:06:23 Kazan
* added preprocdefines.h to prevent what happened with fred -- make sure to make all fred2 headers include this file as the _first_ include -- i have already modified fs2 files to do this
*
* Revision 1.4 2004/03/31 05:42:26 Goober5000
* got rid of all those nasty warnings from xlocale and so forth; also added comments
* for #pragma warning disable to indicate the message being disabled
* --Goober5000
*
* Revision 1.3 2004/02/21 00:59:43 Kazan
* FS2NETD License Comments
*
@@ -40,7 +29,8 @@
#if !defined(__protocol_h_)
#define __protocol_h_
#ifdef _WIN32
#if defined(WIN32)
// Windows Version
#include <windows.h>
#pragma warning(push, 2) // ignore all those warnings for Microsoft stuff
@@ -52,19 +42,19 @@
#define CLOSEFUNC closesocket
#else
#include <cstdio>
// Unix Version
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <cerrno>
#endif
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string>
#define STYPE int
#define CLOSEFUNC close
#include "globalincs/pstypes.h"
#define CLOSEFUNC closesocket
#if !defined(STYPE)
#define STYPE SOCKET
#endif
class UDP_Socket
Loaded 100 of 718 files, more files were not shown because too many files have changed in this diff. Show more