Exception: Constructor now takes printf style arguments
This commit is contained in:
parent
5b736bcfd6
commit
9759e52b3c
7 changed files with 20 additions and 30 deletions
|
@ -58,6 +58,6 @@ private:
|
|||
|
||||
/* Every cpp needs to define DISP_CLASS_NAME for itself (lowercase) */
|
||||
#define GUARD_DISPOSED \
|
||||
{ if (isDisposed()) throw Exception(Exception::RGSSError, "disposed %S", DISP_CLASS_NAME); }
|
||||
{ if (isDisposed()) throw Exception(Exception::RGSSError, "disposed %s", DISP_CLASS_NAME); }
|
||||
|
||||
#endif // DISPOSABLE_H
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
struct Exception
|
||||
{
|
||||
|
@ -44,19 +45,19 @@ struct Exception
|
|||
};
|
||||
|
||||
Type type;
|
||||
std::string fmt;
|
||||
std::string arg1;
|
||||
std::string arg2;
|
||||
std::string msg;
|
||||
|
||||
Exception(Type type, std::string fmt,
|
||||
std::string arg1 = std::string(),
|
||||
std::string arg2 = std::string())
|
||||
: type(type), fmt(fmt), arg1(arg1), arg2(arg2)
|
||||
{}
|
||||
|
||||
void snprintf(char *buffer, size_t bufSize) const
|
||||
Exception(Type type, const char *format, ...)
|
||||
: type(type)
|
||||
{
|
||||
::snprintf(buffer, bufSize, fmt.c_str(), arg1.c_str(), arg2.c_str());
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
|
||||
msg.resize(512);
|
||||
vsnprintf(&msg[0], msg.size(), format, ap);
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -128,14 +128,9 @@ TEXFBO TexPool::request(int width, int height)
|
|||
|
||||
int maxSize = glState.caps.maxTexSize;
|
||||
if (width > maxSize || height > maxSize)
|
||||
{
|
||||
char buffer[128];
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"Texture dimensions [%d, %d] exceed hardware capabilities",
|
||||
width, height);
|
||||
|
||||
throw Exception(Exception::MKXPError, buffer);
|
||||
}
|
||||
throw Exception(Exception::MKXPError,
|
||||
"Texture dimensions [%d, %d] exceed hardware capabilities",
|
||||
width, height);
|
||||
|
||||
/* Nope, create it instead */
|
||||
TEXFBO::init(cnode.obj);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue