Changeset 687


Ignore:
Timestamp:
Jul 30, 2013, 5:48:38 PM (10 years ago)
Author:
Sam Hocevar
Message:

core: get rid of custom Min(), Max(), ERROR(), etc. and use the Lol Engine
features instead.

Location:
abuse/branches/lol/src
Files:
40 edited

Legend:

Unmodified
Added
Removed
  • abuse/branches/lol/src/Makefile.am

    r686 r687  
    6262    $(NULL)
    6363
    64 EXTRALIBS = lisp/liblisp.a sdlport/libsdlport.a imlib/libimlib.a net/libnet.a
    65 abuse_LDADD = $(EXTRALIBS) $(LOL_LIBS)
    66 abuse_DEPENDENCIES = $(EXTRALIBS)
     64abuse_CPPFLAGS = $(AM_CPPFLAGS) -DHAVE_OPENGL \
     65    -I$(srcdir) -I$(srcdir)/lisp -I$(srcdir)/imlib -I$(srcdir)/net
     66abuse_LDFLAGS = lisp/liblisp.a sdlport/libsdlport.a imlib/libimlib.a net/libnet.a $(AM_LDFLAGS)
     67abuse_LDADD = @LOL_LIBS@
     68abuse_DEPENDENCIES = @LOL_DEPS@
    6769
    6870abuse_tool_SOURCES = \
    6971    tool/abuse-tool.cpp \
    7072    crc.cpp crc.h
    71 abuse_tool_LDADD = imlib/libimlib.a
    72 abuse_tool_DEPENDENCIES = $(abuse_tool_LDADD)
     73abuse_tool_CPPFLAGS = $(AM_CPPFLAGS) -DHAVE_OPENGL \
     74    -I$(srcdir) -I$(srcdir)/lisp -I$(srcdir)/imlib -I$(srcdir)/net
     75abuse_tool_LDFLAGS = imlib/libimlib.a $(AM_LDFLAGS)
     76abuse_tool_LDADD = @LOL_LIBS@
     77abuse_tool_DEPENDENCIES = @LOL_DEPS@
    7378
    74 INCLUDES = -I$(srcdir) -I$(srcdir)/lisp -I$(srcdir)/imlib \
    75            -I$(srcdir)/net $(SDL_CFLAGS)
    76 
    77 CPPFLAGS = @CPPFLAGS@ -DNO_CHECK
    78 
  • abuse/branches/lol/src/cache.cpp

    r635 r687  
    165165char *CrcManager::get_filename(int filenumber)
    166166{
    167   CHECK(filenumber>=0 && filenumber<total_files);
     167  ASSERT(filenumber >= 0);
     168  ASSERT(filenumber < total_files);
    168169  return files[filenumber]->filename;
    169170}
     
    171172uint32_t CrcManager::get_crc(int filenumber, int &failed)
    172173{
    173   CHECK(filenumber>=0 && filenumber<total_files);
     174  ASSERT(filenumber >= 0);
     175  ASSERT(filenumber < total_files);
    174176  if (files[filenumber]->crc_calculated)
    175177  {
    176     failed=0;
     178    failed = 0;
    177179    return files[filenumber]->crc;
    178180  }
    179   failed=1;
     181  failed = 1;
    180182  return 0;
    181183}
     
    183185void CrcManager::set_crc(int filenumber, uint32_t crc)
    184186{
    185   CHECK(filenumber>=0 && filenumber<total_files);
    186   files[filenumber]->crc_calculated=1;
     187  ASSERT(filenumber >= 0);
     188  ASSERT(filenumber < total_files);
     189  files[filenumber]->crc_calculated = 1;
    187190  files[filenumber]->crc=crc;
    188191}
     
    882885    int id = AllocId();
    883886
    884     CHECK(id < total && list[id].file_number < 0);
     887    ASSERT(id < total);
     888    ASSERT(list[id].file_number < 0);
    885889
    886890    list[id].file_number = fn;
     
    911915backtile *CacheList::backt(int id)
    912916{
    913   CacheItem *me=list+id;
    914   CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id");
     917  CacheItem *me = list + id;
     918
     919  ASSERT(id < total && id >= 0 && me->file_number >= 0, "bad id");
    915920
    916921  if (me->last_access>=0)
     
    932937foretile *CacheList::foret(int id)
    933938{
    934   CacheItem *me=list+id;
    935   CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id");
     939  CacheItem *me = list + id;
     940
     941  ASSERT(id < total && id >= 0 && me->file_number >= 0, "bad id");
    936942
    937943  if (me->last_access>=0)
     
    952958figure *CacheList::fig(int id)
    953959{
    954   CacheItem *me=list+id;
    955 //  CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id");
     960  CacheItem *me = list + id;
     961
     962  //ASSERT(id < total && id >= 0 && me->file_number >= 0, "bad id");
     963
    956964  if (me->last_access>=0)
    957965  {
     
    971979image *CacheList::img(int id)
    972980{
    973   CacheItem *me=list+id;
    974   CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id");
     981  CacheItem *me = list + id;
     982
     983  ASSERT(id < total && id >= 0 && me->file_number >= 0, "bad id");
     984
    975985  if (me->last_access>=0)
    976986  {
     
    9921002sound_effect *CacheList::sfx(int id)
    9931003{
    994   CacheItem *me=list+id;
    995   CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id");
     1004  CacheItem *me = list + id;
     1005
     1006  ASSERT(id < total && id >= 0 && me->file_number >= 0, "bad id");
     1007
    9961008  if (me->last_access>=0)
    9971009  {
     
    10111023part_frame *CacheList::part(int id)
    10121024{
    1013   CacheItem *me=list+id;
    1014   CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id");
     1025  CacheItem *me = list + id;
     1026
     1027  ASSERT(id < total && id >= 0 && me->file_number >= 0, "bad id");
     1028
    10151029  if (me->last_access>=0)
    10161030  {
     
    10311045LObject *CacheList::lblock(int id)
    10321046{
    1033   CacheItem *me=list+id;
    1034   CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id");
     1047  CacheItem *me = list + id;
     1048
     1049  ASSERT(id < total && id >= 0 && me->file_number >= 0, "bad id");
     1050
    10351051  return (LObject *)me->data;
    10361052}
     
    10971113int CacheList::loaded(int id)
    10981114{
    1099   CacheItem *me=list+id;
    1100   CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id");
     1115  CacheItem *me = list + id;
     1116
     1117  ASSERT(id < total && id >= 0 && me->file_number >= 0, "bad id");
     1118
    11011119  if (me->last_access>=0)
    11021120    return 1;
     
    11061124char_tint *CacheList::ctint(int id)
    11071125{
    1108   CacheItem *me=list+id;
    1109   CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id" && me->type==SPEC_PALETTE);
     1126  CacheItem *me = list + id;
     1127
     1128  ASSERT(id < total && id >= 0 && me->file_number >= 0, "bad id");
     1129  ASSERT(me->type == SPEC_PALETTE);
     1130
    11101131  if (me->last_access>=0)
    11111132  {
  • abuse/branches/lol/src/chars.cpp

    r643 r687  
    108108    else
    109109    {
    110         num = Max(ts, MAX_STATE);
     110        num = lol::max(ts, MAX_STATE);
    111111        LSpace *sp = LSpace::Current;
    112112        LSpace::Current = &LSpace::Perm;
  • abuse/branches/lol/src/collide.cpp

    r555 r687  
    117117      if (x1<p->x1)
    118118      {
    119         add_collide(first,x1,Max(y1,p->y1),p->x1-1,Min(y2,p->y2),who);
     119        add_collide(first,x1,lol::max(y1,p->y1),p->x1-1,lol::min(y2,p->y2),who);
    120120    ax1=p->x1;
    121121      } else
     
    124124      if (x2>p->x2)
    125125      {
    126         add_collide(first,p->x2+1,Max(y1,p->y1),x2,Min(y2,p->y2),who);
     126        add_collide(first,p->x2+1,lol::max(y1,p->y1),x2,lol::min(y2,p->y2),who);
    127127    ax2=p->x2;
    128128      }
  • abuse/branches/lol/src/common.h

    r686 r687  
    2525
    2626//
    27 // Custom utility functions
    28 //
    29 static inline int Min(int a, int b) { return a < b ? a : b; }
    30 static inline int Max(int a, int b) { return a > b ? a : b; }
    31 static inline unsigned int Min(unsigned int a, unsigned int b) { return a < b ? a : b; }
    32 static inline unsigned int Max(unsigned int a, unsigned int b) { return a > b ? a : b; }
    33 static inline long Min(long a, long b) { return a < b ? a : b; }
    34 static inline long Max(long a, long b) { return a > b ? a : b; }
    35 static inline unsigned long Min(unsigned long a, unsigned long b) { return a < b ? a : b; }
    36 static inline unsigned long Max(unsigned long a, unsigned long b) { return a > b ? a : b; }
    37 static inline float Min(float a, float b) { return a < b ? a : b; }
    38 static inline float Max(float a, float b) { return a > b ? a : b; }
    39 
    40 static inline ivec2 Min(ivec2 a, ivec2 b) { return ivec2(Min(a.x, b.x), Min(a.y, b.y)); }
    41 static inline ivec2 Max(ivec2 a, ivec2 b) { return ivec2(Max(a.x, b.x), Max(a.y, b.y)); }
    42 
    43 //
    4427// Byte swapping
    4528//
     
    6548}
    6649
    67 #define ERROR(x,st) { if (!(x)) \
    68    { printf("Error on line %d of %s : %s\n", \
    69      __LINE__,__FILE__,st); exit(1); } }
    70 
    71 // These macros should be removed for the non-debugging version
    72 #ifdef NO_CHECK
    73 #   define CONDITION(x,st)
    74 #   define CHECK(x)
    75 #else
    76 #   define CONDITION(x,st) ERROR(x,st)
    77 #   define CHECK(x) CONDITION(x,"Check stop");
    78 #endif
    79 
    8050#endif // __COMMON_H__
    8151
  • abuse/branches/lol/src/control.cpp

    r555 r687  
    3838    case CHAR_HUMAN : my_figure=human_figure; curbreak;
    3939    case CHAR_IGUANA : my_figure=iguana_figure; break;
    40     default : CONDITION(0,"change_character, bad character type\n");
     40    default : ASSERT(0, "change_character, bad character type");
    4141  }
    4242  cur_char=char_type;
  • abuse/branches/lol/src/game.cpp

    r686 r687  
    321321        tmp = ivec2(0, 0);
    322322
    323     tmp.x = Max(tmp.x, 0);
    324     tmp.y = Max(tmp.y, 0);
     323    tmp.x = lol::max(tmp.x, 0);
     324    tmp.y = lol::max(tmp.y, 0);
    325325
    326326    ivec2 ret(pos.x * AUTOTILE_WIDTH / ftile_width()
     
    802802      x2 = x1 + (v->m_bb.x - v->m_aa.x + fw) / fw;
    803803      y2 = y1 + (v->m_bb.y - v->m_aa.y + fh) / fh;
    804       x2 = Min(x2, current_level->foreground_width() - 1);
    805       y2 = Min(y2, current_level->foreground_height() - 1);
     804      x2 = lol::min(x2, current_level->foreground_width() - 1);
     805      y2 = lol::min(y2, current_level->foreground_height() - 1);
    806806
    807807    xinc = fw;
     
    977977      if(help_text_frames >= 0)
    978978      {
    979     int color = 2 + Max(0, help_text_frames - 10);
     979    int color = 2 + lol::max(0, help_text_frames - 10);
    980980
    981981    ivec2 aa = v->m_aa;
     
    15101510
    15111511    // Find average fps for last 10 frames
    1512     float deltatime = Max(0.001f, frame_timer.Poll());
     1512    float deltatime = lol::max(0.001f, frame_timer.Poll());
    15131513
    15141514    avg_time = 0.9f * avg_time + 0.1f * deltatime;
     
    15161516
    15171517    if (avg_time < 1.0f / 14)
    1518         massive_frame_panic = Max(0, Min(20, massive_frame_panic - 1));
     1518        massive_frame_panic = lol::max(0, lol::min(20, massive_frame_panic - 1));
    15191519
    15201520    int ret = 0;
     
    17751775                                    {
    17761776                                        if(ev.message.id == RAISE_SFX && sfx_volume != 127)
    1777                                             sfx_volume = Min(127, sfx_volume + 16);
     1777                                            sfx_volume = lol::min(127, sfx_volume + 16);
    17781778                                        if(ev.message.id == LOWER_SFX && sfx_volume != 0)
    1779                                             sfx_volume = Max(sfx_volume - 16, 0);
     1779                                            sfx_volume = lol::max(sfx_volume - 16, 0);
    17801780                                        if(ev.message.id == RAISE_MUSIC && music_volume != 126)
    17811781                                        {
    1782                                             music_volume = Min(music_volume + 16, 127);
     1782                                            music_volume = lol::min(music_volume + 16, 127);
    17831783                                            if(current_song && (sound_avail & MUSIC_INITIALIZED))
    17841784                                                current_song->set_volume(music_volume);
     
    17871787                                        if(ev.message.id == LOWER_MUSIC && music_volume != 0)
    17881788                                        {
    1789                                             music_volume = Max(music_volume - 16, 0);
     1789                                            music_volume = lol::max(music_volume - 16, 0);
    17901790                                            if(current_song && (sound_avail & MUSIC_INITIALIZED))
    17911791                                                current_song->set_volume(music_volume);
  • abuse/branches/lol/src/go.cpp

    r686 r687  
    218218    break;
    219219      default :
    220     CHECK(0);
     220    ASSERT(false);
    221221    }
    222222  }
  • abuse/branches/lol/src/imlib/dprint.cpp

    r555 r687  
    5555    else
    5656    {
    57         ERROR(0,"dgets called but no handler set up");
     57        ASSERT(0, "dgets called but no handler set up");
    5858    }
    5959}
  • abuse/branches/lol/src/imlib/event.cpp

    r686 r687  
    3434EventHandler::EventHandler(image *screen, palette *pal)
    3535{
    36     CHECK(screen && pal);
     36    ASSERT(screen);
     37    ASSERT(pal);
     38
    3739    m_pending = 0;
    38 
    3940    m_screen = screen;
    4041
  • abuse/branches/lol/src/imlib/event.h

    r686 r687  
    8585    void SetMousePos(ivec2 pos)
    8686    {
    87         m_pos = ivec2(Min(Max(pos.x, 0), m_screen->Size().x - 1),
    88                       Min(Max(pos.y, 0), m_screen->Size().y - 1));
     87        m_pos = ivec2(lol::min(lol::max(pos.x, 0), m_screen->Size().x - 1),
     88                      lol::min(lol::max(pos.y, 0), m_screen->Size().y - 1));
    8989        SysWarpMouse(m_pos);
    9090    }
  • abuse/branches/lol/src/imlib/filter.cpp

    r686 r687  
    2020Filter::Filter(int colors)
    2121{
    22     CONDITION(colors >= 0 && colors <= 256, "bad colors value");
     22    ASSERT(colors >= 0 && colors <= 256, "bad colors value");
     23
    2324    m_size = colors;
    2425    m_table = (uint8_t *)malloc(m_size);
     
    2930Filter::Filter(palette *from, palette *to)
    3031{
    31     m_size = Max(from->pal_size(), to->pal_size());
     32    m_size = lol::max(from->pal_size(), to->pal_size());
    3233    m_table = (uint8_t *)malloc(m_size);
    3334
     
    5960void Filter::Set(int color_num, int change_to)
    6061{
    61     CONDITION(color_num >= 0 && color_num < m_size, "Bad colors_num");
     62    ASSERT(color_num >= 0 && color_num < m_size, "Bad colors_num");
     63
    6264    m_table[color_num] = change_to;
    6365}
     
    7072    while (npixels--)
    7173    {
    72         CONDITION(*dst < m_size, "not enough filter colors");
     74        ASSERT(*dst < m_size, "not enough filter colors");
    7375        *dst = m_table[*dst];
    7476        dst++;
     
    8890        return;
    8991
    90     aa += Max(caa - pos, ivec2(0));
    91     pos = Max(pos, caa);
    92     bb = Min(bb, cbb - pos + aa);
     92    aa += lol::max(caa - pos, ivec2(0));
     93    pos = lol::max(pos, caa);
     94    bb = lol::min(bb, cbb - pos + aa);
    9395
    9496    if (!(aa < bb))
  • abuse/branches/lol/src/imlib/guistat.cpp

    r682 r687  
    142142void gui_status_manager::pop()
    143143{
    144   CONDITION(first,"No status's to pop!");
    145   gui_status_node *p=first;
    146   first=first->next;
    147   delete p;
     144    ASSERT(first, "no status to pop!");
     145
     146    gui_status_node *p = first;
     147    first = first->next;
     148    delete p;
    148149}
    149150
  • abuse/branches/lol/src/imlib/image.cpp

    r686 r687  
    6666uint8_t image::Pixel(ivec2 pos)
    6767{
    68     CONDITION(pos.x >= 0 && pos.x < m_size.x && pos.y >= 0 && pos.y < m_size.y,
    69               "image::Pixel Bad pixel xy");
     68    ASSERT(pos.x >= 0 && pos.x < m_size.x && pos.y >= 0 && pos.y < m_size.y,
     69           "image::Pixel Bad pixel xy");
    7070    return scan_line(pos.y)[pos.x];
    7171}
     
    7373void image::PutPixel(ivec2 pos, uint8_t color)
    7474{
    75     CONDITION(pos.x >= 0 && pos.x < m_size.x && pos.y >= 0 && pos.y < m_size.y,
    76               "image::PutPixel Bad pixel xy");
     75    ASSERT(pos.x >= 0 && pos.x < m_size.x && pos.y >= 0 && pos.y < m_size.y,
     76           "image::PutPixel Bad pixel xy");
    7777
    7878    if (m_special &&
     
    216216
    217217    // We can now assume p1.y <= p2.y
    218     AddDirty(ivec2(Min(p1.x, p2.x), p1.y),
    219              ivec2(Max(p1.x, p2.x), p2.y) + ivec2(1));
     218    AddDirty(ivec2(lol::min(p1.x, p2.x), p1.y),
     219             ivec2(lol::max(p1.x, p2.x), p2.y) + ivec2(1));
    220220
    221221    ivec2 span = p2 - p1;
     
    229229    int dx = (n > m) ? yi * m_size.x : xi;
    230230    int dy = (n > m) ? xi : yi * m_size.x;
    231     int erx = 2 * Max(span.x * xi, span.y * yi);
    232     int ery = 2 * Min(span.x * xi, span.y * yi);
     231    int erx = 2 * lol::max(span.x * xi, span.y * yi);
     232    int ery = 2 * lol::min(span.x * xi, span.y * yi);
    233233
    234234    Lock();
    235     for (int i = 0, er = 0; i <= Max(n, m); i++)
     235    for (int i = 0, er = 0; i <= lol::max(n, m); i++)
    236236    {
    237237        *start = color;
     
    255255void image::PutPart(image *im, ivec2 pos, ivec2 aa, ivec2 bb, int transparent)
    256256{
    257     CHECK(aa < bb);
     257    ASSERT(aa < bb);
    258258
    259259    ivec2 caa, cbb;
     
    262262    // see if the are to be put is outside of actual image, if so adjust
    263263    // to fit in the image
    264     pos += Min(aa, ivec2(0));
    265     aa += Min(aa, ivec2(0));
    266     bb = Min(bb, im->m_size);
     264    pos += lol::min(aa, ivec2(0));
     265    aa += lol::min(aa, ivec2(0));
     266    bb = lol::min(bb, im->m_size);
    267267    // return if it was adjusted so that nothing will be put
    268268    if (!(aa < bb))
     
    273273        return;
    274274
    275     aa += Max(caa - pos, ivec2(0));
    276     pos += Max(caa - pos, ivec2(0));
    277     bb = Min(bb, cbb - pos + aa);
     275    aa += lol::max(caa - pos, ivec2(0));
     276    pos += lol::max(caa - pos, ivec2(0));
     277    bb = lol::min(bb, cbb - pos + aa);
    278278    if (!(aa < bb))
    279279        return;
     
    339339    if (m_special)
    340340    {
    341         aa = Min(aa, ivec2(m_special->x1_clip(), m_special->y1_clip()));
    342         bb = Max(bb, ivec2(m_special->x2_clip(), m_special->y2_clip()));
     341        aa = lol::min(aa, ivec2(m_special->x1_clip(), m_special->y1_clip()));
     342        bb = lol::max(bb, ivec2(m_special->x2_clip(), m_special->y2_clip()));
    343343    }
    344344
     
    372372    if (m_special)
    373373    {
    374         x1 = Min(x1, m_special->x1_clip());
    375         y1 = Min(y1, m_special->y1_clip());
    376         x2 = Max(x2, m_special->x2_clip());
    377         y2 = Max(y2, m_special->y2_clip());
     374        x1 = lol::min(x1, m_special->x1_clip());
     375        y1 = lol::min(y1, m_special->y1_clip());
     376        x2 = lol::max(x2, m_special->x2_clip());
     377        y2 = lol::max(y2, m_special->y2_clip());
    378378    }
    379379
     
    391391    for (dirty_rect *p = (dirty_rect *)dirties.first(); p; )
    392392    {
    393         aa = Min(aa, p->m_aa);
    394         bb = Max(bb, p->m_bb);
     393        aa = lol::min(aa, p->m_aa);
     394        bb = lol::max(bb, p->m_bb);
    395395        dirty_rect *tmp = (dirty_rect *)p->Next();
    396396        dirties.unlink(p);
     
    409409        return;
    410410
    411     aa = Max(aa, ivec2(0));
    412     bb = Min(bb, m_size);
     411    aa = lol::max(aa, ivec2(0));
     412    bb = lol::min(bb, m_size);
    413413
    414414    if (!(aa < bb))
     
    510510        return;
    511511
    512     aa = Max(aa, ivec2(0));
    513     bb = Min(bb, m_size);
     512    aa = lol::max(aa, ivec2(0));
     513    bb = lol::min(bb, m_size);
    514514
    515515    if (!(aa < bb))
     
    559559            {
    560560              if (aa.x < p->m_aa.x)
    561                 AddDirty(ivec2(aa.x, Max(aa.y, p->m_aa.y)),
    562                          ivec2(p->m_aa.x, Min(bb.y, p->m_bb.y + 1)));
     561                AddDirty(ivec2(aa.x, lol::max(aa.y, p->m_aa.y)),
     562                         ivec2(p->m_aa.x, lol::min(bb.y, p->m_bb.y + 1)));
    563563              if (bb.x > p->m_bb.x + 1)
    564                 AddDirty(ivec2(p->m_bb.x + 1, Max(aa.y, p->m_aa.y)),
    565                          ivec2(bb.x, Min(bb.y, p->m_bb.y + 1)));
     564                AddDirty(ivec2(p->m_bb.x + 1, lol::max(aa.y, p->m_aa.y)),
     565                         ivec2(bb.x, lol::min(bb.y, p->m_bb.y + 1)));
    566566              if (aa.y < p->m_aa.y)
    567567                AddDirty(aa, ivec2(bb.x, p->m_aa.y));
     
    574574
    575575      }
    576       CHECK(aa < bb);
     576      ASSERT(aa < bb);
    577577      dirties.add_end(new dirty_rect(aa, bb - ivec2(1)));
    578578    }
     
    592592    else
    593593    {
    594         p1.x = Max(p1.x, 0);
    595         p1.y = Max(p1.y, 0);
    596         p2.x = Min(p2.x, m_size.x - 1);
    597         p2.y = Min(p2.y, m_size.y - 1);
     594        p1.x = lol::max(p1.x, 0);
     595        p1.y = lol::max(p1.y, 0);
     596        p2.x = lol::min(p2.x, m_size.x - 1);
     597        p2.y = lol::min(p2.y, m_size.y - 1);
    598598    }
    599599    if (p2.x < 0 || p2.y < 0 || p1.x >= m_size.x || p1.y >= m_size.y
     
    728728void image::scroll(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t xd, int16_t yd)
    729729{
    730   CHECK(x1>=0 && y1>=0 && x1<x2 && y1<y2 && x2<m_size.x && y2<m_size.y);
     730  ASSERT(x1 >= 0);
     731  ASSERT(y1 >= 0);
     732  ASSERT(x1 < x2);
     733  ASSERT(y1 < y2);
     734  ASSERT(x2 < m_size.x);
     735  ASSERT(y2 < m_size.y);
     736
    731737  if (m_special)
    732738  {
    733739    ivec2 caa, cbb;
    734740    m_special->GetClip(caa, cbb);
    735     x1=Max(x1, caa.x); y1=Max(caa.y, y1); x2=Min(x2, cbb.x - 1); y2=Min(y2, cbb.y - 1);
     741    x1=lol::max(x1, caa.x);
     742    y1=lol::max(caa.y, y1);
     743    x2=lol::min(x2, cbb.x - 1);
     744    y2=lol::min(y2, cbb.y - 1);
    736745  }
    737746  int16_t xsrc, ysrc, xdst, ydst, xtot=x2-x1-lol::abs(xd)+1, ytot, xt;
     
    755764image *image::create_smooth(int16_t smoothness)
    756765{
     766  ASSERT(smoothness >= 0);
     767
    757768  int16_t i, j, k, l, t, d;
    758769  image *im;
    759   CHECK(smoothness>=0);
    760   if (!smoothness) return NULL;
     770  if (!smoothness)
     771    return NULL;
    761772  d=smoothness*2+1;
    762773  d=d*d;
     
    922933  if (y2>cbb.y - 1) y2=cbb.y - 1;
    923934  if (x2>cbb.x - 1) x2=cbb.x - 1;
    924   CHECK(x2>=x1 && y2>=y1);
     935
     936  ASSERT(x2 >= x1);
     937  ASSERT(y2 >= y1);
     938
    925939  if (x2<x1 || y2<y1) return NULL;
    926940  ret=new image(ivec2((x2-x1+8)/8, (y2-y1+1)));
  • abuse/branches/lol/src/imlib/image.h

    r682 r687  
    5050
    5151    image_descriptor(ivec2 size, int keep_dirties = 1, int static_memory = 0);
    52     int bound_x1(int x1) { return Max(x1, m_aa.x); }
    53     int bound_y1(int y1) { return Max(y1, m_aa.y); }
    54     int bound_x2(int x2) { return Min(x2, m_bb.x); }
    55     int bound_y2(int y2) { return Min(y2, m_bb.y); }
     52    int bound_x1(int x1) { return lol::max(x1, m_aa.x); }
     53    int bound_y1(int y1) { return lol::max(y1, m_aa.y); }
     54    int bound_x2(int x2) { return lol::min(x2, m_bb.x); }
     55    int bound_y2(int y2) { return lol::min(y2, m_bb.y); }
    5656    inline int x1_clip() { return m_aa.x; }
    5757    inline int y1_clip() { return m_aa.y; }
     
    6565    void SetClip(ivec2 aa, ivec2 bb)
    6666    {
    67         m_aa = Max(aa, ivec2(0));
    68         m_bb = Min(Max(bb, m_aa + ivec2(1)), m_size);
     67        m_aa = lol::max(aa, ivec2(0));
     68        m_bb = lol::min(lol::max(bb, m_aa + ivec2(1)), m_size);
    6969    }
    7070    void GetClip(int &x1, int &y1, int &x2, int &y2)
     
    7676        if(x2 < x1 + 1) x2 = x1 + 1;
    7777        if(y2 < y1 + 1) y2 = y1 + 1;
    78         m_aa.x = Max(x1, 0); m_aa.y = Max(y1, 0);
    79         m_bb.x = Min(x2, m_size.x); m_bb.y = Min(y2, m_size.y);
     78        m_aa.x = lol::max(x1, 0); m_aa.y = lol::max(y1, 0);
     79        m_bb.x = lol::min(x2, m_size.x); m_bb.y = lol::min(y2, m_size.y);
    8080    }
    8181    void ReduceDirties();
  • abuse/branches/lol/src/imlib/input.cpp

    r682 r687  
    192192void button::change_visual(image *new_visual)
    193193{
    194   CHECK(visual);
    195   visual=new_visual;
     194    ASSERT(visual);
     195    visual = new_visual;
    196196}
    197197
  • abuse/branches/lol/src/imlib/jwindow.cpp

    r686 r687  
    397397
    398398    if(size.x == -1)
    399         m_size.x = Max(m_size.x, 15 + left_border() + right_border());
     399        m_size.x = lol::max(m_size.x, 15 + left_border() + right_border());
    400400    if(size.y == -1)
    401         m_size.y = Max(m_size.y, top_border() + bottom_border());
     401        m_size.y = lol::max(m_size.y, top_border() + bottom_border());
    402402    m_surf = new image(m_size, NULL, 2);
    403403    m_surf->clear(backg);
     
    436436        i->set_owner(this);
    437437        i->area(x1, y1, x2, y2);
    438         m_size = Max(m_size, ivec2(x2, y2));
     438        m_size = lol::max(m_size, ivec2(x2, y2));
    439439    }
    440440}
  • abuse/branches/lol/src/imlib/palette.cpp

    r686 r687  
    121121void palette::set_rgbs()
    122122{
    123   int i,v;
    124   CHECK(ncolors==256);
     123  ASSERT(ncolors == 256);
     124
     125  int i, v;
    125126  for (i=0; i<64; i++)
    126127  {
     
    170171void palette::set_used(int color_num)
    171172{
    172   int x,b;
    173   CHECK(color_num>=0 && color_num<ncolors);
    174   x=color_num/8;
    175   b=color_num%8;
    176   usd[x]|=(128>>b);
     173    ASSERT(color_num >= 0);
     174    ASSERT(color_num < ncolors);
     175
     176    int x = color_num / 8;
     177    int b = color_num % 8;
     178    usd[x] |= 128 >> b;
    177179}
    178180
    179181void palette::set_unused(int color_num)
    180182{
    181   int x,b;
    182   CHECK(color_num>=0 && color_num<ncolors);
    183   x=color_num/8;
    184   b=color_num%8;
    185   usd[x]&=(0xff^(128>>b));
     183    ASSERT(color_num >= 0);
     184    ASSERT(color_num < ncolors);
     185
     186    int x = color_num / 8;
     187    int b = color_num % 8;
     188    usd[x] &= 0xff ^ (128 >> b);
    186189}
    187190
    188191int palette::used(int color_num)
    189192{
    190   int x,b;
    191   CHECK(color_num>=0 && color_num<ncolors);
    192   x=color_num/8;
    193   b=color_num%8;
    194   return (usd[x]&(128>>b));
     193    ASSERT(color_num >= 0);
     194    ASSERT(color_num < ncolors);
     195
     196    int x = color_num / 8;
     197    int b = color_num % 8;
     198    return usd[x] & (128 >> b);
    195199}
    196200
     
    235239
    236240void palette::set(int x, unsigned char red, char unsigned green, char unsigned blue)
    237 { CONDITION(x>=0 && x<ncolors,"Pallete::set passed bad x");
    238   CONDITION((int)red<=ncolors && (int)green<=ncolors && (int)blue<=ncolors,
    239         "pallette::set color values bigger than palette");
    240   pal[x].red=red; pal[x].green=green; pal[x].blue=blue;
     241{
     242    ASSERT(x >= 0 && x < ncolors, "palete::set passed bad x");
     243    ASSERT((int)red <= ncolors && (int)green <= ncolors && (int)blue <= ncolors,
     244           "palette::set color values bigger than palette");
     245
     246    pal[x].red = red;
     247    pal[x].green = green;
     248    pal[x].blue = blue;
    241249}
    242250
    243251void palette::get(int x, unsigned char &red, unsigned char &green, unsigned char &blue)
    244 { CONDITION(x>=0 && x<ncolors,"Pallete::get passed bad x");
    245   red=pal[x].red; green=pal[x].green; blue=pal[x].blue;
    246 }
     252{
     253    ASSERT(x >= 0 && x < ncolors, "palete::get passed bad x");
     254
     255    red = pal[x].red;
     256    green = pal[x].green;
     257    blue = pal[x].blue;
     258}
     259
    247260palette::~palette()
    248 { if (pal) free(pal);
    249   if (usd) free(usd);
     261{
     262    free(pal);
     263    free(usd);
    250264}
    251265
    252266palette::palette(int number_colors)
    253267{
    254   CONDITION(number_colors>0,"palette::constructor - need at least one color!");
    255   ncolors=number_colors;
    256   bg=0;
    257   pal=(color *)malloc(ncolors*3);
    258   usd=(unsigned char *)malloc(ncolors/8+1);
    259   defaults();
     268    ASSERT(number_colors > 0, "palette::constructor - need at least one color!");
     269
     270    ncolors = number_colors;
     271    bg = 0;
     272    pal = (color *)malloc(ncolors*3);
     273    usd = (unsigned char *)malloc(ncolors / 8 + 1);
     274    defaults();
    260275}
    261276
     
    277292{
    278293  int t,r,g,b;
    279   CONDITION(!is_leaf(),"Cannot prune a leaf!");
     294  ASSERT(!is_leaf(),"Cannot prune a leaf!");
    280295  total(t,r,g,b);
    281296  red=r/t;
     
    304319    unsigned char r, unsigned char g, unsigned char b)
    305320{
    306   int i;
    307   CONDITION(level<=8,"Tree cannot have more than eight levels");
    308   if (level==8)
    309     be_childish();
    310   else
    311     for (i=0; i<8; i++) children[i]=NULL;
    312   padre=dad;
    313   red=r; green=g; blue=b;
    314   tot=0;
     321    int i;
     322    ASSERT(level <= 8, "Tree cannot have more than eight levels");
     323
     324    if (level == 8)
     325        be_childish();
     326    else
     327        for (i=0; i<8; i++) children[i]=NULL;
     328    padre = dad;
     329    red = r; green = g; blue = b;
     330    tot = 0;
    315331}
    316332
     
    326342    if (who->children[x])
    327343    {
    328       CONDITION(lev<8,"Levl > 7");
     344      ASSERT(lev < 8, "Levl > 7");
    329345      re_delete(who->children[x],lev+1);
    330346      level[lev].unlink(who->children[x]);
     
    354370    }
    355371  }
    356   CONDITION(lev>0,"could not prune!");
     372  ASSERT(lev > 0, "could not prune!");
    357373  t=0; r=0; g=0; b=0;
    358374  f->total(t,r,g,b);
     
    362378    f->total(t,r,g,b);
    363379  }
    364   CONDITION(t>1,"Should be more colors\n");
     380  ASSERT(t > 1, "Should be more colors");
    365381  printf("%d Pruned at level %d, r=%d, g=%d, b=%d, total nodes off = %d\n",nc,
    366382    lev,r/t,g/t,b/t,t);
  • abuse/branches/lol/src/imlib/pmenu.cpp

    r682 r687  
    7878  next=Next;
    7979  on_off=NULL;
    80   CONDITION(Name,"Sub menu cannot have a NULL name");
     80  ASSERT(Name, "Sub menu cannot have a NULL name");
    8181  n = strdup(Name);
    8282  sub=Sub;
  • abuse/branches/lol/src/imlib/sprite.cpp

    r686 r687  
    2525ASprite::ASprite(image *screen, image *visual, ivec2 pos)
    2626{
    27     CHECK(visual && screen);
     27    ASSERT(visual);
     28    ASSERT(screen);
     29
    2830    m_pos = pos;
    2931    m_visual = visual;
  • abuse/branches/lol/src/imlib/status.cpp

    r555 r687  
    7575void text_status_manager::pop()
    7676{
    77   CONDITION(first,"No status's to pop!");
     77  ASSERT(first, "no status to pop!");
    7878  if (level==1) dprintf("\n");
    7979  level--;
  • abuse/branches/lol/src/imlib/transimage.cpp

    r686 r687  
    5656    {
    5757        printf("size = %d %d (%ld bytes)\n", m_size.x, m_size.y, (long)bytes);
    58         CONDITION(parser, "malloc error for TransImage::m_data");
     58        ASSERT(parser, "malloc error for TransImage::m_data");
    5959    }
    6060
     
    122122
    123123    // Number of lines to skip, number of lines to draw, first line to draw
    124     int skiplines = Max(pos1.y - pos.y, 0);
    125     ysteps = Min(pos2.y - pos.y, m_size.y - skiplines);
     124    int skiplines = lol::max(pos1.y - pos.y, 0);
     125    ysteps = lol::min(pos2.y - pos.y, m_size.y - skiplines);
    126126    pos.y += skiplines;
    127127
     
    140140    }
    141141
    142     screen->AddDirty(ivec2(Max(pos.x, pos1.x), pos.y),
    143                      ivec2(Min(pos.x + m_size.x, pos2.x), pos.y + m_size.y));
     142    screen->AddDirty(ivec2(lol::max(pos.x, pos1.x), pos.y),
     143                     ivec2(lol::min(pos.x + m_size.x, pos2.x), pos.y + m_size.y));
    144144    return parser;
    145145}
     
    158158    if (N == SCANLINE)
    159159    {
    160         pos1.y = Max(pos1.y, pos.y + amount);
    161         pos2.y = Min(pos2.y, pos.y + amount + 1);
     160        pos1.y = lol::max(pos1.y, pos.y + amount);
     161        pos2.y = lol::min(pos2.y, pos.y + amount + 1);
    162162        if (pos1.y >= pos2.y)
    163163            return;
     
    169169        return; // if ClipToLine says nothing to draw, return
    170170
    171     CONDITION(N != BLEND || (pos.y >= bpos.y
     171    ASSERT(N != BLEND || (pos.y >= bpos.y
    172172                              && pos.y + ysteps <= bpos.y + blend->Size().y),
    173               "Blend doesn't fit on TransImage");
     173           "blend doesn't fit on TransImage");
    174174
    175175    if (N == FADE || N == FADE_TINT || N == BLEND)
     
    182182
    183183    if (N == PREDATOR)
    184         ysteps = Min(ysteps, pos2.y - 1 - pos.y - 2);
     184        ysteps = lol::min(ysteps, pos2.y - 1 - pos.y - 2);
    185185
    186186    screen->Lock();
     
    211211
    212212            // Chop left side if necessary, but no more than todo
    213             int tochop = Min(todo, Max(pos1.x - ix, 0));
     213            int tochop = lol::min(todo, lol::max(pos1.x - ix, 0));
    214214
    215215            ix += tochop;
     
    219219
    220220            // Chop right side if necessary and process the remaining pixels
    221             int count = Min(todo, Max(pos2.x - ix, 0));
     221            int count = lol::min(todo, lol::max(pos2.x - ix, 0));
    222222
    223223            if (N == NORMAL || N == SCANLINE)
  • abuse/branches/lol/src/imlib/video.cpp

    r670 r687  
    2323{
    2424    // make sure the image has the ability to contain dirty areas
    25     CHECK(im->m_special);
     25    ASSERT(im->m_special);
    2626
    2727    if (im->m_special->keep_dirt == 0)
  • abuse/branches/lol/src/intsect.cpp

    r686 r687  
    126126          {
    127127            int32_t ae_bd=my1*mx2-mx1*my2;
    128             CONDITION(ae_bd,"line intersect fuck up");
     128            ASSERT(ae_bd,"line intersect fuck up");
    129129            tx2=(mx1*mx2*(b2-b1))/ae_bd+xadd;
    130130            ty2=my1*tx2/mx1+b1;
     
    133133          {
    134134            int32_t db_ea=(my2*mx1-mx2*my1);
    135             CONDITION(db_ea,"line intersect fuck up");
     135            ASSERT(db_ea,"line intersect fuck up");
    136136            ty2=(mx1*b1*my2-my1*mx2*b2)/db_ea+yadd;
    137137            tx2=mx1*(ty2-b1)/my1;
  • abuse/branches/lol/src/items.cpp

    r682 r687  
    6767    }
    6868
    69     maxx=Max(x1,x2);
    70     maxy=Max(y1,y2);
    71     minx=Min(x1,x2);
    72     miny=Min(y1,y2);
     69    maxx=lol::max(x1,x2);
     70    maxy=lol::max(y1,y2);
     71    minx=lol::min(x1,x2);
     72    miny=lol::min(y1,y2);
    7373
    7474    if (skip_next)
     
    152152
    153153
    154     maxx=Max(x1,x2);
    155     maxy=Max(y1,y2);
    156     minx=Min(x1,x2);
    157     miny=Min(y1,y2);
     154    maxx=lol::max(x1,x2);
     155    maxy=lol::max(y1,y2);
     156    minx=lol::min(x1,x2);
     157    miny=lol::min(y1,y2);
    158158
    159159    if (skip_next)
  • abuse/branches/lol/src/level.cpp

    r686 r687  
    6363    }
    6464  }
    65   CONDITION(c,"no attacker found");
     65  ASSERT(c, "no attacker found");
    6666  return c;
    6767}
     
    298298{
    299299  int startable;
    300   CONDITION(nplayers>0,"make_view_list with <=0 players!\n");
     300  ASSERT(nplayers > 0, "make_view_list with <=0 players!");
    301301  view *f=NULL;
    302302  int j,use_type=current_start_type;
     
    20192019      {
    20202020    int32_t x1=fp->read_uint32();
    2021     CONDITION(x1>=0,"expected x1 for object link to be > 0\n");
     2021    ASSERT(x1 >= 0, "expected x1 for object link to be > 0");
    20222022    int32_t x2=fp->read_uint32();
    20232023    game_object *p,*q=number_to_object_in_list(x1,save_list);
     
    26282628  if (blockx2>=foreground_width()) { x2=tl*foreground_width()-1; }
    26292629  if (blocky2>=foreground_height()) { y2=th*foreground_height()-1; }
    2630   blockx1=Max(blockx1,0);
    2631   blocky1=Max(blocky1,0);
     2630  blockx1=lol::max(blockx1,0);
     2631  blocky1=lol::max(blocky1,0);
    26322632
    26332633  if ((blockx1>blockx2) || (blocky1>blocky2)) return ;
  • abuse/branches/lol/src/level.h

    r682 r687  
    104104  ~level();
    105105
    106   int fg_raised(int x, int y) { CHECK(x>=0 && y>=0 && x<fg_width && y<fg_height);
     106  int fg_raised(int x, int y) { ASSERT(x>=0 && y>=0 && x<fg_width && y<fg_height);
    107107                 return (*(map_fg+x+y*fg_width))&0x4000; }
    108   void fg_set_raised(int x, int y, int r) { CHECK(x>=0 && y>=0 && x<fg_width && y<fg_height);
     108  void fg_set_raised(int x, int y, int r) { ASSERT(x>=0 && y>=0 && x<fg_width && y<fg_height);
    109109                        uint16_t v=(*(map_fg+x+y*fg_width))&(0xffff-0x4000);
    110110                        if (r) (*(map_fg+x+y*fg_width))=v|0x4000;
    111111                        else (*(map_fg+x+y*fg_width))=v;
    112112                      }
    113   void mark_seen(int x, int y) { CHECK(x>=0 && y>=0 && x<fg_width && y<fg_height);
     113  void mark_seen(int x, int y) { ASSERT(x>=0 && y>=0 && x<fg_width && y<fg_height);
    114114                      (*(map_fg+x+y*fg_width))|=0x8000; }
    115115  void clear_fg(int32_t x, int32_t y) { *(map_fg+x+y*fg_width)&=0x7fff; }
    116116
    117   uint16_t *get_fgline(int y) { CHECK(y>=0 && y<fg_height); return map_fg+y*fg_width; }
    118   uint16_t *get_bgline(int y) { CHECK(y>=0 && y<bg_height); return map_bg+y*bg_width; }
     117  uint16_t *get_fgline(int y) { ASSERT(y>=0 && y<fg_height); return map_fg+y*fg_width; }
     118  uint16_t *get_bgline(int y) { ASSERT(y>=0 && y<bg_height); return map_bg+y*bg_width; }
    119119  uint16_t GetFg(ivec2 pos) { if (pos >= ivec2(0) && pos < ivec2(fg_width, fg_height))
    120120                              return fgvalue(*(map_fg+pos.x+pos.y*fg_width));
  • abuse/branches/lol/src/light.cpp

    r686 r687  
    493493      if (x1<p->x1)
    494494      {
    495         add_light(first,x1,Max(y1,p->y1),p->x1-1,Min(y2,p->y2),who);
     495        add_light(first,x1,lol::max(y1,p->y1),p->x1-1,lol::min(y2,p->y2),who);
    496496    ax1=p->x1;
    497497      } else
     
    500500      if (x2>p->x2)
    501501      {
    502         add_light(first,p->x2+1,Max(y1,p->y1),x2,Min(y2,p->y2),who);
     502        add_light(first,p->x2+1,lol::max(y1,p->y1),x2,lol::min(y2,p->y2),who);
    503503    ax2=p->x2;
    504504      }
  • abuse/branches/lol/src/lisp/lisp.cpp

    r686 r687  
    279279LFixedPoint *LFixedPoint::Create(int32_t x)
    280280{
    281     size_t size = Max(sizeof(LFixedPoint), sizeof(LRedirect));
     281    size_t size = lol::max(sizeof(LFixedPoint), sizeof(LRedirect));
    282282
    283283    LFixedPoint *p = (LFixedPoint *)LSpace::Current->Alloc(size);
     
    289289LObjectVar *LObjectVar::Create(int index)
    290290{
    291     size_t size = Max(sizeof(LObjectVar), sizeof(LRedirect));
     291    size_t size = lol::max(sizeof(LObjectVar), sizeof(LRedirect));
    292292
    293293    LObjectVar *p = (LObjectVar *)LSpace::Current->Alloc(size);
     
    301301    if (addr == NULL)
    302302        return NULL;
    303     size_t size = Max(sizeof(LPointer), sizeof(LRedirect));
     303    size_t size = lol::max(sizeof(LPointer), sizeof(LRedirect));
    304304
    305305    LPointer *p = (LPointer *)LSpace::Current->Alloc(size);
     
    311311LChar *LChar::Create(uint16_t ch)
    312312{
    313     size_t size = Max(sizeof(LChar), sizeof(LRedirect));
     313    size_t size = lol::max(sizeof(LChar), sizeof(LRedirect));
    314314
    315315    LChar *c = (LChar *)LSpace::Current->Alloc(size);
     
    336336struct LString *LString::Create(int length)
    337337{
    338     size_t size = Max(sizeof(LString) + length - 1, sizeof(LRedirect));
     338    size_t size = lol::max(sizeof(LString) + length - 1, sizeof(LRedirect));
    339339
    340340    LString *s = (LString *)LSpace::Current->Alloc(size);
     
    348348    PtrRef r1(arg_list), r2(block_list);
    349349
    350     size_t size = Max(sizeof(LUserFunction), sizeof(LRedirect));
     350    size_t size = lol::max(sizeof(LUserFunction), sizeof(LRedirect));
    351351
    352352    LUserFunction *lu = (LUserFunction *)LSpace::Current->Alloc(size);
     
    359359LSysFunction *new_lisp_sys_function(int min_args, int max_args, int fun_number)
    360360{
    361     size_t size = Max(sizeof(LSysFunction), sizeof(LRedirect));
     361    size_t size = lol::max(sizeof(LSysFunction), sizeof(LRedirect));
    362362
    363363    // System functions should reside in permanant space
     
    395395LSymbol *new_lisp_symbol(char *name)
    396396{
    397     size_t size = Max(sizeof(LSymbol), sizeof(LRedirect));
     397    size_t size = lol::max(sizeof(LSymbol), sizeof(LRedirect));
    398398
    399399    LSymbol *s = (LSymbol *)LSpace::Current->Alloc(size);
     
    412412LNumber *LNumber::Create(long num)
    413413{
    414     size_t size = Max(sizeof(LNumber), sizeof(LRedirect));
     414    size_t size = lol::max(sizeof(LNumber), sizeof(LRedirect));
    415415
    416416    LNumber *n = (LNumber *)LSpace::Current->Alloc(size);
     
    422422LList *LList::Create()
    423423{
    424     size_t size = Max(sizeof(LList), sizeof(LRedirect));
     424    size_t size = lol::max(sizeof(LList), sizeof(LRedirect));
    425425
    426426    LList *c = (LList *)LSpace::Current->Alloc(size);
     
    10621062
    10631063
    1064 char n[MAX_LISP_TOKEN_LEN];  // assume all tokens will be < 200 characters
     1064static char token_buffer[MAX_LISP_TOKEN_LEN];  // assume all tokens will be < 200 characters
    10651065
    10661066int end_of_program(char const *s)
    10671067{
    1068   return !read_ltoken(s, n);
     1068  return !read_ltoken(s, token_buffer);
    10691069}
    10701070
     
    10851085    LObject *ret = NULL;
    10861086
    1087     if (!read_ltoken(code, n))
     1087    if (!read_ltoken(code, token_buffer))
    10881088        lerror(NULL, "unexpected end of program");
    10891089
    1090   if (!strcmp(n, "nil"))
     1090  if (!strcmp(token_buffer, "nil"))
    10911091    return NULL;
    1092   else if (toupper(n[0])=='T' && !n[1])
     1092  else if (toupper(token_buffer[0])=='T' && !token_buffer[1])
    10931093    return true_symbol;
    1094   else if (n[0]=='\'')                    // short hand for quote function
     1094  else if (token_buffer[0]=='\'')                    // short hand for quote function
    10951095  {
    10961096    LObject *cs = LList::Create(), *c2=NULL, *tmp;
     
    11051105    ret=cs;
    11061106  }
    1107   else if (n[0]=='`')                    // short hand for backquote function
     1107  else if (token_buffer[0]=='`')                    // short hand for backquote function
    11081108  {
    11091109    LObject *cs = LList::Create(), *c2=NULL, *tmp;
     
    11171117    ((LList *)cs)->m_cdr = (LObject *)c2;
    11181118    ret=cs;
    1119   }  else if (n[0]==',')              // short hand for comma function
     1119  }  else if (token_buffer[0]==',')              // short hand for comma function
    11201120  {
    11211121    LObject *cs = LList::Create(), *c2=NULL, *tmp;
     
    11301130    ret=cs;
    11311131  }
    1132   else if (n[0]=='(')                     // make a list of everything in ()
     1132  else if (token_buffer[0]=='(')                     // make a list of everything in ()
    11331133  {
    11341134    void *first=NULL, *cur=NULL, *last=NULL;
     
    11381138    {
    11391139      char const *tmp=code;
    1140       if (!read_ltoken(tmp, n))           // check for the end of the list
     1140      if (!read_ltoken(tmp, token_buffer))           // check for the end of the list
    11411141        lerror(NULL, "unexpected end of program");
    1142       if (n[0]==')')
     1142      if (token_buffer[0]==')')
    11431143      {
    11441144                done=1;
    1145                 read_ltoken(code, n);                // read off the ')'
     1145                read_ltoken(code, token_buffer);                // read off the ')'
    11461146      }
    11471147      else
    11481148      {
    1149                 if (n[0]=='.' && !n[1])
     1149                if (token_buffer[0]=='.' && !token_buffer[1])
    11501150                {
    11511151                  if (!first)
     
    11541154                  {
    11551155                    void *tmp;
    1156                     read_ltoken(code, n);              // skip the '.'
     1156                    read_ltoken(code, token_buffer);              // skip the '.'
    11571157                    tmp=Compile(code);
    11581158                    ((LList *)last)->m_cdr = (LObject *)tmp;          // link the last cdr to
     
    11771177    ret=(LObject *)comp_optimize(first);
    11781178
    1179   } else if (n[0]==')')
     1179  } else if (token_buffer[0]==')')
    11801180    lerror(code, "mismatched )");
    1181   else if (isdigit(n[0]) || (n[0]=='-' && isdigit(n[1])))
     1181  else if (isdigit(token_buffer[0]) || (token_buffer[0]=='-' && isdigit(token_buffer[1])))
    11821182  {
    11831183    LNumber *num = LNumber::Create(0);
    1184     sscanf(n, "%ld", &num->m_num);
     1184    sscanf(token_buffer, "%ld", &num->m_num);
    11851185    ret=num;
    1186   } else if (n[0]=='"')
     1186  } else if (token_buffer[0]=='"')
    11871187  {
    11881188    ret = LString::Create(str_token_len(code));
     
    12021202    *start=0;
    12031203    code++;
    1204   } else if (n[0]=='#')
    1205   {
    1206     if (n[1]=='\\')
    1207     {
    1208       read_ltoken(code, n);                   // read character name
    1209       if (!strcmp(n, "newline"))
     1204  } else if (token_buffer[0]=='#')
     1205  {
     1206    if (token_buffer[1]=='\\')
     1207    {
     1208      read_ltoken(code, token_buffer);                   // read character name
     1209      if (!strcmp(token_buffer, "newline"))
    12101210        ret = LChar::Create('\n');
    1211       else if (!strcmp(n, "space"))
     1211      else if (!strcmp(token_buffer, "space"))
    12121212        ret = LChar::Create(' ');
    12131213      else
    1214         ret = LChar::Create(n[0]);
    1215     }
    1216     else if (n[1]==0)                           // short hand for function
     1214        ret = LChar::Create(token_buffer[0]);
     1215    }
     1216    else if (token_buffer[1]==0)                           // short hand for function
    12171217    {
    12181218      LObject *cs = LList::Create(), *c2=NULL, *tmp;
     
    12281228    else
    12291229    {
    1230       lbreak("Unknown #\\ notation : %s\n", n);
     1230      lbreak("Unknown #\\ notation : %s\n", token_buffer);
    12311231      exit(0);
    12321232    }
    12331233  } else {
    1234     ret = LSymbol::FindOrCreate(n);
     1234    ret = LSymbol::FindOrCreate(token_buffer);
    12351235  }
    12361236  return ret;
     
    30543054    PtrRef ref1(this);
    30553055
    3056     maxevaldepth = Max(maxevaldepth, ++evaldepth);
     3056    maxevaldepth = lol::max(maxevaldepth, ++evaldepth);
    30573057
    30583058    int tstart = trace_level;
  • abuse/branches/lol/src/lisp/lisp_gc.cpp

    r637 r687  
    8787    LObject *ret = x;
    8888
    89     maxgcdepth = Max(maxgcdepth, ++gcdepth);
     89    maxgcdepth = lol::max(maxgcdepth, ++gcdepth);
    9090
    9191    if ((uint8_t *)x >= cstart && (uint8_t *)x < cend)
  • abuse/branches/lol/src/loader2.cpp

    r682 r687  
    452452
    453453
    454   ERROR(nbacktiles,"No background tiles defined!");
    455   ERROR(nforetiles,"No foreground tiles defined!");
    456   ERROR(foretiles[0]>=0,"No black (0) foreground tile defined!");
    457   ERROR(backtiles[0]>=0,"No black (0) background tile defined!");
    458   ERROR(big_font_pict!=-1 || small_font_pict!=-1,
    459     "No font loaded (use load_big_font or load_small_font)!");
    460   f_wid=cache.foret(foretiles[0])->im->Size().x;
    461   f_hi=cache.foret(foretiles[0])->im->Size().y;
    462   b_wid=cache.backt(backtiles[0])->im->Size().x;
    463   b_hi=cache.backt(backtiles[0])->im->Size().y;
     454  ASSERT(nbacktiles, "no background tiles defined!");
     455  ASSERT(nforetiles, "no foreground tiles defined!");
     456  ASSERT(foretiles[0] >= 0, "no black (0) foreground tile defined!");
     457  ASSERT(backtiles[0] >= 0, "no black (0) background tile defined!");
     458  ASSERT(big_font_pict != -1 || small_font_pict != -1,
     459         "no font loaded (use load_big_font or load_small_font)!");
     460  f_wid = cache.foret(foretiles[0])->im->Size().x;
     461  f_hi = cache.foret(foretiles[0])->im->Size().y;
     462  b_wid = cache.backt(backtiles[0])->im->Size().x;
     463  b_hi = cache.backt(backtiles[0])->im->Size().y;
    464464
    465465#if 0
     
    501501  long l=fp->file_size();
    502502  s=(char *)malloc(l+1);
    503   ERROR(s,"Malloc error in load_script");
     503  ASSERT(s, "malloc error in load_script");
    504504
    505505  fp->read(s,l);
  • abuse/branches/lol/src/loadgame.cpp

    r682 r687  
    7070  for (i=0; i<total_saved; i++,y+=ih)
    7171  {
    72     maxih = Max(ih, maxih);
    73     maxiw = Max(iw, maxiw);
     72    maxih = lol::max(ih, maxih);
     73    maxiw = lol::max(iw, maxiw);
    7474    if (y >= lines * ih)
    7575    {
  • abuse/branches/lol/src/menu.cpp

    r686 r687  
    5050    ivec2 caa, cbb;
    5151    main_screen->GetClip(caa, cbb);
    52     aa = Max(aa, caa);
    53     bb = Min(bb, cbb);
     52    aa = lol::max(aa, caa);
     53    bb = lol::min(bb, cbb);
    5454
    5555    if (!(aa < bb))
  • abuse/branches/lol/src/objects.cpp

    r686 r687  
    240240int RC_type_size(int type)
    241241{
    242   switch (type)
    243   {
    244     case RC_8 :
    245     { return 1; } break;
    246     case RC_16 :
    247     { return 2; } break;
    248     case RC_32 :
    249     { return 4; } break;
    250   }
    251   CHECK(0);
    252   return 1;
     242    switch (type)
     243    {
     244        case RC_8: return 1;
     245        case RC_16: return 2;
     246        case RC_32: return 4;
     247    }
     248    ASSERT(false);
     249    return 1;
    253250}
    254251
     
    389386    ivec2 pos2 = the_game->GameToMouse(ivec2(x1, draw_to), v);
    390387
    391     pos2.y = Max(v->m_aa.y, pos2.y);
    392     pos1.y = Min(v->m_bb.y, pos1.y);
     388    pos2.y = lol::max(v->m_aa.y, pos2.y);
     389    pos1.y = lol::min(v->m_bb.y, pos1.y);
    393390    TransImage *p = picture();
    394391
  • abuse/branches/lol/src/particle.cpp

    r686 r687  
    4141void add_panim(int id, long x, long y, int dir)
    4242{
    43   CONDITION(id>=0 && id<total_pseqs,"bad id for particle animation");
     43  ASSERT(id >= 0 && id < total_pseqs, "bad id for particle animation");
    4444  part_animation *pan=new part_animation(pseqs[id],x,y,dir,NULL);
    4545  if (!first_anim)
     
    214214    main_screen->GetClip(caa, cbb);
    215215
    216     int t = 1 + Max(lol::abs(p2.x - p1.x), lol::abs(p2.y - p1.y));
     216    int t = 1 + lol::max(lol::abs(p2.x - p1.x), lol::abs(p2.y - p1.y));
    217217    int xo = p1.x << 16,
    218218        yo = p1.y << 16,
     
    244244    main_screen->GetClip(caa, cbb);
    245245
    246     int t = 1 + Max(lol::abs(p2.x - p1.x), lol::abs(p2.y - p1.y));
     246    int t = 1 + lol::max(lol::abs(p2.x - p1.x), lol::abs(p2.y - p1.y));
    247247    int xo = p1.x << 16,
    248248        yo = p1.y << 16,
  • abuse/branches/lol/src/sdlport/event.cpp

    r682 r687  
    8484    int x, y;
    8585    uint8_t buttons = SDL_GetMouseState(&x, &y);
    86     x = Min((x << 16) / mouse_xscale, main_screen->Size().x - 1);
    87     y = Min((y << 16) / mouse_yscale, main_screen->Size().y - 1);
     86    x = lol::min((x << 16) / mouse_xscale, main_screen->Size().x - 1);
     87    y = lol::min((y << 16) / mouse_yscale, main_screen->Size().y - 1);
    8888    ev.mouse_move.x = x;
    8989    ev.mouse_move.y = y;
  • abuse/branches/lol/src/sdlport/video.cpp

    r682 r687  
    241241        return;
    242242
    243     CHECK(x1 >= 0 && x2 >= x1 && y1 >= 0 && y2 >= y1);
     243    ASSERT(x1 >= 0);
     244    ASSERT(x2 >= x1);
     245    ASSERT(y1 >= 0);
     246    ASSERT(y2 >= y1);
    244247
    245248    // Adjust if we are trying to draw off the screen
  • abuse/branches/lol/src/tool/abuse-tool.cpp

    r682 r687  
    163163                /* Try to print a representation of the item */
    164164                int has_binary = 0;
    165                 for (int i = 0; i < Min(20, (int)se->size); i++)
     165                for (int i = 0; i < lol::min(20, (int)se->size); i++)
    166166                {
    167167                    uint8_t ch = ((uint8_t *)se->data)[i];
     
    176176                    putchar('\"');
    177177
    178                 size_t max = Min(has_binary ? 15 : 30, (int)se->size);
     178                size_t max = lol::min(has_binary ? 15 : 30, (int)se->size);
    179179                for (size_t i = 0; i < max; i++)
    180180                {
     
    220220        {
    221221            uint8_t buf[1024];
    222             int step = Min((int)todo, 1024);
     222            int step = lol::min((int)todo, 1024);
    223223            fp.read(buf, step);
    224224            fwrite(buf, step, 1, stdout);
  • abuse/branches/lol/src/transp.cpp

    r682 r687  
    2525    ivec2 pos(x, y);
    2626
    27     aa += Max(caa - pos, ivec2(0));
    28     bb -= Max(caa - pos, ivec2(0));
    29     pos = Max(caa, pos);
     27    aa += lol::max(caa - pos, ivec2(0));
     28    bb -= lol::max(caa - pos, ivec2(0));
     29    pos = lol::max(caa, pos);
    3030
    31     bb = Min(bb, cbb - ivec2(1) - pos);
     31    bb = lol::min(bb, cbb - ivec2(1) - pos);
    3232
    3333    if (!(bb >= ivec2(0)))
  • abuse/branches/lol/src/view.cpp

    r682 r687  
    119119        return pan_x;
    120120
    121     return Max(0, m_lastpos.x - (m_bb.x - m_aa.x + 1) / 2 + m_shift.x + pan_x);
     121    return lol::max(0, m_lastpos.x - (m_bb.x - m_aa.x + 1) / 2 + m_shift.x + pan_x);
    122122}
    123123
     
    127127        return pan_x;
    128128
    129     return Max(0, (m_lastlastpos.x + m_lastpos.x) / 2
     129    return lol::max(0, (m_lastlastpos.x + m_lastpos.x) / 2
    130130                    - (m_bb.x - m_aa.x + 1) / 2 + m_shift.x + pan_x);
    131131}
     
    136136        return pan_y;
    137137
    138     return Max(0, m_lastpos.y - (m_bb.y - m_aa.y + 1) / 2 - m_shift.y + pan_y);
     138    return lol::max(0, m_lastpos.y - (m_bb.y - m_aa.y + 1) / 2 - m_shift.y + pan_y);
    139139}
    140140
     
    144144        return pan_y;
    145145
    146     return Max(0, (m_lastlastpos.y + m_lastpos.y) / 2
     146    return lol::max(0, (m_lastlastpos.y + m_lastpos.y) / 2
    147147                    - (m_bb.y - m_aa.y + 1) / 2 - m_shift.y + pan_y);
    148148}
     
    157157
    158158    if (m_focus->x > m_lastpos.x)
    159         m_lastpos.x = Max(m_lastpos.x, m_focus->x - no_xright);
     159        m_lastpos.x = lol::max(m_lastpos.x, m_focus->x - no_xright);
    160160    else if (m_focus->x < m_lastpos.x)
    161         m_lastpos.x = Min(m_lastpos.x, m_focus->x + no_xleft);
     161        m_lastpos.x = lol::min(m_lastpos.x, m_focus->x + no_xleft);
    162162
    163163    if (m_focus->y > m_lastpos.y)
    164         m_lastpos.y = Max(m_lastpos.y, m_focus->y - no_ybottom);
     164        m_lastpos.y = lol::max(m_lastpos.y, m_focus->y - no_ybottom);
    165165    else if (m_focus->y < m_lastpos.y)
    166         m_lastpos.y = Min(m_lastpos.y, m_focus->y + no_ytop);
     166        m_lastpos.y = lol::min(m_lastpos.y, m_focus->y + no_ytop);
    167167}
    168168
Note: See TracChangeset for help on using the changeset viewer.