2007-06-14

This commit is contained in:
Anonymous Maarten committed 2015-12-03 01:38:22 +01:00
1 parent e20673c2cd
commit 1ae34ae340
96 files changed
+5680 -1020

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
#include <string>
#include "lua_vm.h"
#include "opengta.h"
#include "dataholder.h"
#include "file_helper.h"
#include "log.h"
std::string map_filename;
const char* script_file;
void on_exit() {
SDL_Quit();
PHYSFS_deinit();
}
void parse_args(int argc, char* argv[]) {
if (argc != 3) {
ERROR << "invalid args" << std::endl;
exit(1);
}
map_filename = std::string(argv[1]);
script_file = argv[2];
}
void run_init(const char* prg_name) {
PHYSFS_init(prg_name);
Util::FileHelper & fh = GET_FILE_HELPER;
if (fh.existsInSystemFS(fh.getBaseDataPath())) {
PHYSFS_addToSearchPath(GET_FILE_HELPER.getBaseDataPath().c_str(), 1);
}
else {
WARN << "Could not load data-source: " << fh.getBaseDataPath() << std::endl;
}
PHYSFS_addToSearchPath(PHYSFS_getBaseDir(), 1);
}
void run_main() {
OpenGTA::Script::LuaVM & vm = OpenGTA::Script::LuaVMHolder::Instance();
OpenGTA::MainMsgHolder::Instance().load("ENGLISH.FXT");
OpenGTA::MapHolder::Instance().load(map_filename);
OpenGTA::Map & loadedMap = OpenGTA::MapHolder::Instance().get();
vm.setMap(loadedMap);
vm.runFile(script_file);
}
+43
View File
@@ -0,0 +1,43 @@
#!/bin/bash
function input_data() {
cat <<EOF
0
1
2
1
0
-1
-2
-1
0
1
2
1
0
-1
-2
-1
0
EOF
}
function transform() {
switch=$1
input_data | ./interpolate_test --$switch >gnuplot_data.$$
cat <<EOF >gnuplot_script.$$
plot "gnuplot_data.$$" title "$switch"
EOF
gnuplot gnuplot_script.$$ -
}
if [ ! -f interpolate_test ]; then
g++ -I ../math -o interpolate_test interpolate_test.cpp
fi
transform linear
transform cubic
transform cosine
transform hermite
rm -f gnuplot_data.$$ gnuplot_script.$$
+75
View File
@@ -0,0 +1,75 @@
#include <iostream>
#include "rectangle.hpp"
using namespace std;
using namespace Math;
template <typename T> bool test_values ( const Rectangle<T> & r, T x, T y, T w, T h ) {
return (r.x == x && r.y == y && r.w == w && r.h == h);
}
int main(int argc, char* argv[]) {
/*
#define TEST_SET_1 5, 10, 24, 31
Rectangle<int> a(TEST_SET_1);
if (!test_values<int>(a, TEST_SET_1))
cerr << "verifying values failed " << __LINE__ << endl;
Rectangle<int> a_copy(a);
if (!test_values<int>(a_copy, TEST_SET_1))
cerr << "copy-constructor failed " << __LINE__ << endl;
if (! (a == a_copy) )
cerr << "equality failed " << __LINE__ << endl;
if (! a.isInside(15, 15) )
cerr << "isInside failed " << __LINE__ << endl;
Rectangle<int> b(10, 15, 10, 15);
if (a == b )
cerr << "equality failed " << __LINE__ << endl;
if (! rectangle_test_inside<int>(a, b) )
cerr << "rect-inside-rect test failed " << __LINE__ << endl;
if (rectangle_test_leftborder<int>(a, b))
cerr << "rectangle-left-b failed " << __LINE__ << endl;
if (rectangle_test_rightborder<int>(a, b))
cerr << "rectangle-right-b failed " << __LINE__ << endl;
if (rectangle_test_topborder<int>(a, b))
cerr << "rectangle-top-b failed " << __LINE__ << endl;
if (rectangle_test_bottomborder<int>(a, b))
cerr << "rectangle-bottom-b failed " << __LINE__ << endl;
*/
typedef Rectangle<int> IRect;
int input[4];
for (int j = 0; j < 4; ++j) {
input[j] = 0;
input[j] = atoi(argv[j+1]);
}
IRect big(input[0], input[1], input[2], input[3]);
for (int j = 0; j < 4; ++j) {
input[j] = 0;
input[j] = atoi(argv[j+5]);
}
IRect small(input[0], input[1], input[2], input[3]);
list< IRect > mlist;
RectangleGeometry<int>::difference(mlist, big, small);
cout << mlist.size() << " rects returned" << endl;
list< IRect >::iterator i;
for (i = mlist.begin(); i != mlist.end(); ++i) {
cout << "x = " << i->x << " y = " << i->y
<< " w = " << i->w << " h = " << i->h << endl;
}
}