mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
moved ps/X* to ps/XML/
premake: reflect 2 added and 1 removed source dir add ps/Util - some helpful functions that were previously in main.cpp This was SVN commit r2624.
This commit is contained in:
@@ -49,6 +49,8 @@ function setuppackage (projectname)
|
||||
"ps",
|
||||
"ps/scripting",
|
||||
"ps/Network",
|
||||
"ps/GameSetup",
|
||||
"ps/XML",
|
||||
|
||||
"simulation",
|
||||
"simulation/scripting",
|
||||
@@ -70,8 +72,7 @@ function setuppackage (projectname)
|
||||
"terrain",
|
||||
"sound",
|
||||
"scripting",
|
||||
"i18n",
|
||||
"tests"
|
||||
"i18n"
|
||||
}
|
||||
|
||||
if (projectname ~= "sced") then tconcat(source_dirs, {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "VFSUtil.h"
|
||||
#include "Loader.h"
|
||||
|
||||
#include "ps/XMLWriter.h"
|
||||
#include "ps/XML/XMLWriter.h"
|
||||
#include "simulation/Entity.h"
|
||||
#include "simulation/BaseEntity.h"
|
||||
#include "simulation/BaseEntityCollection.h"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "precompiled.h"
|
||||
#include "ogl.h"
|
||||
#include "Xeromyces.h"
|
||||
#include "XML/Xeromyces.h"
|
||||
#include "MaterialManager.h"
|
||||
|
||||
#define SAFE_DELETE(x) \
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "ObjectBase.h"
|
||||
|
||||
#include "ObjectManager.h"
|
||||
#include "Xeromyces.h"
|
||||
#include "XML/Xeromyces.h"
|
||||
#include "CLogger.h"
|
||||
|
||||
#define LOG_CATEGORY "graphics"
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "Overlay.h"
|
||||
|
||||
#include "Parser.h"
|
||||
#include "XeroXMB.h"
|
||||
#include "Xeromyces.h"
|
||||
#include "ps/XML/XeroXMB.h"
|
||||
#include "XML/Xeromyces.h"
|
||||
|
||||
#include "CLogger.h"
|
||||
#define LOG_CATEGORY "graphics"
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ gee@pyro.nu
|
||||
#include "CTooltip.h"
|
||||
#include "MiniMap.h"
|
||||
|
||||
#include "ps/Xeromyces.h"
|
||||
#include "ps/XML/Xeromyces.h"
|
||||
#include "ps/Font.h"
|
||||
|
||||
#include "Pyrogenesis.h"
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ ERROR_TYPE(GUI, JSOpenFailed);
|
||||
#include "Singleton.h"
|
||||
#include "lib/input.h"
|
||||
|
||||
#include "Xeromyces.h"
|
||||
#include "XML/Xeromyces.h"
|
||||
|
||||
extern int gui_handler(const SDL_Event* ev);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ gee@pyro.nu
|
||||
#include <vector>
|
||||
#include "lib/input.h" // just for EV_PASS
|
||||
|
||||
#include "ps/Xeromyces.h"
|
||||
#include "ps/XML/Xeromyces.h"
|
||||
|
||||
#include "gui/scripting/JSInterface_IGUIObject.h"
|
||||
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ that of Atlas depending on commandline parameters.
|
||||
#include "gui/GUI.h"
|
||||
#include "ps/CConsole.h"
|
||||
#include "ps/Profile.h"
|
||||
#include "ps/System.h"
|
||||
#include "ps/Util.h"
|
||||
#include "ps/Game.h"
|
||||
#include "ps/Hotkey.h"
|
||||
#include "ps/Interact.h"
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
#include "Atlas.h"
|
||||
#include "Config.h"
|
||||
#include "ps/System.h"
|
||||
#include "ps/Util.h"
|
||||
|
||||
ERROR_GROUP(System);
|
||||
ERROR_TYPE(System, SDLInitFailed);
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#include "lib/res/file/vfs.h"
|
||||
#include "lib/ogl.h"
|
||||
#include "lib/timer.h"
|
||||
#include "lib/detect.h"
|
||||
#include "lib/res/res.h"
|
||||
#include "lib/res/graphics/tex.h"
|
||||
|
||||
#include "ps/GameSetup/Config.h"
|
||||
|
||||
static std::string SplitExts(const char *exts)
|
||||
{
|
||||
std::string str = exts;
|
||||
std::string ret = "";
|
||||
size_t idx = str.find_first_of(" ");
|
||||
while(idx != std::string::npos)
|
||||
{
|
||||
if(idx >= str.length() - 1)
|
||||
{
|
||||
ret += str;
|
||||
break;
|
||||
}
|
||||
|
||||
ret += str.substr(0, idx);
|
||||
ret += "\n";
|
||||
str = str.substr(idx + 1);
|
||||
idx = str.find_first_of(" ");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void WriteSystemInfo()
|
||||
{
|
||||
TIMER(write_sys_info);
|
||||
|
||||
get_gfx_info();
|
||||
// get_cpu_info already called during init - see call site
|
||||
get_snd_info();
|
||||
get_mem_status();
|
||||
|
||||
struct utsname un;
|
||||
uname(&un);
|
||||
|
||||
FILE* f = fopen("../logs/system_info.txt", "w");
|
||||
if(!f)
|
||||
return;
|
||||
|
||||
// .. OS
|
||||
fprintf(f, "OS : %s %s (%s)\n", un.sysname, un.release, un.version);
|
||||
|
||||
// .. CPU
|
||||
fprintf(f, "CPU : %s, %s", un.machine, cpu_type);
|
||||
if(cpus > 1)
|
||||
fprintf(f, " (x%d)", cpus);
|
||||
if(cpu_freq != 0.0f)
|
||||
{
|
||||
if(cpu_freq < 1e9)
|
||||
fprintf(f, ", %.2f MHz\n", cpu_freq*1e-6);
|
||||
else
|
||||
fprintf(f, ", %.2f GHz\n", cpu_freq*1e-9);
|
||||
}
|
||||
else
|
||||
fprintf(f, "\n");
|
||||
|
||||
// .. memory
|
||||
fprintf(f, "Memory : %lu MiB; %lu MiB free\n", tot_mem/MiB, avl_mem/MiB);
|
||||
|
||||
// .. graphics
|
||||
fprintf(f, "Graphics Card : %s\n", gfx_card);
|
||||
fprintf(f, "OpenGL Drivers : %s; %s\n", glGetString(GL_VERSION), gfx_drv_ver);
|
||||
fprintf(f, "Video Mode : %dx%d:%d@%d\n", g_xres, g_yres, g_bpp, g_freq);
|
||||
|
||||
// .. sound
|
||||
fprintf(f, "Sound Card : %s\n", snd_card);
|
||||
fprintf(f, "Sound Drivers : %s\n", snd_drv_ver);
|
||||
|
||||
|
||||
//
|
||||
// .. network name / ips
|
||||
//
|
||||
|
||||
// note: can't use un.nodename because it is for an
|
||||
// "implementation-defined communications network".
|
||||
char hostname[128] = "(unknown)";
|
||||
(void)gethostname(hostname, sizeof(hostname)-1);
|
||||
// -1 makes sure it's 0-terminated. if the function fails,
|
||||
// we display "(unknown)" and will skip IP output below.
|
||||
fprintf(f, "Network Name : %s", hostname);
|
||||
|
||||
{
|
||||
hostent* host = gethostbyname(hostname);
|
||||
if(!host)
|
||||
goto no_ip;
|
||||
struct in_addr** ips = (struct in_addr**)host->h_addr_list;
|
||||
if(!ips)
|
||||
goto no_ip;
|
||||
|
||||
// output all IPs (> 1 if using VMware or dual ethernet)
|
||||
fprintf(f, " (");
|
||||
for(uint i = 0; i < 256 && ips[i]; i++) // safety
|
||||
{
|
||||
// separate entries but avoid trailing comma
|
||||
if(i != 0)
|
||||
fprintf(f, ", ");
|
||||
fprintf(f, "%s", inet_ntoa(*ips[i]));
|
||||
}
|
||||
fprintf(f, ")");
|
||||
}
|
||||
|
||||
no_ip:
|
||||
fprintf(f, "\n");
|
||||
|
||||
|
||||
// .. OpenGL extensions (write them last, since it's a lot of text)
|
||||
const char* exts = oglExtList();
|
||||
if (!exts) exts = "{unknown}";
|
||||
fprintf(f, "\nOpenGL Extensions: \n%s\n", SplitExts(exts).c_str());
|
||||
|
||||
fclose(f);
|
||||
f = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const wchar_t* HardcodedErrorString(int err)
|
||||
{
|
||||
#define E(sym) case sym: return L ## #sym;
|
||||
|
||||
switch(err)
|
||||
{
|
||||
E(ERR_NO_MEM)
|
||||
E(ERR_FILE_NOT_FOUND)
|
||||
E(ERR_INVALID_HANDLE)
|
||||
E(ERR_INVALID_PARAM)
|
||||
E(ERR_EOF)
|
||||
E(ERR_PATH_NOT_FOUND)
|
||||
E(ERR_PATH_LENGTH)
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
const wchar_t* ErrorString(int err)
|
||||
{
|
||||
// language file not available (yet)
|
||||
return HardcodedErrorString(err);
|
||||
|
||||
// TODO: load from language file
|
||||
}
|
||||
|
||||
|
||||
// <extension> identifies the file format that is to be written
|
||||
// (case-insensitive). examples: "bmp", "png", "jpg".
|
||||
// BMP is good for quick output at the expense of large files.
|
||||
void WriteScreenshot(const char* extension)
|
||||
{
|
||||
// determine next screenshot number.
|
||||
//
|
||||
// current approach: increment number until that file doesn't yet exist.
|
||||
// this is fairly slow, but it's typically only done once, since the last
|
||||
// number is cached. binary search shouldn't be necessary.
|
||||
//
|
||||
// known bug: after program restart, holes in the number series are
|
||||
// filled first. example: add 1st and 2nd; [exit] delete 1st; [restart]
|
||||
// add 3rd -> it gets number 1, not 3.
|
||||
// could fix via enumerating all files, but it's not worth it ATM.
|
||||
char fn[VFS_MAX_PATH];
|
||||
|
||||
const char* file_format_string = "screenshots/screenshot%04d.%s";
|
||||
// %04d -> always 4 digits, so sorting by filename works correctly.
|
||||
|
||||
static int next_num = 1;
|
||||
do
|
||||
sprintf(fn, file_format_string, next_num++, extension);
|
||||
while(vfs_exists(fn));
|
||||
|
||||
const int w = g_xres, h = g_yres;
|
||||
const int bpp = 24;
|
||||
GLenum fmt = GL_RGB;
|
||||
int flags = TEX_BOTTOM_UP;
|
||||
// we want writing BMP to be as fast as possible,
|
||||
// so read data from OpenGL in BMP format to obviate conversion.
|
||||
if(!stricmp(extension, "bmp"))
|
||||
{
|
||||
fmt = GL_BGR;
|
||||
flags |= TEX_BGR;
|
||||
}
|
||||
|
||||
const size_t size = w * h * bpp;
|
||||
void* img = mem_alloc(size);
|
||||
|
||||
glReadPixels(0, 0, w, h, fmt, GL_UNSIGNED_BYTE, img);
|
||||
|
||||
if(tex_write(fn, w, h, bpp, flags, img) < 0)
|
||||
debug_warn("WriteScreenshot: tex_write failed");
|
||||
|
||||
mem_free(img);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
extern void WriteSystemInfo();
|
||||
|
||||
extern const wchar_t* ErrorString(int err);
|
||||
|
||||
extern void WriteScreenshot(const char* extension);
|
||||
@@ -8,9 +8,9 @@
|
||||
#include <stack>
|
||||
#include <algorithm>
|
||||
|
||||
#include "ps/Xeromyces.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "lib/res/file/vfs.h"
|
||||
#include "Xeromyces.h"
|
||||
|
||||
#define ZLIB_DLL
|
||||
#include "zlib.h" // for crc32
|
||||
@@ -16,7 +16,7 @@ ERROR_GROUP(Xeromyces);
|
||||
ERROR_TYPE(Xeromyces, XMLOpenFailed);
|
||||
ERROR_TYPE(Xeromyces, XMLParseError);
|
||||
|
||||
#include "ps/XeroXMB.h"
|
||||
#include "XeroXMB.h"
|
||||
#include "CVFSFile.h"
|
||||
|
||||
class CXeromyces : public XMBFile
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "ObjectManager.h"
|
||||
#include "CStr.h"
|
||||
|
||||
#include "ps/Xeromyces.h"
|
||||
#include "ps/XML/Xeromyces.h"
|
||||
|
||||
#include "CLogger.h"
|
||||
#define LOG_CATEGORY "entity"
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "EventHandlers.h"
|
||||
#include "EntitySupport.h"
|
||||
#include "ScriptObject.h"
|
||||
#include "Xeromyces.h"
|
||||
#include "XML/Xeromyces.h"
|
||||
|
||||
class CBaseEntity : public CJSComplex<CBaseEntity>, public IEventTarget
|
||||
{
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "Scheduler.h"
|
||||
#include "Loader.h"
|
||||
|
||||
#include "XML.h"
|
||||
#include "XML/XML.h"
|
||||
|
||||
#include "Game.h"
|
||||
#include "GameAttributes.h"
|
||||
|
||||
Reference in New Issue
Block a user