本文整理匯總了C++中Error函數的典型用法代碼示例。如果您正苦於以下問題:C++ Error函數的具體用法?C++ Error怎麽用?C++ Error使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Error函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: Assert
ubyte *gr_ibitblt_create_mask_sub( grsBitmap * mask_bmp, int sx, int sy, int sw, int sh, int srowSize, int destType )
{
int x,y;
ubyte pixel;
int draw_mode = MODE_NONE;
int source_offset = 0;
int dest_offset = 0;
int num_to_draw, draw_start_source, draw_start_dest;
int esi, edi;
int code_size;
ubyte *code;
uint temp;
Assert( (!(mask_bmp->bmProps.flags&BM_FLAG_RLE)) );
if ( destType == BM_SVGA )
code_size = gr_ibitblt_find_code_size_svga( mask_bmp, sx, sy, sw, sh, srowSize );
else
code_size = gr_ibitblt_find_code_size( mask_bmp, sx, sy, sw, sh, srowSize );
code = D2_ALLOC( code_size );
if ( code == NULL )
return NULL;
Code_pointer = code;
if ( destType == BM_SVGA ) {
// MOV EBX, gr_vesa_setpage
*Code_pointer++ = OPCODE_MOV_EBX;
temp = (uint)gr_vesa_setpage;
memcpy( Code_pointer, &temp, sizeof(int) );
Code_pointer += sizeof(int);
// MOV EAX, 0
*Code_pointer++ = OPCODE_MOV_EAX;
temp = 0;
memcpy( Code_pointer, &temp, sizeof(int) );
Code_pointer += sizeof(int);
// CALL EBX
*Code_pointer++ = OPCODE_CALL_EBX1;
*Code_pointer++ = OPCODE_CALL_EBX2;
ibitblt_svga_page = 0;
is_svga = 1;
linear_address = 0;
} else {
is_svga = 0;
}
esi = source_offset = 0;
edi = dest_offset = 0;
draw_start_source = draw_start_dest = 0;
for ( y=sy; y<sy+sh; y++ ) {
for ( x=sx; x<sx+sw; x++ ) {
dest_offset = y*mask_bmp->bmProps.rowSize+x;
pixel = mask_bmp->bmTexBuf[dest_offset];
if ( pixel!=255 ) {
switch ( draw_mode) {
case MODE_DRAW:
move_and_draw( draw_start_source-esi, draw_start_dest-edi, num_to_draw );
esi = draw_start_source + num_to_draw;
edi = draw_start_dest + num_to_draw;
// fall through!!!
case MODE_NONE:
case MODE_SKIP:
break;
}
draw_mode = MODE_SKIP;
} else {
switch ( draw_mode) {
case MODE_SKIP:
case MODE_NONE:
draw_start_source = source_offset;
draw_start_dest = dest_offset;
num_to_draw = 0;
// fall through
case MODE_DRAW:
num_to_draw++;
break;
}
draw_mode = MODE_DRAW;
}
source_offset++;
}
if ( draw_mode == MODE_DRAW ) {
move_and_draw( draw_start_source-esi, draw_start_dest-edi, num_to_draw );
esi = draw_start_source + num_to_draw;
edi = draw_start_dest + num_to_draw;
}
draw_mode = MODE_NONE;
source_offset += (srowSize - sw);
}
*Code_pointer++ = OPCODE_RET;
if ( Code_pointer >= &code[code_size-1] )
Error( "ibitblt overwrote allocated code block\n" );
////printf( "Code is %d bytes\n", Code_pointer - code );
return code;
}
示例2: jpeg_std_error
std::optional<ImageData2D> JpegImporter::doImage2D(UnsignedInt) {
/* Initialize structures */
jpeg_decompress_struct file;
JSAMPARRAY rows = nullptr;
unsigned char* data = nullptr;
/* Fugly error handling stuff */
/** @todo Get rid of this crap */
struct ErrorManager {
jpeg_error_mgr jpegErrorManager;
std::jmp_buf setjmpBuffer;
} errorManager;
file.err = jpeg_std_error(&errorManager.jpegErrorManager);
errorManager.jpegErrorManager.error_exit = [](j_common_ptr info) {
info->err->output_message(info);
std::longjmp(reinterpret_cast<ErrorManager*>(info->err)->setjmpBuffer, 1);
};
if(setjmp(errorManager.setjmpBuffer)) {
Error() << "Trade::JpegImporter::image2D(): error while reading JPEG file";
jpeg_destroy_decompress(&file);
delete[] rows;
delete[] data;
return std::nullopt;
}
/* Open file */
jpeg_create_decompress(&file);
jpeg_mem_src(&file, _in.begin(), _in.size());
/* Read file header, start decompression */
jpeg_read_header(&file, true);
jpeg_start_decompress(&file);
/* Image size and type */
const Vector2i size(file.output_width, file.output_height);
static_assert(BITS_IN_JSAMPLE == 8, "Only 8-bit JPEG is supported");
constexpr const ImageType type = ImageType::UnsignedByte;
/* Image format */
ImageFormat format;
switch(file.out_color_space) {
case JCS_GRAYSCALE:
CORRADE_INTERNAL_ASSERT(file.out_color_components == 1);
#ifdef MAGNUM_TARGET_GLES
format = Context::current() && Context::current()->isExtensionSupported<Extensions::GL::EXT::texture_rg>() ?
ImageFormat::Red : ImageFormat::Luminance;
#else
format = ImageFormat::Red;
#endif
break;
case JCS_RGB:
CORRADE_INTERNAL_ASSERT(file.out_color_components == 3);
format = ImageFormat::RGB;
break;
/** @todo RGBA (only in libjpeg-turbo and probably ignored) */
default:
Error() << "Trade::JpegImporter::image2D(): unsupported color space" << file.out_color_space;
}
/* Initialize data array */
data = new unsigned char[size.product()*file.out_color_components*BITS_IN_JSAMPLE/8];
/* Read image row by row */
rows = new JSAMPROW[size.y()];
const Int stride = size.x()*file.out_color_components*BITS_IN_JSAMPLE/8;
for(Int i = 0; i != size.y(); ++i)
rows[i] = data + (size.y() - i - 1)*stride;
while(file.output_scanline < file.output_height)
jpeg_read_scanlines(&file, rows+file.output_scanline, file.output_height-file.output_scanline);
delete[] rows;
rows = nullptr;
/* Cleanup */
jpeg_finish_decompress(&file);
jpeg_destroy_decompress(&file);
return Trade::ImageData2D(format, type, size, data);
}
示例3: SignatureSha256
SignatureSha256(const Signature& signature)
: Signature(signature)
{
if (getType() != Signature::Sha256)
throw Error("Incorrect signature type");
}
示例4: throw
void GifImage::setExifData(const ExifData& /*exifData*/)
{
// Todo: implement me!
throw(Error(32, "Exif metadata", "GIF"));
}
示例5: Show_Message
void LineSum::Line_Sum_Report (int number)
{
int stop, stops, run, runs, period, per, num, time;
int on, off, ride, total, max_ride, *total_rider, *max_load;
char buffer [FIELD_BUFFER];
bool last_stop_flag, stop_flag, line_flag;
Rider_Data *rider_ptr;
Offset_Data *offset_ptr;
Show_Message ("Creating a Line Summary Report -- Record");
Set_Progress (100);
//---- initialize the selection sets ----
set_ptr = select_set [number];
if (set_ptr == NULL) return;
Header_Number (LINE_SUM);
//---- initialize the report data ----
if (!Break_Check (rider_data.Num_Records () + 6)) {
Print (1);
Line_Sum_Header ();
}
num = set_ptr->Num_Periods () + 1;
total_rider = new int [num];
max_load = new int [num];
if (total_rider == NULL || max_load == NULL) {
Error ("Insufficient Space for %d Time Periods", num);
}
memset (total_rider, '\0', num * sizeof (int));
memset (max_load, '\0', num * sizeof (int));
//---- process each route ----
for (rider_ptr = rider_data.First_Key (); rider_ptr; rider_ptr = rider_data.Next_Key ()) {
Show_Progress ();
//---- check the selection criteria ----
if (!set_ptr->Select_Modes (rider_ptr->Mode ())) continue;
if (!set_ptr->Select_Routes (rider_ptr->Route ())) continue;
stops = rider_ptr->Stops ();
runs = rider_ptr->Runs ();
//---- check for stops in the subarea ----
if (offset_flag && set_ptr->Subarea_Flag ()) {
line_flag = false;
for (stop=1; stop <= stops; stop++) {
offset_ptr = stop_offset.Get (rider_ptr->Stop (stop));
if (offset_ptr == NULL) continue;
if (set_ptr->In_Subarea (offset_ptr->X (), offset_ptr->Y ())) {
line_flag = true;
break;
}
}
if (!line_flag) continue;
}
//---- print the line label ----
str_fmt (buffer, sizeof (buffer), "%s %d", Transit_Code ((Transit_Type) rider_ptr->Mode ()), rider_ptr->Route ());
Print (1, "%16.16s", buffer);
//---- process each time period ----
for (per=1; per < num; per++) {
total = max_ride = 0;
for (run=1; run <= runs; run++) {
switch (set_ptr->Time_Method ()) {
case RUN_START:
time = rider_ptr->Time (run, 1);
break;
case RUN_END:
time = rider_ptr->Time (run, stops);
break;
case RUN_MID:
time = (rider_ptr->Time (run, 1) + rider_ptr->Time (run, stops)) / 2;
break;
case SCHED_START:
time = rider_ptr->Schedule (run, 1);
break;
case SCHED_END:
time = rider_ptr->Schedule (run, stops);
break;
case SCHED_MID:
time = (rider_ptr->Schedule (run, 1) + rider_ptr->Schedule (run, stops)) / 2;
break;
}
//.........這裏部分代碼省略.........
示例6: xf86parseLayoutSection
XF86ConfLayoutPtr
xf86parseLayoutSection (void)
{
int has_ident = FALSE;
int token;
parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
while ((token = xf86getToken (LayoutTab)) != ENDSECTION)
{
switch (token)
{
case COMMENT:
ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
break;
case IDENTIFIER:
if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
Error (QUOTE_MSG, "Identifier");
if (has_ident == TRUE)
Error (MULTIPLE_MSG, "Identifier");
ptr->lay_identifier = val.str;
has_ident = TRUE;
break;
case INACTIVE:
{
XF86ConfInactivePtr iptr;
iptr = calloc (1, sizeof (XF86ConfInactiveRec));
iptr->list.next = NULL;
if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
free (iptr);
Error (INACTIVE_MSG);
}
iptr->inactive_device_str = val.str;
ptr->lay_inactive_lst = (XF86ConfInactivePtr)
xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr);
}
break;
case SCREEN:
{
XF86ConfAdjacencyPtr aptr;
int absKeyword = 0;
aptr = calloc (1, sizeof (XF86ConfAdjacencyRec));
aptr->list.next = NULL;
aptr->adj_scrnum = -1;
aptr->adj_where = CONF_ADJ_OBSOLETE;
aptr->adj_x = 0;
aptr->adj_y = 0;
aptr->adj_refscreen = NULL;
if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER)
aptr->adj_scrnum = val.num;
else
xf86unGetToken (token);
token = xf86getSubToken(&(ptr->lay_comment));
if (token != STRING) {
free(aptr);
Error (SCREEN_MSG);
}
aptr->adj_screen_str = val.str;
token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
switch (token)
{
case RIGHTOF:
aptr->adj_where = CONF_ADJ_RIGHTOF;
break;
case LEFTOF:
aptr->adj_where = CONF_ADJ_LEFTOF;
break;
case ABOVE:
aptr->adj_where = CONF_ADJ_ABOVE;
break;
case BELOW:
aptr->adj_where = CONF_ADJ_BELOW;
break;
case RELATIVE:
aptr->adj_where = CONF_ADJ_RELATIVE;
break;
case ABSOLUTE:
aptr->adj_where = CONF_ADJ_ABSOLUTE;
absKeyword = 1;
break;
case EOF_TOKEN:
free(aptr);
Error (UNEXPECTED_EOF_MSG);
break;
default:
xf86unGetToken (token);
token = xf86getSubToken(&(ptr->lay_comment));
if (token == STRING)
aptr->adj_where = CONF_ADJ_OBSOLETE;
else
aptr->adj_where = CONF_ADJ_ABSOLUTE;
}
switch (aptr->adj_where)
{
case CONF_ADJ_ABSOLUTE:
if (absKeyword)
token = xf86getSubToken(&(ptr->lay_comment));
if (token == NUMBER)
//.........這裏部分代碼省略.........
示例7: ReadDirectory
/*
* Read the next TIFF directory from a file
* and convert it to the internal format.
* We read directories sequentially.
*/
static uint64
ReadDirectory(int fd, unsigned int ix, uint64 off)
{
uint16 dircount;
uint32 direntrysize;
void* dirmem = NULL;
uint64 nextdiroff = 0;
uint32 n;
uint8* dp;
if (off == 0) /* no more directories */
goto done;
#if defined(__WIN32__) && defined(_MSC_VER)
if (_lseeki64(fd, (__int64)off, SEEK_SET) != (__int64)off) {
#else
if (lseek(fd, (off_t)off, SEEK_SET) != (off_t)off) {
#endif
Fatal("Seek error accessing TIFF directory");
goto done;
}
if (!bigtiff) {
if (read(fd, (char*) &dircount, sizeof (uint16)) != sizeof (uint16)) {
ReadError("directory count");
goto done;
}
if (swabflag)
TIFFSwabShort(&dircount);
direntrysize = 12;
} else {
uint64 dircount64 = 0;
if (read(fd, (char*) &dircount64, sizeof (uint64)) != sizeof (uint64)) {
ReadError("directory count");
goto done;
}
if (swabflag)
TIFFSwabLong8(&dircount64);
if (dircount64>0xFFFF) {
Error("Sanity check on directory count failed");
goto done;
}
dircount = (uint16)dircount64;
direntrysize = 20;
}
dirmem = _TIFFmalloc(dircount * direntrysize);
if (dirmem == NULL) {
Fatal("No space for TIFF directory");
goto done;
}
n = read(fd, (char*) dirmem, dircount*direntrysize);
if (n != dircount*direntrysize) {
n /= direntrysize;
Error(
#if defined(__WIN32__) && defined(_MSC_VER)
"Could only read %lu of %u entries in directory at offset %#I64x",
(unsigned long)n, dircount, (unsigned __int64) off);
#else
"Could only read %lu of %u entries in directory at offset %#llx",
(unsigned long)n, dircount, (unsigned long long) off);
#endif
dircount = n;
nextdiroff = 0;
} else {
if (!bigtiff) {
示例8: main
int main(int argc, char* argv[])
{
CLState_p state;
StructFOFSpec_p ctrl;
PStack_p prob_names = PStackAlloc();
int i;
AxFilterSet_p filters;
Scanner_p in;
DStr_p corename;
char *tname;
assert(argv[0]);
InitIO(NAME);
DocOutputFormat = tstp_format;
OutputFormat = TSTPFormat;
state = process_options(argc, argv);
OpenGlobalOut(outname);
if(filtername)
{
filters = AxFilterSetAlloc();
in = CreateScanner(StreamTypeFile, filtername, true, NULL);
AxFilterSetParse(in, filters);
DestroyScanner(in);
}
else
{
filters = AxFilterSetCreateInternal(AxFilterDefaultSet);
}
if(dumpfilter)
{
AxFilterSetPrint(GlobalOut, filters);
}
if(state->argc < 1)
{
Error("Usage: e_axfilter <problem> [<options>]\n", USAGE_ERROR);
}
for(i=0; state->argv[i]; i++)
{
PStackPushP(prob_names, state->argv[i]);
}
/* Base name is the stripped base of the first argument */
tname = FileNameStrip(state->argv[0]);
corename = DStrAlloc();
DStrAppendStr(corename, tname);
FREE(tname);
ctrl = StructFOFSpecAlloc();
StructFOFSpecParseAxioms(ctrl, prob_names, parse_format);
StructFOFSpecInitDistrib(ctrl);
StructFOFSpecResetShared(ctrl);
for(i=0; i<AxFilterSetElements(filters); i++)
{
/* SigPrint(stdout,ctrl->sig); */
filter_problem(ctrl,
AxFilterSetGetFilter(filters,i),
DStrView(corename));
}
StructFOFSpecFree(ctrl);
DStrFree(corename);
AxFilterSetFree(filters);
CLStateFree(state);
PStackFree(prob_names);
OutClose(GlobalOut);
ExitIO();
#ifdef CLB_MEMORY_DEBUG
MemFlushFreeList();
MemDebugPrintStats(stdout);
#endif
return 0;
}
示例9: W_LumpLength
/*
====================
W_LumpLength
Returns the buffer size needed to load the given lump
====================
*/
int W_LumpLength (int lump)
{
if (lump >= numlumps)
Error ("W_LumpLength: %i >= numlumps",lump);
return lumpinfo[lump].size;
}
示例10: MapBufferRangeEXT
void *GL_APIENTRY MapBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access)
{
EVENT("(GLenum target = 0x%X, GLintptr offset = %d, GLsizeiptr length = %d, GLbitfield access = 0x%X)",
target, offset, length, access);
Context *context = GetValidGlobalContext();
if (context)
{
if (!ValidBufferTarget(context, target))
{
context->recordError(Error(GL_INVALID_ENUM));
return NULL;
}
if (offset < 0 || length < 0)
{
context->recordError(Error(GL_INVALID_VALUE));
return NULL;
}
Buffer *buffer = context->getState().getTargetBuffer(target);
if (buffer == NULL)
{
context->recordError(Error(GL_INVALID_OPERATION));
return NULL;
}
// Check for buffer overflow
size_t offsetSize = static_cast<size_t>(offset);
size_t lengthSize = static_cast<size_t>(length);
if (!rx::IsUnsignedAdditionSafe(offsetSize, lengthSize) ||
offsetSize + lengthSize > static_cast<size_t>(buffer->getSize()))
{
context->recordError(Error(GL_INVALID_VALUE));
return NULL;
}
// Check for invalid bits in the mask
GLbitfield allAccessBits = GL_MAP_READ_BIT |
GL_MAP_WRITE_BIT |
GL_MAP_INVALIDATE_RANGE_BIT |
GL_MAP_INVALIDATE_BUFFER_BIT |
GL_MAP_FLUSH_EXPLICIT_BIT |
GL_MAP_UNSYNCHRONIZED_BIT;
if (access & ~(allAccessBits))
{
context->recordError(Error(GL_INVALID_VALUE));
return NULL;
}
if (length == 0 || buffer->isMapped())
{
context->recordError(Error(GL_INVALID_OPERATION));
return NULL;
}
// Check for invalid bit combinations
if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) == 0)
{
context->recordError(Error(GL_INVALID_OPERATION));
return NULL;
}
GLbitfield writeOnlyBits = GL_MAP_INVALIDATE_RANGE_BIT |
GL_MAP_INVALIDATE_BUFFER_BIT |
GL_MAP_UNSYNCHRONIZED_BIT;
if ((access & GL_MAP_READ_BIT) != 0 && (access & writeOnlyBits) != 0)
{
context->recordError(Error(GL_INVALID_OPERATION));
return NULL;
}
if ((access & GL_MAP_WRITE_BIT) == 0 && (access & GL_MAP_FLUSH_EXPLICIT_BIT) != 0)
{
context->recordError(Error(GL_INVALID_OPERATION));
return NULL;
}
Error error = buffer->mapRange(offset, length, access);
if (error.isError())
{
context->recordError(error);
return NULL;
}
return buffer->getMapPointer();
}
return NULL;
}
示例11: SetError
bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
{
if ( !file )
{
SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
return false;
}
// Delete the existing data:
Clear();
location.Clear();
// Get the file size, so we can pre-allocate the string. HUGE speed impact.
long length = 0;
fseek( file, 0, SEEK_END );
length = ftell( file );
fseek( file, 0, SEEK_SET );
// Strange case, but good to handle up front.
if ( length <= 0 )
{
SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
return false;
}
// If we have a file, assume it is all one big XML file, and read it in.
// The document parser may decide the document ends sooner than the entire file, however.
TIXML_STRING data;
data.reserve( length );
// Subtle bug here. TinyXml did use fgets. But from the XML spec:
// 2.11 End-of-Line Handling
// <snip>
// <quote>
// ...the XML processor MUST behave as if it normalized all line breaks in external
// parsed entities (including the document entity) on input, before parsing, by translating
// both the two-character sequence #xD #xA and any #xD that is not followed by #xA to
// a single #xA character.
// </quote>
//
// It is not clear fgets does that, and certainly isn't clear it works cross platform.
// Generally, you expect fgets to translate from the convention of the OS to the c/unix
// convention, and not work generally.
/*
while( fgets( buf, sizeof(buf), file ) )
{
data += buf;
}
*/
char* buf = new char[ length+1 ];
buf[0] = 0;
if ( fread( buf, length, 1, file ) != 1 ) {
delete [] buf;
SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
return false;
}
const char* lastPos = buf;
const char* p = buf;
buf[length] = 0;
while( *p ) {
assert( p < (buf+length) );
if ( *p == 0xa ) {
// Newline character. No special rules for this. Append all the characters
// since the last string, and include the newline.
data.append( lastPos, (p-lastPos+1) ); // append, include the newline
++p; // move past the newline
lastPos = p; // and point to the new buffer (may be 0)
assert( p <= (buf+length) );
}
else if ( *p == 0xd ) {
// Carriage return. Append what we have so far, then
// handle moving forward in the buffer.
if ( (p-lastPos) > 0 ) {
data.append( lastPos, p-lastPos ); // do not add the CR
}
data += (char)0xa; // a proper newline
if ( *(p+1) == 0xa ) {
// Carriage return - new line sequence
p += 2;
lastPos = p;
assert( p <= (buf+length) );
}
else {
// it was followed by something else...that is presumably characters again.
++p;
lastPos = p;
assert( p <= (buf+length) );
}
}
else {
++p;
}
}
// Handle any left over characters.
//.........這裏部分代碼省略.........
示例12: ReadTriggerInfo
static int ReadTriggerInfo (CFile& cf)
{
int h, i, j;
CTrigger *trigP;
if (gameFileInfo.triggers.count && (gameFileInfo.triggers.offset > -1)) {
#if TRACE
console.printf(CON_DBG, " loading CTrigger data ...\n");
#endif
if (!gameData.trigs.Create (gameFileInfo.triggers.count, false)) {
Error ("Not enough memory for trigger data");
return -1;
}
if (cf.Seek (gameFileInfo.triggers.offset, SEEK_SET)) {
Error ("Error seeking to trigger data\n(file damaged or invalid)");
return -1;
}
for (i = 0, trigP = TRIGGERS.Buffer (); i < gameFileInfo.triggers.count; i++, trigP++) {
if (gameTopFileInfo.fileinfoVersion >= 31)
trigP->Read (cf, 0);
else {
tTriggerV30 trig;
int t, nType = 0, flags = 0;
if (gameTopFileInfo.fileinfoVersion == 30)
V30TriggerRead (trig, cf);
else {
tTriggerV29 trig29;
V29TriggerRead (trig29, cf);
trig.flags = trig29.flags;
trig.nLinks = (char) trig29.nLinks;
trig.value = trig29.value;
trig.time = trig29.time;
for (t = 0; t < trig.nLinks; t++) {
trig.segments [t] = trig29.segments [t];
trig.sides [t] = trig29.sides [t];
}
}
//Assert(trig.flags & TRIGGER_ON);
trig.flags &= ~TRIGGER_ON;
if (trig.flags & TRIGGER_CONTROL_DOORS)
nType = TT_OPEN_DOOR;
else if (trig.flags & TRIGGER_SHIELD_DAMAGE)
nType = TT_SHIELD_DAMAGE;
else if (trig.flags & TRIGGER_ENERGY_DRAIN)
nType = TT_ENERGY_DRAIN;
else if (trig.flags & TRIGGER_EXIT)
nType = TT_EXIT;
else if (trig.flags & TRIGGER_MATCEN)
nType = TT_MATCEN;
else if (trig.flags & TRIGGER_ILLUSION_OFF)
nType = TT_ILLUSION_OFF;
else if (trig.flags & TRIGGER_SECRET_EXIT)
nType = TT_SECRET_EXIT;
else if (trig.flags & TRIGGER_ILLUSION_ON)
nType = TT_ILLUSION_ON;
else if (trig.flags & TRIGGER_UNLOCK_DOORS)
nType = TT_UNLOCK_DOOR;
else if (trig.flags & TRIGGER_OPEN_WALL)
nType = TT_OPEN_WALL;
else if (trig.flags & TRIGGER_CLOSE_WALL)
nType = TT_CLOSE_WALL;
else if (trig.flags & TRIGGER_ILLUSORY_WALL)
nType = TT_ILLUSORY_WALL;
else
Int3();
if (trig.flags & TRIGGER_ONE_SHOT)
flags = TF_ONE_SHOT;
trigP->nType = nType;
trigP->flags = flags;
trigP->nLinks = trig.nLinks;
trigP->nLinks = trig.nLinks;
trigP->value = trig.value;
trigP->time = trig.time;
for (t = 0; t < trig.nLinks; t++) {
trigP->segments [t] = trig.segments [t];
trigP->sides [t] = trig.sides [t];
}
}
if (trigP->nLinks < 0)
trigP->nLinks = 0;
else if (trigP->nLinks > MAX_TRIGGER_TARGETS)
trigP->nLinks = MAX_TRIGGER_TARGETS;
for (h = trigP->nLinks, j = 0; j < h; ) {
if ((trigP->segments [j] >= 0) && (trigP->segments [j] < gameData.segs.nSegments) &&
(trigP->sides [j] >= 0) && (trigP->sides [j] < 6))
j++;
else if (--h) {
trigP->segments [j] = trigP->segments [h];
trigP->sides [j] = trigP->sides [h];
}
}
trigP->nLinks = h;
}
}
if (gameTopFileInfo.fileinfoVersion >= 33) {
gameData.trigs.m_nObjTriggers = cf.ReadInt ();
if (gameData.trigs.m_nObjTriggers) {
if (!gameData.trigs.Create (gameData.trigs.m_nObjTriggers, true)) {
//.........這裏部分代碼省略.........
示例13: diff
inline Try<Diff> diff(const std::string& from, const std::string& to)
{
// Initialize the Apache Portable Runtime subsystem, as necessary
// for using the svn library.
initialize();
// Note that svn_pool_create wraps apr_pool_create_ex, which is
// thread safe, see: http://goo.gl/NX0hps.
apr_pool_t* pool = svn_pool_create(NULL);
// First we need to produce a text delta stream by diffing 'source'
// against 'target'.
svn_string_t source;
source.data = from.data();
source.len = from.length();
svn_string_t target;
target.data = to.data();
target.len = to.length();
svn_txdelta_stream_t* delta;
#if SVN_VER_MAJOR >= 1 && SVN_VER_MINOR >= 8
svn_txdelta2(
&delta,
svn_stream_from_string(&source, pool),
svn_stream_from_string(&target, pool),
false,
pool);
#else
svn_txdelta(
&delta,
svn_stream_from_string(&source, pool),
svn_stream_from_string(&target, pool),
pool);
#endif
// Now we want to convert this text delta stream into an svndiff
// format based diff. Setup the handler that will consume the text
// delta and produce the svndiff.
svn_txdelta_window_handler_t handler;
void* baton = NULL;
svn_stringbuf_t* diff = svn_stringbuf_create_ensure(1024, pool);
#if SVN_VER_MAJOR >= 1 && SVN_VER_MINOR >= 7
svn_txdelta_to_svndiff3(
&handler,
&baton,
svn_stream_from_stringbuf(diff, pool),
0,
SVN_DELTA_COMPRESSION_LEVEL_DEFAULT,
pool);
#elif SVN_VER_MAJOR >= 1 && SVN_VER_MINOR >= 4
svn_txdelta_to_svndiff2(
&handler,
&baton,
svn_stream_from_stringbuf(diff, pool),
0,
pool);
#else
svn_txdelta_to_svndiff(
svn_stream_from_stringbuf(diff, pool),
pool,
&handler,
&baton);
#endif
// Now feed the text delta to the handler.
svn_error_t* error = svn_txdelta_send_txstream(delta, handler, baton, pool);
if (error != NULL) {
char buffer[1024];
std::string message(svn_err_best_message(error, buffer, 1024));
svn_pool_destroy(pool);
return Error(message);
}
Diff d(std::string(diff->data, diff->len));
svn_pool_destroy(pool);
return d;
}
示例14: WriteCFile
void WriteCFile (const StrBuf* Data, const Collection* A, const Bitmap* B)
/* Write the contents of Data to a file in C format */
{
FILE* F;
const char* D;
unsigned Size;
/* Get the name of the image */
const StrBuf* S = GetBitmapName (B);
/* Get the file name */
const char* Name = NeedAttrVal (A, "name", "write");
/* Check the number of bytes per line */
unsigned BytesPerLine = GetBytesPerLine (A);
/* Get the number base */
unsigned Base = GetBase (A);
/* Get the identifier */
const char* Ident = GetIdentifier (A);
/* Open the output file */
F = fopen (Name, "w");
if (F == 0) {
Error ("Cannot open output file `%s': %s", Name, strerror (errno));
}
/* Write a readable header */
fprintf (F,
"/*\n"
" * This file was generated by %s %s from\n"
" * %.*s (%ux%u, %u colors%s)\n"
" */\n"
"\n",
ProgName,
GetVersionAsString (),
SB_GetLen (S), SB_GetConstBuf (S),
GetBitmapWidth (B), GetBitmapHeight (B),
GetBitmapColors (B),
BitmapIsIndexed (B)? ", indexed" : "");
/* If an identifier was given, output #defines for width, height, the
* number of colors and declare a variable for the data.
*/
if (Ident) {
fprintf (F,
"#define %s_COLORS %u\n"
"#define %s_WIDTH %u\n"
"#define %s_HEIGHT %u\n"
"const unsigned char %s[] = {\n",
Ident, GetBitmapColors (B),
Ident, GetBitmapWidth (B),
Ident, GetBitmapHeight (B),
Ident);
}
/* Write the data */
D = SB_GetConstBuf (Data);
Size = SB_GetLen (Data);
while (Size) {
unsigned I;
/* Output one line */
unsigned Chunk = Size;
if (Chunk > BytesPerLine) {
Chunk = BytesPerLine;
}
fputs (" ", F);
for (I = 0; I < Chunk; ++I) {
switch (Base) {
case 10:
fprintf (F, "%u,", *D++ & 0xFF);
break;
case 16:
fprintf (F, "0x%02X,", *D++ & 0xFF);
break;
}
}
fputc ('\n', F);
/* Bump the counters */
Size -= Chunk;
}
/* Terminate the array if we had an identifier */
if (Ident) {
fputs ("};\n", F);
}
/* Close the file */
if (fclose (F) != 0) {
Error ("Error closing output file `%s': %s", Name, strerror (errno));
}
}
示例15: switch
void Parser::optimise_call(ExprNode *node)
{
DBL result = 0.0;
bool have_result = true;;
if(node->op != OP_CALL)
return;
if(node->child == NULL)
return;
if(node->child->op != OP_CONSTANT)
return;
switch(node->call.token)
{
case SIN_TOKEN:
result = sin(node->child->number);
break;
case COS_TOKEN:
result = cos(node->child->number);
break;
case TAN_TOKEN:
result = tan(node->child->number);
break;
case ASIN_TOKEN:
result = asin(node->child->number);
break;
case ACOS_TOKEN:
result = acos(node->child->number);
break;
case ATAN_TOKEN:
result = atan(node->child->number);
break;
case SINH_TOKEN:
result = sinh(node->child->number);
break;
case COSH_TOKEN:
result = cosh(node->child->number);
break;
case TANH_TOKEN:
result = tanh(node->child->number);
break;
case ASINH_TOKEN:
result = asinh(node->child->number);
break;
case ACOSH_TOKEN:
result = acosh(node->child->number);
break;
case ATANH_TOKEN:
result = atanh(node->child->number);
break;
case ABS_TOKEN:
result = fabs(node->child->number);
break;
case RADIANS_TOKEN:
result = node->child->number * M_PI / 180.0;
break;
case DEGREES_TOKEN:
result = node->child->number * 180.0 / M_PI;
break;
case FLOOR_TOKEN:
result = floor(node->child->number);
break;
case INT_TOKEN:
result = (int)(node->child->number);
break;
case CEIL_TOKEN:
result = ceil(node->child->number);
break;
case SQRT_TOKEN:
result = sqrt(node->child->number);
break;
case EXP_TOKEN:
result = exp(node->child->number);
break;
case LN_TOKEN:
if(node->child->number > 0.0)
result = log(node->child->number);
else
Error("Domain error in 'ln'.");
break;
case LOG_TOKEN:
if(node->child->number > 0.0)
result = log10(node->child->number);
else
Error("Domain error in 'log'.");
break;
case MIN_TOKEN:
have_result = false;
break;
case MAX_TOKEN:
have_result = false;
break;
case ATAN2_TOKEN:
have_result = false;
break;
case POW_TOKEN:
have_result = false;
break;
case MOD_TOKEN:
have_result = false;
//.........這裏部分代碼省略.........