forked from 0ad/0ad
Linux compat changes, fix for (really old) bug in VertexBufferManager shutdown, GUI header reorganization for gcc 4.0
This was SVN commit r3437.
This commit is contained in:
parent
90bf4ae0a7
commit
fcfa746244
@ -19,6 +19,9 @@
|
||||
#include "CStr.h"
|
||||
#include "NUSpline.h"
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
/*
|
||||
Andrew (aka pyrolink)
|
||||
Contact: ajdecker1022@msn.com
|
||||
|
@ -331,7 +331,7 @@ void CGUI::SendEventToAll(CStr EventName)
|
||||
//-------------------------------------------------------------------
|
||||
// Constructor / Destructor
|
||||
//-------------------------------------------------------------------
|
||||
CGUI::CGUI() : m_InternalNameNumber(0), m_MouseButtons(0), m_FocusedObject(NULL)
|
||||
CGUI::CGUI() : m_MouseButtons(0), m_FocusedObject(NULL), m_InternalNameNumber(0)
|
||||
{
|
||||
m_BaseObject = new CGUIDummyObject;
|
||||
m_BaseObject->SetGUI(this);
|
||||
|
@ -24,9 +24,14 @@ ERROR_TYPE(GUI, JSOpenFailed);
|
||||
//--------------------------------------------------------
|
||||
// Includes / Compiler directives
|
||||
//--------------------------------------------------------
|
||||
#include "GUI.h"
|
||||
// NOTE: GUI.h included at the bottom of this file (has to be after CGUI class
|
||||
// definition)
|
||||
|
||||
#include "GUITooltip.h"
|
||||
#include "GUIbase.h"
|
||||
|
||||
#include "ps/Overlay.h" // CPos and CRect
|
||||
|
||||
#include "Singleton.h"
|
||||
#include "lib/input.h"
|
||||
|
||||
@ -57,11 +62,22 @@ extern InReaction gui_handler(const SDL_Event* ev);
|
||||
*/
|
||||
struct SGUIStyle
|
||||
{
|
||||
// A list of defualts for
|
||||
// A list of defaults for
|
||||
std::map<CStr, CStr> m_SettingsDefaults;
|
||||
};
|
||||
|
||||
struct JSObject; // The GUI stores a JSObject*, so needs to know that JSObject exists
|
||||
class IGUIObject;
|
||||
class CGUISpriteInstance;
|
||||
struct SGUIText;
|
||||
class CColor;
|
||||
class SGUIText;
|
||||
class SGUIIcon;
|
||||
class CGUIString;
|
||||
class CGUISprite;
|
||||
struct SGUIImageEffects;
|
||||
struct SGUIScrollBarStyle;
|
||||
class GUITooltip;
|
||||
|
||||
/**
|
||||
* @author Gustav Larsson
|
||||
@ -622,4 +638,7 @@ private:
|
||||
std::map<CStr, SGUIIcon> m_Icons;
|
||||
};
|
||||
|
||||
|
||||
#include "GUI.h"
|
||||
|
||||
#endif
|
||||
|
@ -25,7 +25,7 @@ gee@pyro.nu
|
||||
//--------------------------------------------------------
|
||||
// Includes / Compiler directives
|
||||
//--------------------------------------------------------
|
||||
#include "GUIutil.h"
|
||||
#include "GUIbase.h"
|
||||
|
||||
#include "Overlay.h"
|
||||
#include "lib/res/graphics/ogl_tex.h"
|
||||
|
@ -5,8 +5,164 @@ gee@pyro.nu
|
||||
*/
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "GUI.h"
|
||||
|
||||
using std::string;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Help Classes/Structs for the GUI implementation
|
||||
//--------------------------------------------------------
|
||||
|
||||
CClientArea::CClientArea() : pixel(0.f,0.f,0.f,0.f), percent(0.f,0.f,0.f,0.f)
|
||||
{
|
||||
}
|
||||
|
||||
CClientArea::CClientArea(const CStr& Value)
|
||||
{
|
||||
SetClientArea(Value);
|
||||
}
|
||||
|
||||
CRect CClientArea::GetClientArea(const CRect &parent) const
|
||||
{
|
||||
// If it's a 0 0 100% 100% we need no calculations
|
||||
if (percent == CRect(0.f,0.f,100.f,100.f) && pixel == CRect(0.f,0.f,0.f,0.f))
|
||||
return parent;
|
||||
|
||||
CRect client;
|
||||
|
||||
// This should probably be cached and not calculated all the time for every object.
|
||||
client.left = parent.left + (parent.right-parent.left)*percent.left/100.f + pixel.left;
|
||||
client.top = parent.top + (parent.bottom-parent.top)*percent.top/100.f + pixel.top;
|
||||
client.right = parent.left + (parent.right-parent.left)*percent.right/100.f + pixel.right;
|
||||
client.bottom = parent.top + (parent.bottom-parent.top)*percent.bottom/100.f + pixel.bottom;
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
bool CClientArea::SetClientArea(const CStr& Value)
|
||||
{
|
||||
// Get value in STL string format
|
||||
string _Value = Value;
|
||||
|
||||
// This might lack incredible speed, but since all XML files
|
||||
// are read at startup, reading 100 client areas will be
|
||||
// negligible in the loading time.
|
||||
|
||||
// Setup parser to parse the value
|
||||
|
||||
// One of the four values:
|
||||
// will give outputs like (in argument):
|
||||
// (200) <== no percent, just the first $value
|
||||
// (200) (percent) <== just the percent
|
||||
// (200) (percent) (100) <== percent PLUS pixel
|
||||
// (200) (percent) (-100) <== percent MINUS pixel
|
||||
// (200) (percent) (100) (-100) <== Both PLUS and MINUS are used, INVALID
|
||||
/*
|
||||
string one_value = "_[-_$arg(_minus)]$value[$arg(percent)%_[+_$value]_[-_$arg(_minus)$value]_]";
|
||||
string four_values = one_value + "$arg(delim)" +
|
||||
one_value + "$arg(delim)" +
|
||||
one_value + "$arg(delim)" +
|
||||
one_value + "$arg(delim)_"; // it's easier to just end with another delimiter
|
||||
*/
|
||||
// Don't use the above strings, because they make this code go very slowly
|
||||
const char* four_values =
|
||||
"_[-_$arg(_minus)]$value[$arg(percent)%_[+_$value]_[-_$arg(_minus)$value]_]" "$arg(delim)"
|
||||
"_[-_$arg(_minus)]$value[$arg(percent)%_[+_$value]_[-_$arg(_minus)$value]_]" "$arg(delim)"
|
||||
"_[-_$arg(_minus)]$value[$arg(percent)%_[+_$value]_[-_$arg(_minus)$value]_]" "$arg(delim)"
|
||||
"_[-_$arg(_minus)]$value[$arg(percent)%_[+_$value]_[-_$arg(_minus)$value]_]" "$arg(delim)"
|
||||
"_";
|
||||
CParser& parser (CParserCache::Get(four_values));
|
||||
|
||||
CParserLine line;
|
||||
line.ParseString(parser, _Value);
|
||||
|
||||
if (!line.m_ParseOK)
|
||||
return false;
|
||||
|
||||
int arg_count[4]; // argument counts for the four values
|
||||
int arg_start[4] = {0,0,0,0}; // location of first argument, [0] is always 0
|
||||
|
||||
// Divide into the four piles (delimiter is an argument named "delim")
|
||||
for (int i=0, valuenr=0; i<(int)line.GetArgCount(); ++i)
|
||||
{
|
||||
string str;
|
||||
line.GetArgString(i, str);
|
||||
if (str == "delim")
|
||||
{
|
||||
if (valuenr==0)
|
||||
{
|
||||
arg_count[0] = i;
|
||||
arg_start[1] = i+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (valuenr!=3)
|
||||
{
|
||||
debug_assert(valuenr <= 2);
|
||||
arg_start[valuenr+1] = i+1;
|
||||
arg_count[valuenr] = arg_start[valuenr+1] - arg_start[valuenr] - 1;
|
||||
}
|
||||
else
|
||||
arg_count[3] = (int)line.GetArgCount() - arg_start[valuenr] - 1;
|
||||
}
|
||||
|
||||
++valuenr;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate argument
|
||||
|
||||
// This is the scheme:
|
||||
// 1 argument = Just pixel value
|
||||
// 2 arguments = Just percent value
|
||||
// 3 arguments = percent and pixel
|
||||
// 4 arguments = INVALID
|
||||
|
||||
// Default to 0
|
||||
float values[4][2] = {{0.f,0.f},{0.f,0.f},{0.f,0.f},{0.f,0.f}};
|
||||
for (int v=0; v<4; ++v)
|
||||
{
|
||||
if (arg_count[v] == 1)
|
||||
{
|
||||
string str;
|
||||
line.GetArgString(arg_start[v], str);
|
||||
|
||||
if (!line.GetArgFloat(arg_start[v], values[v][1]))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
if (arg_count[v] == 2)
|
||||
{
|
||||
if (!line.GetArgFloat(arg_start[v], values[v][0]))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
if (arg_count[v] == 3)
|
||||
{
|
||||
if (!line.GetArgFloat(arg_start[v], values[v][0]) ||
|
||||
!line.GetArgFloat(arg_start[v]+2, values[v][1]))
|
||||
return false;
|
||||
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
// Now store the values[][] in the right place
|
||||
pixel.left = values[0][1];
|
||||
pixel.top = values[1][1];
|
||||
pixel.right = values[2][1];
|
||||
pixel.bottom = values[3][1];
|
||||
percent.left = values[0][0];
|
||||
percent.top = values[1][0];
|
||||
percent.right = values[2][0];
|
||||
percent.bottom = values[3][0];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Error definitions
|
||||
|
@ -142,6 +142,64 @@ enum EVAlign { EVAlign_Top, EVAlign_Bottom, EVAlign_Center };
|
||||
typedef std::map<CStr, IGUIObject*> map_pObjects;
|
||||
typedef std::vector<IGUIObject*> vector_pObjects;
|
||||
|
||||
// Icon, you create them in the XML file with root element <setup>
|
||||
// you use them in text owned by different objects... Such as CText.
|
||||
struct SGUIIcon
|
||||
{
|
||||
SGUIIcon() : m_CellID(0) {}
|
||||
|
||||
// Sprite name of icon
|
||||
CStr m_SpriteName;
|
||||
|
||||
// Size
|
||||
CSize m_Size;
|
||||
|
||||
// Cell of texture to use; ignored unless the texture has specified cell-size
|
||||
int m_CellID;
|
||||
};
|
||||
|
||||
/**
|
||||
* @author Gustav Larsson
|
||||
*
|
||||
* Client Area is a rectangle relative to a parent rectangle
|
||||
*
|
||||
* You can input the whole value of the Client Area by
|
||||
* string. Like used in the GUI.
|
||||
*/
|
||||
class CClientArea
|
||||
{
|
||||
public:
|
||||
CClientArea();
|
||||
CClientArea(const CStr& Value);
|
||||
|
||||
/// Pixel modifiers
|
||||
CRect pixel;
|
||||
|
||||
/// Percent modifiers
|
||||
CRect percent;
|
||||
|
||||
/**
|
||||
* Get client area rectangle when the parent is given
|
||||
*/
|
||||
CRect GetClientArea(const CRect &parent) const;
|
||||
|
||||
/**
|
||||
* The ClientArea can be set from a string looking like:
|
||||
*
|
||||
* "0 0 100% 100%"
|
||||
* "50%-10 50%-10 50%+10 50%+10"
|
||||
*
|
||||
* i.e. First percent modifier, then + or - and the pixel modifier.
|
||||
* Although you can use just the percent or the pixel modifier. Notice
|
||||
* though that the percent modifier must always be the first when
|
||||
* both modifiers are inputted.
|
||||
*
|
||||
* @return true if success, false if failure. If false then the client area
|
||||
* will be unchanged.
|
||||
*/
|
||||
bool SetClientArea(const CStr& Value);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Error declarations
|
||||
//--------------------------------------------------------
|
||||
|
@ -244,156 +244,6 @@ void guiLoadIdentity()
|
||||
glScalef(1.0f, -1.f, 1.0f);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Help Classes/Structs for the GUI implementation
|
||||
//--------------------------------------------------------
|
||||
|
||||
CClientArea::CClientArea() : pixel(0.f,0.f,0.f,0.f), percent(0.f,0.f,0.f,0.f)
|
||||
{
|
||||
}
|
||||
|
||||
CClientArea::CClientArea(const CStr& Value)
|
||||
{
|
||||
SetClientArea(Value);
|
||||
}
|
||||
|
||||
CRect CClientArea::GetClientArea(const CRect &parent) const
|
||||
{
|
||||
// If it's a 0 0 100% 100% we need no calculations
|
||||
if (percent == CRect(0.f,0.f,100.f,100.f) && pixel == CRect(0.f,0.f,0.f,0.f))
|
||||
return parent;
|
||||
|
||||
CRect client;
|
||||
|
||||
// This should probably be cached and not calculated all the time for every object.
|
||||
client.left = parent.left + (parent.right-parent.left)*percent.left/100.f + pixel.left;
|
||||
client.top = parent.top + (parent.bottom-parent.top)*percent.top/100.f + pixel.top;
|
||||
client.right = parent.left + (parent.right-parent.left)*percent.right/100.f + pixel.right;
|
||||
client.bottom = parent.top + (parent.bottom-parent.top)*percent.bottom/100.f + pixel.bottom;
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
bool CClientArea::SetClientArea(const CStr& Value)
|
||||
{
|
||||
// Get value in STL string format
|
||||
string _Value = Value;
|
||||
|
||||
// This might lack incredible speed, but since all XML files
|
||||
// are read at startup, reading 100 client areas will be
|
||||
// negligible in the loading time.
|
||||
|
||||
// Setup parser to parse the value
|
||||
|
||||
// One of the four values:
|
||||
// will give outputs like (in argument):
|
||||
// (200) <== no percent, just the first $value
|
||||
// (200) (percent) <== just the percent
|
||||
// (200) (percent) (100) <== percent PLUS pixel
|
||||
// (200) (percent) (-100) <== percent MINUS pixel
|
||||
// (200) (percent) (100) (-100) <== Both PLUS and MINUS are used, INVALID
|
||||
/*
|
||||
string one_value = "_[-_$arg(_minus)]$value[$arg(percent)%_[+_$value]_[-_$arg(_minus)$value]_]";
|
||||
string four_values = one_value + "$arg(delim)" +
|
||||
one_value + "$arg(delim)" +
|
||||
one_value + "$arg(delim)" +
|
||||
one_value + "$arg(delim)_"; // it's easier to just end with another delimiter
|
||||
*/
|
||||
// Don't use the above strings, because they make this code go very slowly
|
||||
const char* four_values =
|
||||
"_[-_$arg(_minus)]$value[$arg(percent)%_[+_$value]_[-_$arg(_minus)$value]_]" "$arg(delim)"
|
||||
"_[-_$arg(_minus)]$value[$arg(percent)%_[+_$value]_[-_$arg(_minus)$value]_]" "$arg(delim)"
|
||||
"_[-_$arg(_minus)]$value[$arg(percent)%_[+_$value]_[-_$arg(_minus)$value]_]" "$arg(delim)"
|
||||
"_[-_$arg(_minus)]$value[$arg(percent)%_[+_$value]_[-_$arg(_minus)$value]_]" "$arg(delim)"
|
||||
"_";
|
||||
CParser& parser (CParserCache::Get(four_values));
|
||||
|
||||
CParserLine line;
|
||||
line.ParseString(parser, _Value);
|
||||
|
||||
if (!line.m_ParseOK)
|
||||
return false;
|
||||
|
||||
int arg_count[4]; // argument counts for the four values
|
||||
int arg_start[4] = {0,0,0,0}; // location of first argument, [0] is always 0
|
||||
|
||||
// Divide into the four piles (delimiter is an argument named "delim")
|
||||
for (int i=0, valuenr=0; i<(int)line.GetArgCount(); ++i)
|
||||
{
|
||||
string str;
|
||||
line.GetArgString(i, str);
|
||||
if (str == "delim")
|
||||
{
|
||||
if (valuenr==0)
|
||||
{
|
||||
arg_count[0] = i;
|
||||
arg_start[1] = i+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (valuenr!=3)
|
||||
{
|
||||
debug_assert(valuenr <= 2);
|
||||
arg_start[valuenr+1] = i+1;
|
||||
arg_count[valuenr] = arg_start[valuenr+1] - arg_start[valuenr] - 1;
|
||||
}
|
||||
else
|
||||
arg_count[3] = (int)line.GetArgCount() - arg_start[valuenr] - 1;
|
||||
}
|
||||
|
||||
++valuenr;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate argument
|
||||
|
||||
// This is the scheme:
|
||||
// 1 argument = Just pixel value
|
||||
// 2 arguments = Just percent value
|
||||
// 3 arguments = percent and pixel
|
||||
// 4 arguments = INVALID
|
||||
|
||||
// Default to 0
|
||||
float values[4][2] = {{0.f,0.f},{0.f,0.f},{0.f,0.f},{0.f,0.f}};
|
||||
for (int v=0; v<4; ++v)
|
||||
{
|
||||
if (arg_count[v] == 1)
|
||||
{
|
||||
string str;
|
||||
line.GetArgString(arg_start[v], str);
|
||||
|
||||
if (!line.GetArgFloat(arg_start[v], values[v][1]))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
if (arg_count[v] == 2)
|
||||
{
|
||||
if (!line.GetArgFloat(arg_start[v], values[v][0]))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
if (arg_count[v] == 3)
|
||||
{
|
||||
if (!line.GetArgFloat(arg_start[v], values[v][0]) ||
|
||||
!line.GetArgFloat(arg_start[v]+2, values[v][1]))
|
||||
return false;
|
||||
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
// Now store the values[][] in the right place
|
||||
pixel.left = values[0][1];
|
||||
pixel.top = values[1][1];
|
||||
pixel.right = values[2][1];
|
||||
pixel.bottom = values[3][1];
|
||||
percent.left = values[0][0];
|
||||
percent.top = values[1][0];
|
||||
percent.right = values[2][0];
|
||||
percent.bottom = values[3][0];
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Utilities implementation
|
||||
//--------------------------------------------------------
|
||||
|
@ -25,6 +25,9 @@ gee@pyro.nu
|
||||
#include "Parser.h"
|
||||
// TODO Gee: New
|
||||
#include "Overlay.h"
|
||||
#include "CGUI.h"
|
||||
#include "CGUISprite.h"
|
||||
#include "IGUIObject.h"
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Help Classes/Structs for the GUI
|
||||
@ -41,72 +44,10 @@ bool __ParseString(const CStr& Value, T &tOutput);
|
||||
// just like the mouse position
|
||||
void guiLoadIdentity();
|
||||
|
||||
// Icon, you create them in the XML file with root element <setup>
|
||||
// you use them in text owned by different objects... Such as CText.
|
||||
struct SGUIIcon
|
||||
{
|
||||
SGUIIcon() : m_CellID(0) {}
|
||||
|
||||
// Sprite name of icon
|
||||
CStr m_SpriteName;
|
||||
|
||||
// Size
|
||||
CSize m_Size;
|
||||
|
||||
// Cell of texture to use; ignored unless the texture has specified cell-size
|
||||
int m_CellID;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @author Gustav Larsson
|
||||
*
|
||||
* Client Area is a rectangle relative to a parent rectangle
|
||||
*
|
||||
* You can input the whole value of the Client Area by
|
||||
* string. Like used in the GUI.
|
||||
*/
|
||||
class CClientArea
|
||||
{
|
||||
public:
|
||||
CClientArea();
|
||||
CClientArea(const CStr& Value);
|
||||
|
||||
/// Pixel modifiers
|
||||
CRect pixel;
|
||||
|
||||
/// Percent modifiers
|
||||
CRect percent;
|
||||
|
||||
/**
|
||||
* Get client area rectangle when the parent is given
|
||||
*/
|
||||
CRect GetClientArea(const CRect &parent) const;
|
||||
|
||||
/**
|
||||
* The ClientArea can be set from a string looking like:
|
||||
*
|
||||
* "0 0 100% 100%"
|
||||
* "50%-10 50%-10 50%+10 50%+10"
|
||||
*
|
||||
* i.e. First percent modifier, then + or - and the pixel modifier.
|
||||
* Although you can use just the percent or the pixel modifier. Notice
|
||||
* though that the percent modifier must always be the first when
|
||||
* both modifiers are inputted.
|
||||
*
|
||||
* @return true if success, false if failure. If false then the client area
|
||||
* will be unchanged.
|
||||
*/
|
||||
bool SetClientArea(const CStr& Value);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Forward declarations
|
||||
//--------------------------------------------------------
|
||||
class CGUI;
|
||||
class IGUIObject;
|
||||
struct SGUIMessage;
|
||||
class CGUISpriteInstance;
|
||||
|
||||
/**
|
||||
* @author Gustav Larsson
|
||||
|
@ -22,6 +22,7 @@ gee@pyro.nu
|
||||
#include "GUI.h"
|
||||
|
||||
struct SGUIScrollBarStyle;
|
||||
class IGUIScrollBar;
|
||||
|
||||
//--------------------------------------------------------
|
||||
// Macros
|
||||
|
@ -79,7 +79,7 @@ namespace I18n
|
||||
#if MSC_VERSION
|
||||
# pragma warning (disable: 4355)
|
||||
#endif
|
||||
CLocale(JSContext* context, JSObject* scope) : Script(this, context, scope), CacheAge(0) {}
|
||||
CLocale(JSContext* context, JSObject* scope) : CacheAge(0), Script(this, context, scope) {}
|
||||
#if MSC_VERSION
|
||||
# pragma warning (default: 4355)
|
||||
#endif
|
||||
|
@ -406,15 +406,26 @@ static void pattern_set(const Alloc* a, ulong pattern)
|
||||
}
|
||||
|
||||
|
||||
static bool padding_is_intact(const Alloc* a)
|
||||
static bool padding_is_intact(const Alloc* a, ulong **corrupt_address)
|
||||
{
|
||||
*corrupt_address=NULL;
|
||||
|
||||
ulong* pre = (ulong*)a->p;
|
||||
ulong* post = (ulong*)( (char*)a->p + a->size - padding_size );
|
||||
|
||||
for(uint i = 0; i < padding_size / sizeof(ulong); i++)
|
||||
if(*pre++ != pattern_before || *post++ != pattern_after)
|
||||
{
|
||||
if(pre[i] != pattern_before)
|
||||
{
|
||||
*corrupt_address=&pre[i];
|
||||
return false;
|
||||
|
||||
}
|
||||
else if (post[i] != pattern_after)
|
||||
{
|
||||
*corrupt_address=&post[i];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -767,13 +778,16 @@ void mmgr_write_leak_report(void)
|
||||
// user-callable integrity checks
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool alloc_is_valid(const Alloc *a);
|
||||
|
||||
bool mmgr_is_valid_ptr(const void* p)
|
||||
{
|
||||
// null pointer - won't even try ;-)
|
||||
if (p == NULL)
|
||||
return false;
|
||||
lock();
|
||||
bool found = allocs_find(p) != 0;
|
||||
Alloc *a=allocs_find(p);
|
||||
bool found = a != NULL && alloc_is_valid(a);
|
||||
unlock();
|
||||
return found;
|
||||
}
|
||||
@ -785,10 +799,14 @@ static bool alloc_is_valid(const Alloc* a)
|
||||
// exceptions (e.g. "hardware is on fire") from getting through, but
|
||||
// there's really no alternative, since padding_is_intact is very
|
||||
// likely to crash if the Alloc is corrupted.
|
||||
// TODO Linux doesn't treat e.g. SIGSEGV as an exception (crashes instead)
|
||||
// Research linux/unix/gcc alternative for catching those (signal handler
|
||||
// and set/longjmp?)
|
||||
bool intact;
|
||||
ulong *p=NULL; // The corrupted address
|
||||
try
|
||||
{
|
||||
intact = padding_is_intact(a);
|
||||
intact = padding_is_intact(a, &p);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -799,9 +817,34 @@ static bool alloc_is_valid(const Alloc* a)
|
||||
// allocation's memory range) or is otherwise corrupt.
|
||||
if(!intact)
|
||||
{
|
||||
debug_assert(0 && "Memory over/underrun detected by mmgr");
|
||||
log("[!] Memory over/underrun:\n");
|
||||
// if p is between a->p and a->p+padding_size, accuse a and the alloc
|
||||
// before a, if p is between a->p+a->size-padding_size and a->p+a->size,
|
||||
// accuse a and the alloc after a
|
||||
// TODO This doesn't really find out the next/previous alloc area, just
|
||||
// prints the address, which end was currupted, and the data found
|
||||
if (p)
|
||||
{
|
||||
u8 *user_p = (u8 *)a->user_p();
|
||||
u8 *user_p_end = ((u8*)a->user_p()) + a->user_size();
|
||||
ulong expected=0;
|
||||
if ((u8*)p < user_p)
|
||||
{
|
||||
log("[!] Memory underrun: padding currupt at offset %d (bytes)\n",
|
||||
((u8 *)p)-user_p);
|
||||
expected=pattern_before;
|
||||
}
|
||||
else
|
||||
{
|
||||
log("[!] Memory overrun: padding currupt at %d bytes past end of buffer\n",
|
||||
((u8 *)p)-user_p_end);
|
||||
expected=pattern_after;
|
||||
}
|
||||
log("[!] Memory over/underrun: expected padding %08x, found garbage %08x\n", expected, *p);
|
||||
}
|
||||
else
|
||||
log("[!] alloc_is_valid encountered an exception - something may be very wrong!\n");
|
||||
log_this_alloc(a);
|
||||
debug_assert(0 && "Memory over/underrun detected by mmgr");
|
||||
}
|
||||
return intact;
|
||||
}
|
||||
@ -1148,8 +1191,8 @@ void* realloc_dbg(const void* user_p, size_t user_size, AllocType type, const ch
|
||||
if(!a)
|
||||
{
|
||||
// you called realloc for a pointer mmgr didn't allocate
|
||||
debug_assert(0 && "realloc was called for a pointer mmgr didn't allocate");
|
||||
log("[!] realloc: wasn't previously allocated\n");
|
||||
debug_assert(0 && "realloc was called for a pointer mmgr didn't allocate");
|
||||
goto fail;
|
||||
}
|
||||
// .. the owner wasn't compiled with mmgr.h
|
||||
@ -1172,8 +1215,8 @@ void* realloc_dbg(const void* user_p, size_t user_size, AllocType type, const ch
|
||||
|
||||
// old_size should only be non-zero if the Alloc security checks all passed
|
||||
// If the old buffer was actually zero bytes large, do nothing :P
|
||||
if (old_size)
|
||||
memcpy2(ret, user_p, old_size);
|
||||
if (old_size && ret)
|
||||
memcpy2(ret, user_p, MIN(old_size, user_size));
|
||||
|
||||
if(user_p)
|
||||
free_dbg(user_p, AT_FREE, file,line,func, stack_frames+1);
|
||||
|
@ -127,7 +127,7 @@
|
||||
#include <stdexcept>
|
||||
#include <streambuf>
|
||||
#include <string>
|
||||
#include <strstream>
|
||||
#include <sstream>
|
||||
#include <typeinfo>
|
||||
#include <valarray>
|
||||
|
||||
|
@ -692,10 +692,10 @@ namespace test {
|
||||
TEST(i32_from_double(1.01) == 1);
|
||||
TEST(i32_from_double(5.6) == 5);
|
||||
|
||||
TEST(i64_from_double(0.99999) == 0ll);
|
||||
TEST(i64_from_double(1.0) == 1ll);
|
||||
TEST(i64_from_double(1.01) == 1ll);
|
||||
TEST(i64_from_double(5.6) == 5ll);
|
||||
TEST(i64_from_double(0.99999) == 0LL);
|
||||
TEST(i64_from_double(1.0) == 1LL);
|
||||
TEST(i64_from_double(1.01) == 1LL);
|
||||
TEST(i64_from_double(5.6) == 5LL);
|
||||
}
|
||||
|
||||
static void self_test()
|
||||
|
@ -103,7 +103,7 @@ void udbg_launch_debugger()
|
||||
}
|
||||
}
|
||||
|
||||
void* debug_get_nth_caller(uint n, void *context)
|
||||
void* debug_get_nth_caller(uint n, void *UNUSED(context))
|
||||
{
|
||||
// bt[0] == debug_get_nth_caller
|
||||
// bt[1] == caller of get_nth_caller
|
||||
@ -116,7 +116,7 @@ void* debug_get_nth_caller(uint n, void *context)
|
||||
return bt[n+1]; // n==1 => bt[2], and so forth
|
||||
}
|
||||
|
||||
const wchar_t* debug_dump_stack(wchar_t* buf, size_t max_chars, uint skip, void* context)
|
||||
const wchar_t* debug_dump_stack(wchar_t* buf, size_t max_chars, uint skip, void* UNUSED(context))
|
||||
{
|
||||
++skip; // Skip ourselves too
|
||||
|
||||
@ -405,7 +405,6 @@ LibError debug_resolve_symbol(void* ptr_of_interest, char* sym_name, char* file,
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
#include "mmgr.h"
|
||||
|
||||
void debug_puts(const char* text)
|
||||
{
|
||||
@ -417,12 +416,13 @@ void debug_puts(const char* text)
|
||||
// TODO: Do these properly. (I don't know what I'm doing; I just
|
||||
// know that these functions are required in order to compile...)
|
||||
|
||||
int debug_write_crashlog(const char* file, wchar_t* header, void* context)
|
||||
int debug_write_crashlog(const char* UNUSED(file), wchar_t* UNUSED(header),
|
||||
void* UNUSED(context))
|
||||
{
|
||||
abort();
|
||||
}
|
||||
|
||||
int debug_is_pointer_bogus(const void* p)
|
||||
int debug_is_pointer_bogus(const void* UNUSED(p))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -434,7 +434,7 @@ void debug_heap_check()
|
||||
// if <full_monty> is true or PARANOIA #defined, all possible checks are
|
||||
// performed as often as possible. this is really slow (we are talking x100),
|
||||
// but reports errors closer to where they occurred.
|
||||
void debug_heap_enable(DebugHeapChecks what)
|
||||
void debug_heap_enable(DebugHeapChecks UNUSED(what))
|
||||
{
|
||||
// No-op until we find out if glibc has heap debugging
|
||||
}
|
||||
@ -442,4 +442,5 @@ void debug_heap_enable(DebugHeapChecks what)
|
||||
// disable all automatic checks until the next debug_heap_enable.
|
||||
void debug_heap_disable()
|
||||
{
|
||||
// No-op until we find out if glibc has heap debugging
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "sysdep/ia32.h"
|
||||
|
||||
// rationale for wrapping gettimeofday and clock_gettime, instead of emulating
|
||||
// them where not available: allows returning higher-resolution timer values
|
||||
// than their us / ns interface, via double [seconds]. they're also not
|
||||
|
@ -654,7 +654,7 @@ void CConsole::SaveHistory()
|
||||
break;
|
||||
buffer = CStrW( *it ).ToUTF8() + "\n" + buffer;
|
||||
}
|
||||
vfs_store( m_sHistoryFile, (void*)buffer.c_str(), buffer.Length(), FILE_NO_AIO );
|
||||
vfs_store( m_sHistoryFile, (const void*)buffer.c_str(), buffer.Length(), FILE_NO_AIO );
|
||||
}
|
||||
|
||||
void CConsole::SendChatMessage(const wchar_t *szMessage)
|
||||
|
@ -80,6 +80,7 @@
|
||||
|
||||
#include "Atlas.h"
|
||||
#include "GameSetup.h"
|
||||
#include "Config.h"
|
||||
|
||||
ERROR_GROUP(System);
|
||||
ERROR_TYPE(System, SDLInitFailed);
|
||||
|
@ -18,7 +18,7 @@ bool g_mouse_buttons[6] = {0};
|
||||
// updates the state of the above; never swallows messages.
|
||||
InReaction GlobalsInputHandler(const SDL_Event* ev)
|
||||
{
|
||||
int c;
|
||||
uint c;
|
||||
|
||||
switch(ev->type)
|
||||
{
|
||||
|
@ -381,8 +381,9 @@ bool CNetClient::ChatHandler(CNetMessage *pMsg, CNetSession *pSession)
|
||||
}
|
||||
HANDLED(pMsg);
|
||||
}
|
||||
default:
|
||||
UNHANDLED(pMsg);
|
||||
}
|
||||
UNHANDLED(pMsg);
|
||||
}
|
||||
|
||||
void CNetClient::OnClientConnect(int sessionID, const CStrW &name)
|
||||
|
@ -132,6 +132,8 @@ private:
|
||||
inline End(CMessagePipe *pPipe, CLockedMessageDeque *pIn, CLockedMessageDeque *pOut):
|
||||
m_pPipe(pPipe), m_pIn(pIn), m_pOut(pOut)
|
||||
{}
|
||||
|
||||
virtual ~End() {}
|
||||
|
||||
virtual void Push(CNetMessage *);
|
||||
virtual CNetMessage *TryPop();
|
||||
|
@ -8,26 +8,31 @@
|
||||
|
||||
|
||||
|
||||
const int HeaderMagic = 0x30424D58; // = "XMB0" (little-endian)
|
||||
const u32 HeaderMagic = 0x30424D58; // = "XMB0" (little-endian)
|
||||
const char* HeaderMagicStr = "XMB0";
|
||||
|
||||
// Warning: May contain traces of pointer abuse
|
||||
|
||||
void XMBFile::Initialise(char* FileData)
|
||||
void XMBFile::Initialise(const char* FileData)
|
||||
{
|
||||
m_Pointer = FileData;
|
||||
int Header = *(int*)m_Pointer; m_Pointer += 4;
|
||||
u32 Header = *(u32 *)m_Pointer; m_Pointer += 4;
|
||||
debug_assert(Header == HeaderMagic && "Invalid XMB header!");
|
||||
|
||||
int i;
|
||||
|
||||
// FIXME Check that m_Pointer doesn't end up past the end of the buffer
|
||||
// (it shouldn't be all that dangerous since we're only doing read-only
|
||||
// access, but it might crash on an invalid file, reading a couple of
|
||||
// billion random element names from RAM)
|
||||
|
||||
#ifdef XERO_USEMAP
|
||||
// Build a std::map of all the names->ids
|
||||
int ElementNameCount = *(int*)m_Pointer; m_Pointer += 4;
|
||||
u32 ElementNameCount = *(u32*)m_Pointer; m_Pointer += 4;
|
||||
for (i = 0; i < ElementNameCount; ++i)
|
||||
m_ElementNames[ReadZStrA()] = i;
|
||||
|
||||
int AttributeNameCount = *(int*)m_Pointer; m_Pointer += 4;
|
||||
u32 AttributeNameCount = *(u32*)m_Pointer; m_Pointer += 4;
|
||||
for (i = 0; i < AttributeNameCount; ++i)
|
||||
m_AttributeNames[ReadZStrA()] = i;
|
||||
#else
|
||||
@ -77,7 +82,7 @@ int XMBFile::getAttributeID(const char* Name) const
|
||||
|
||||
int XMBFile::getElementID(const char* Name) const
|
||||
{
|
||||
char* Pos = m_ElementPointer;
|
||||
const char* Pos = m_ElementPointer;
|
||||
|
||||
int len = (int)strlen(Name)+1; // count bytes, including null terminator
|
||||
|
||||
@ -97,7 +102,7 @@ int XMBFile::getElementID(const char* Name) const
|
||||
|
||||
int XMBFile::getAttributeID(const char* Name) const
|
||||
{
|
||||
char* Pos = m_AttributePointer;
|
||||
const char* Pos = m_AttributePointer;
|
||||
|
||||
int len = (int)strlen(Name)+1; // count bytes, including null terminator
|
||||
|
||||
@ -121,7 +126,7 @@ int XMBFile::getAttributeID(const char* Name) const
|
||||
// laziness overcomes the need for speed
|
||||
std::string XMBFile::getElementString(const int ID) const
|
||||
{
|
||||
char* Pos = m_ElementPointer;
|
||||
const char* Pos = m_ElementPointer;
|
||||
for (int i = 0; i < ID; ++i)
|
||||
Pos += 4 + *(int*)Pos;
|
||||
return std::string(Pos+4);
|
||||
@ -129,7 +134,7 @@ std::string XMBFile::getElementString(const int ID) const
|
||||
|
||||
std::string XMBFile::getAttributeString(const int ID) const
|
||||
{
|
||||
char* Pos = m_AttributePointer;
|
||||
const char* Pos = m_AttributePointer;
|
||||
for (int i = 0; i < ID; ++i)
|
||||
Pos += 4 + *(int*)Pos;
|
||||
return std::string(Pos+4);
|
||||
@ -179,7 +184,7 @@ int XMBElement::getLineNumber() const
|
||||
XMBElement XMBElementList::item(const int id)
|
||||
{
|
||||
debug_assert(id >= 0 && id < Count && "Element ID out of range");
|
||||
char* Pos;
|
||||
const char* Pos;
|
||||
|
||||
// If access is sequential, don't bother scanning
|
||||
// through all the nodes to find the next one
|
||||
@ -204,7 +209,7 @@ XMBElement XMBElementList::item(const int id)
|
||||
|
||||
utf16string XMBAttributeList::getNamedItem(const int AttributeName) const
|
||||
{
|
||||
char* Pos = m_Pointer;
|
||||
const char* Pos = m_Pointer;
|
||||
|
||||
// Maybe not the cleverest algorithm, but it should be
|
||||
// fast enough with half a dozen attributes:
|
||||
@ -222,7 +227,7 @@ utf16string XMBAttributeList::getNamedItem(const int AttributeName) const
|
||||
XMBAttribute XMBAttributeList::item(const int id)
|
||||
{
|
||||
debug_assert(id >= 0 && id < Count && "Attribute ID out of range");
|
||||
char* Pos;
|
||||
const char* Pos;
|
||||
|
||||
// If access is sequential, don't bother scanning through
|
||||
// all the nodes to find the right one
|
||||
@ -243,5 +248,5 @@ XMBAttribute XMBAttributeList::item(const int id)
|
||||
m_LastItemID = id;
|
||||
m_LastPointer = Pos;
|
||||
|
||||
return XMBAttribute(*(int*)Pos, utf16string( (utf16_t*)(Pos+8) ));
|
||||
return XMBAttribute(*(int*)Pos, utf16string( (const utf16_t*)(Pos+8) ));
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ XMB_Text {
|
||||
#endif
|
||||
|
||||
// File headers, to make sure it doesn't try loading anything other than an XMB
|
||||
extern const int HeaderMagic;
|
||||
extern const u32 HeaderMagic;
|
||||
extern const char* HeaderMagicStr;
|
||||
|
||||
class XMBElement;
|
||||
@ -115,7 +115,7 @@ public:
|
||||
// Initialise from the contents of an XMB file.
|
||||
// FileData must remain allocated and unchanged while
|
||||
// the XMBFile is being used.
|
||||
void Initialise(char* FileData);
|
||||
void Initialise(const char* FileData);
|
||||
|
||||
// Returns the root element
|
||||
XMBElement getRoot() const;
|
||||
@ -132,7 +132,7 @@ public:
|
||||
std::string getAttributeString(const int ID) const;
|
||||
|
||||
private:
|
||||
char* m_Pointer;
|
||||
const char* m_Pointer;
|
||||
|
||||
#ifdef XERO_USEMAP
|
||||
std::map<std::string, int> m_ElementNames;
|
||||
@ -140,8 +140,8 @@ private:
|
||||
#else
|
||||
int m_ElementNameCount;
|
||||
int m_AttributeNameCount;
|
||||
char* m_ElementPointer;
|
||||
char* m_AttributePointer;
|
||||
const char* m_ElementPointer;
|
||||
const char* m_AttributePointer;
|
||||
#endif
|
||||
|
||||
std::string ReadZStrA();
|
||||
@ -154,7 +154,7 @@ public:
|
||||
XMBElement()
|
||||
: m_Pointer(0) {}
|
||||
|
||||
XMBElement(char* offset)
|
||||
XMBElement(const char* offset)
|
||||
: m_Pointer(offset) {}
|
||||
|
||||
int getNodeName() const;
|
||||
@ -165,7 +165,7 @@ public:
|
||||
|
||||
private:
|
||||
// Pointer to the start of the node
|
||||
char* m_Pointer;
|
||||
const char* m_Pointer;
|
||||
};
|
||||
|
||||
class XMBElementList
|
||||
@ -175,7 +175,7 @@ public:
|
||||
XMBElementList()
|
||||
: Count(0), m_Pointer(0), m_LastItemID(-2) {}
|
||||
|
||||
XMBElementList(char* offset, int count)
|
||||
XMBElementList(const char* offset, int count)
|
||||
: Count(count),
|
||||
m_Pointer(offset),
|
||||
m_LastItemID(-2) {} // use -2 because it isn't x-1 where x is a non-negative integer
|
||||
@ -185,11 +185,11 @@ public:
|
||||
int Count;
|
||||
|
||||
private:
|
||||
char* m_Pointer;
|
||||
const char* m_Pointer;
|
||||
|
||||
// For optimised sequential access:
|
||||
int m_LastItemID;
|
||||
char* m_LastPointer;
|
||||
const char* m_LastPointer;
|
||||
};
|
||||
|
||||
|
||||
@ -206,7 +206,7 @@ struct XMBAttribute
|
||||
class XMBAttributeList
|
||||
{
|
||||
public:
|
||||
XMBAttributeList(char* offset, int count)
|
||||
XMBAttributeList(const char* offset, int count)
|
||||
: Count(count), m_Pointer(offset), m_LastItemID(-2) {};
|
||||
|
||||
// Get the attribute value directly (unlike Xerces)
|
||||
@ -219,11 +219,11 @@ public:
|
||||
|
||||
private:
|
||||
// Pointer to start of attribute list
|
||||
char* m_Pointer;
|
||||
const char* m_Pointer;
|
||||
|
||||
// For optimised sequential access:
|
||||
int m_LastItemID;
|
||||
char* m_LastPointer;
|
||||
const char* m_LastPointer;
|
||||
};
|
||||
|
||||
#endif // _XEROXMB_H_
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
|
||||
void write(const void* data, int size, int offset)
|
||||
{
|
||||
debug_assert(offset >= 0 && offset+size <= length);
|
||||
debug_assert(offset >= 0 && offset+size < length);
|
||||
memcpy2(&buffer[offset], data, size);
|
||||
}
|
||||
|
||||
@ -312,13 +312,13 @@ bool CXeromyces::ReadXMBFile(const char* filename)
|
||||
const void* buffer = file->GetBuffer();
|
||||
|
||||
debug_assert(file->GetBufferSize() >= 42 && "Invalid XMB file"); // 42 bytes is the smallest possible XMB. (Well, maybe not quite, but it's a nice number.)
|
||||
debug_assert(*(int*)buffer == HeaderMagic && "Invalid XMB file header");
|
||||
debug_assert(*(u32*)buffer == HeaderMagic && "Invalid XMB file header");
|
||||
|
||||
// Store the Handle so it can be closed later
|
||||
XMBFileHandle = file;
|
||||
|
||||
// Set up the XMBFile
|
||||
Initialise((char*)buffer);
|
||||
Initialise((const char*)buffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -480,13 +480,13 @@ void CPatchRData::RenderBase()
|
||||
{
|
||||
debug_assert(m_UpdateFlags==0);
|
||||
|
||||
u8* base=m_VBBase->m_Owner->Bind();
|
||||
SBaseVertex *base=(SBaseVertex *)m_VBBase->m_Owner->Bind();
|
||||
|
||||
// setup data pointers
|
||||
u32 stride=sizeof(SBaseVertex);
|
||||
glVertexPointer(3,GL_FLOAT,stride,base+offsetof(SBaseVertex,m_Position));
|
||||
glColorPointer(4,GL_UNSIGNED_BYTE,stride,base+offsetof(SBaseVertex,m_Color));
|
||||
glTexCoordPointer(2,GL_FLOAT,stride,base+offsetof(SBaseVertex,m_UVs[0]));
|
||||
glVertexPointer(3,GL_FLOAT,stride,&base->m_Position[0]);
|
||||
glColorPointer(4,GL_UNSIGNED_BYTE,stride,&base->m_Color);
|
||||
glTexCoordPointer(2,GL_FLOAT,stride,&base->m_UVs[0]);
|
||||
|
||||
// render each splat
|
||||
for (uint i=0;i<(uint)m_Splats.size();i++) {
|
||||
@ -503,14 +503,15 @@ void CPatchRData::RenderStreams(u32 streamflags)
|
||||
{
|
||||
debug_assert(m_UpdateFlags==0);
|
||||
|
||||
u8* base=m_VBBase->m_Owner->Bind();
|
||||
SBaseVertex* base=(SBaseVertex *)m_VBBase->m_Owner->Bind();
|
||||
|
||||
// setup data pointers
|
||||
glVertexPointer(3,GL_FLOAT,sizeof(SBaseVertex),base+offsetof(SBaseVertex,m_Position));
|
||||
u32 stride=sizeof(SBaseVertex);
|
||||
glVertexPointer(3, GL_FLOAT, stride, &base->m_Position);
|
||||
if (streamflags & STREAM_UV0) {
|
||||
glTexCoordPointer(2,GL_FLOAT,sizeof(SBaseVertex),base+offsetof(SBaseVertex,m_UVs));
|
||||
glTexCoordPointer(2, GL_FLOAT, stride, &base->m_UVs);
|
||||
} else if (streamflags & STREAM_POSTOUV0) {
|
||||
glTexCoordPointer(3,GL_FLOAT,sizeof(SBaseVertex),base+offsetof(SBaseVertex,m_Position));
|
||||
glTexCoordPointer(3, GL_FLOAT, stride, &base->m_Position);
|
||||
}
|
||||
|
||||
// render all base splats at once
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "ogl.h"
|
||||
#include "Renderer.h"
|
||||
#include "VertexBuffer.h"
|
||||
#include "VertexBufferManager.h"
|
||||
#include "ps/CLogger.h"
|
||||
|
||||
ERROR_GROUP(Renderer);
|
||||
@ -18,14 +19,20 @@ ERROR_TYPE(Renderer, VBOFailed);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// shared list of all free batch objects
|
||||
std::vector<CVertexBuffer::Batch*> CVertexBuffer::m_FreeBatches;
|
||||
std::vector<CVertexBuffer::Batch *> CVertexBuffer::m_FreeBatches;
|
||||
// NOTE: This global variable is here (as opposed to in VertexBufferManager.cpp,
|
||||
// as would be logical) to make sure that m_FreeBatches is freed in the right
|
||||
// order relative to the VertexBufferManager
|
||||
CVertexBufferManager g_VBMan;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Call at shutdown to free memory
|
||||
void CVertexBuffer::Shutdown()
|
||||
{
|
||||
for(std::vector<Batch*>::iterator iter=m_FreeBatches.begin();iter!=m_FreeBatches.end();++iter)
|
||||
{
|
||||
delete *iter;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -173,7 +180,7 @@ void CVertexBuffer::AppendBatch(VBChunk* UNUSED(chunk),Handle texture,size_t num
|
||||
batch=m_FreeBatches.back();
|
||||
m_FreeBatches.pop_back();
|
||||
} else {
|
||||
batch=new Batch;
|
||||
batch=new Batch();
|
||||
}
|
||||
m_Batches.push_back(batch);
|
||||
batch->m_Texture=texture;
|
||||
@ -207,6 +214,7 @@ void CVertexBuffer::UpdateChunkVertices(VBChunk* chunk,void* data)
|
||||
u8* CVertexBuffer::Bind()
|
||||
{
|
||||
u8* base;
|
||||
|
||||
if (g_Renderer.m_Caps.m_VBO) {
|
||||
pglBindBufferARB(GL_ARRAY_BUFFER_ARB,m_Handle);
|
||||
base=(u8*) 0;
|
||||
|
@ -18,6 +18,9 @@
|
||||
// absolute maximum (bytewise) size of each GL vertex buffer object
|
||||
#define MAX_VB_SIZE_BYTES (512*1024)
|
||||
|
||||
template <typename T>
|
||||
struct ctor_dtor_logger;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// CVertexBuffer: encapsulation of ARB_vertex_buffer_object, also supplying
|
||||
// some additional functionality for batching and sharing buffers between
|
||||
@ -66,8 +69,10 @@ public:
|
||||
// return this VBs batch list
|
||||
const std::vector<Batch*>& GetBatches() const { return m_Batches; }
|
||||
|
||||
const uint GetVertexSize() const { return m_VertexSize; }
|
||||
|
||||
// free memory
|
||||
static void CVertexBuffer::Shutdown();
|
||||
static void Shutdown();
|
||||
|
||||
protected:
|
||||
friend class CVertexBufferManager; // allow allocate only via CVertexBufferManager
|
||||
@ -96,8 +101,9 @@ private:
|
||||
u8* m_SysMem;
|
||||
// type of the buffer - dynamic?
|
||||
bool m_Dynamic;
|
||||
|
||||
// list of all spare batches, shared between all vbs
|
||||
static std::vector<Batch*> m_FreeBatches;
|
||||
static std::vector<Batch *> m_FreeBatches;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -13,8 +13,6 @@
|
||||
|
||||
#define LOG_CATEGORY "graphics"
|
||||
|
||||
CVertexBufferManager g_VBMan;
|
||||
|
||||
// janwas 2004-06-14: added dtor
|
||||
|
||||
CVertexBufferManager::~CVertexBufferManager()
|
||||
@ -27,15 +25,11 @@ CVertexBufferManager::~CVertexBufferManager()
|
||||
// global instances.
|
||||
void CVertexBufferManager::Shutdown()
|
||||
{
|
||||
debug_printf("CVertexBufferManager shutdown\n");
|
||||
|
||||
typedef std::list<CVertexBuffer*>::iterator Iter;
|
||||
for (Iter iter=m_Buffers.begin();iter!=m_Buffers.end();++iter)
|
||||
delete *iter;
|
||||
|
||||
|
||||
CVertexBuffer::Shutdown();
|
||||
|
||||
debug_printf("CVertexBufferManager shutdown finished\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,8 +24,9 @@ bool IEventTarget::_DispatchEvent( CScriptEvent* evt, IEventTarget* target )
|
||||
|
||||
evt->m_CurrentTarget = this;
|
||||
|
||||
HandlerList::iterator it;
|
||||
for( it = m_Handlers_id[evt->m_TypeCode].begin(); it != m_Handlers_id[evt->m_TypeCode].end(); it++ )
|
||||
HandlerList::const_iterator it;
|
||||
const HandlerList &handlers=m_Handlers_id[evt->m_TypeCode];
|
||||
for( it = handlers.begin(); it != handlers.end(); it++ )
|
||||
{
|
||||
DOMEventHandler id = *it;
|
||||
if( id && id->DispatchEvent( GetScriptExecContext( target ), evt ) )
|
||||
|
@ -4,6 +4,7 @@
|
||||
// in its objects. Shouldn't be used any more for anything but entity code.
|
||||
|
||||
#include "scripting/ScriptingHost.h"
|
||||
#include "simulation/ScriptObject.h"
|
||||
#include "JSConversions.h"
|
||||
|
||||
#include "lib/allocators.h"
|
||||
|
Loading…
Reference in New Issue
Block a user