diff --git a/engine/openbor.c b/engine/openbor.c index d1619ae75..9675f9347 100644 --- a/engine/openbor.c +++ b/engine/openbor.c @@ -143,8 +143,8 @@ const s_defense default_defense = .block_damage_adjust = 0, .block_damage_max = MAX_INT, .block_damage_min = MIN_INT, - .blockpower = 0.f, - .blockthreshold = 0.f, + .blockpower = 0, + .blockthreshold = 0, .blockratio = DEFENSE_BLOCKRATIO_COMPATABILITY_DEFAULT, .blocktype = BLOCK_TYPE_GLOBAL, .death_config_flags = DEATH_CONFIG_MACRO_DEFAULT, @@ -153,7 +153,7 @@ const s_defense default_defense = .damage_min = MIN_INT, .factor = 1.f, .knockdown = 1.f, - .pain = 0.f + .pain = 0 }; const s_offense default_offense = @@ -1029,7 +1029,7 @@ int buffer_append(char **buffer, const char *str, size_t n, size_t *bufferlen, s *buffer = realloc(*buffer, *bufferlen = appendlen + *len + 1024); if(*buffer == NULL) { - borShutdown(1, "Unalbe to resize buffer.\n"); + borShutdown(1, "Unable to resize buffer.\n"); } } strncpy(*buffer + *len, str, appendlen); @@ -1051,7 +1051,7 @@ int handle_txt_include(char *command, ArgList *arglist, char **fn, char *namebuf *buf = realloc(*buf, *len + size + strlen(incfile) + strlen(filename) + 100); //leave enough memory for jump command if(*buf == NULL) { - borShutdown(1, "Unalbe to resize buffer. (handle_txt_include)\n"); + borShutdown(1, "Unable to resize buffer. (handle_txt_include)\n"); free(buf2); return 0; } @@ -4301,7 +4301,7 @@ void cachesound(int index, int load) // Rewrite by Caskey, Damon V. // 2018-03-19 // -// Add or remove a sprite to the the sprite list +// Add or remove a sprite to the sprite list // by index. // // index: Target index in the sprite list. @@ -4842,12 +4842,12 @@ int nextcolourmapn(s_model *model, int map_index, int player_index) // This logic attempts to populate used_colors_map array with // every color in use by other players who picking same - // character. If there are aren't enough unused map indexes to + // character. If there aren't enough unused map indexes to // go around (i.e. three players select a character that only // has two maps), then we return initial map selection. for(i = 0; i < MAX_PLAYERS; i++) - { + { // Compare every player index to player_index argument. If // it's a different index but that index's model matches // player_index's model, then it's another player choosing @@ -4961,7 +4961,7 @@ int prevcolourmapn(s_model *model, int map_index, int player_index) // This logic attempts to populate used_colors_map array with // every color in use by other players who picking same - // character. If there are aren't enough unused map indexes to + // character. If there aren't enough unused map indexes to // go around (i.e. three players select a character that only // has two maps), then we return initial map selection. @@ -6636,7 +6636,7 @@ void child_spawn_execute_list(s_child_spawn* head, entity* parent) * 2022-05-29 * * Accept pointer to node in list of child -* spawns. Apply properties to to spawn +* spawns. Apply properties to spawn * a child entity. Returns pointer to * spawned entity. */ @@ -9391,7 +9391,7 @@ void prepare_cache_map(size_t size) void cache_model(char *name, char *path, int flag) { int len; - printf("Cacheing '%s' from %s\n", name, path); + printf("Caching '%s' from %s\n", name, path); prepare_cache_map(models_cached + 1); memset(&model_cache[models_cached], 0, sizeof(model_cache[models_cached])); @@ -12497,7 +12497,7 @@ size_t lcmScriptDeleteMain(char **buf) len = i; break; } else continue; - if (i <= 0) break; + //if (i <= 0) break; } len = len-pos; @@ -12641,7 +12641,7 @@ s_model *init_model(const int cacheindex, const int unload) /* * Faction data. Faction type properties * get defaults set downstream depending - * on the the model's own type. + * on the model's own type. */ newchar->faction = (s_faction){ @@ -13694,7 +13694,6 @@ s_model *load_cached_model(char *name, char *owner, char unload) offense_setup_from_arg(filename, command, newchar->offense, &arglist, OFFENSE_PARAMETER_FACTOR); break; - break; case CMD_MODEL_HEIGHT: newchar->size.y = GET_INT_ARG(1); break; @@ -14842,7 +14841,7 @@ s_model *load_cached_model(char *name, char *owner, char unload) child_spawn_upsert_property(&temp_child_spawn_head, temp_child_spawn_index)->config = (CHILD_SPAWN_CONFIG_AUTOKILL_HIT | CHILD_SPAWN_CONFIG_BEHAVIOR_BOMB | CHILD_SPAWN_CONFIG_FACTION_DAMAGE_PARENT | CHILD_SPAWN_CONFIG_FACTION_HOSTILE_PARENT | CHILD_SPAWN_CONFIG_FACTION_INDIRECT_PARENT | CHILD_SPAWN_CONFIG_LAUNCH_TOSS | CHILD_SPAWN_CONFIG_MOVE_CONFIG_PARAMETER | CHILD_SPAWN_CONFIG_RELATIONSHIP_OWNER); child_spawn_upsert_property(&temp_child_spawn_head, temp_child_spawn_index)->aimove = AIMOVE1_BOMB; child_spawn_upsert_property(&temp_child_spawn_head, temp_child_spawn_index)->direction_adjust = DIRECTION_ADJUST_SAME; - child_spawn_upsert_property(&temp_child_spawn_head, temp_child_spawn_index)->move_config_flags = (MOVE_CONFIG_NO_ADJUST_BASE | MOVE_CONFIG_SUBJECT_TO_HOLE | MOVE_CONFIG_SUBJECT_TO_PLATFORM | MOVE_CONFIG_SUBJECT_TO_WALL | MOVE_CONFIG_SUBJECT_TO_MAX_Z | MOVE_CONFIG_SUBJECT_TO_MIN_Z | MOVE_CONFIG_SUBJECT_TO_PLATFORM); + child_spawn_upsert_property(&temp_child_spawn_head, temp_child_spawn_index)->move_config_flags = (MOVE_CONFIG_NO_ADJUST_BASE | MOVE_CONFIG_SUBJECT_TO_HOLE | MOVE_CONFIG_SUBJECT_TO_PLATFORM | MOVE_CONFIG_SUBJECT_TO_WALL | MOVE_CONFIG_SUBJECT_TO_MAX_Z | MOVE_CONFIG_SUBJECT_TO_MIN_Z); break; @@ -14855,7 +14854,7 @@ s_model *load_cached_model(char *name, char *owner, char unload) child_spawn_upsert_property(&temp_child_spawn_head, temp_child_spawn_index)->config = (CHILD_SPAWN_CONFIG_AUTOKILL_HIT | CHILD_SPAWN_CONFIG_BEHAVIOR_SHOT | CHILD_SPAWN_CONFIG_FACTION_DAMAGE_PARENT | CHILD_SPAWN_CONFIG_FACTION_HOSTILE_PARENT | CHILD_SPAWN_CONFIG_FACTION_INDIRECT_PARENT | CHILD_SPAWN_CONFIG_GRAVITY_OFF | CHILD_SPAWN_CONFIG_LAUNCH_THROW | CHILD_SPAWN_CONFIG_MOVE_CONFIG_PARAMETER | CHILD_SPAWN_CONFIG_RELATIONSHIP_OWNER); child_spawn_upsert_property(&temp_child_spawn_head, temp_child_spawn_index)->aimove = AIMOVE1_ARROW; child_spawn_upsert_property(&temp_child_spawn_head, temp_child_spawn_index)->direction_adjust = DIRECTION_ADJUST_SAME; - child_spawn_upsert_property(&temp_child_spawn_head, temp_child_spawn_index)->move_config_flags = (MOVE_CONFIG_NO_ADJUST_BASE | MOVE_CONFIG_SUBJECT_TO_HOLE | MOVE_CONFIG_SUBJECT_TO_PLATFORM | MOVE_CONFIG_SUBJECT_TO_WALL | MOVE_CONFIG_SUBJECT_TO_MAX_Z | MOVE_CONFIG_SUBJECT_TO_MIN_Z | MOVE_CONFIG_SUBJECT_TO_PLATFORM); + child_spawn_upsert_property(&temp_child_spawn_head, temp_child_spawn_index)->move_config_flags = (MOVE_CONFIG_NO_ADJUST_BASE | MOVE_CONFIG_SUBJECT_TO_HOLE | MOVE_CONFIG_SUBJECT_TO_PLATFORM | MOVE_CONFIG_SUBJECT_TO_WALL | MOVE_CONFIG_SUBJECT_TO_MAX_Z | MOVE_CONFIG_SUBJECT_TO_MIN_Z); child_spawn_upsert_property(&temp_child_spawn_head, temp_child_spawn_index)->takedamage = arrow_takedamage; break; @@ -16029,7 +16028,7 @@ s_model *load_cached_model(char *name, char *owner, char unload) /* * Translate text value into a pre-defined forcemap constant. - * Wen applying a pre-defined forcemap, we�ll look at the model + * When applying a pre-defined forcemap, we�ll look at the model * and try to find its appropriate index. For example, if the * pre-defined BURN is used, forcemap will apply the model�s * designated burn. This allows use of effect maps without the @@ -16620,10 +16619,10 @@ s_model *load_cached_model(char *name, char *owner, char unload) break; case CMD_MODEL_FORCEMAP: - + /* * Translate text value into a pre-defined forcemap constant. - * Wen applying a pre-defined forcemap, we�ll look at the model + * When applying a pre-defined forcemap, we�ll look at the model * and try to find its appropriate index. For example, if the * pre-defined BURN is used, forcemap will apply the model�s * designated burn. This allows use of effect maps without the @@ -16902,7 +16901,7 @@ s_model *load_cached_model(char *name, char *owner, char unload) /* * Delete nodes from frame object lists - * that don't have valid data (i.e no + * that don't have valid data (i.e. no * coordinates defined at all or the * coordinates X/Y/H/W are all 0). * @@ -22138,7 +22137,7 @@ void draw_visual_debug() // boxes, which is what the draw_box_on_entity() funciton // is meant for. For Y axis, We need to invert the value, // and place them in opposiing parameters (Max Y into - // function's min Y parameter, and and min Y into function's + // function's min Y parameter, and min Y into function's // max Y parameter). range_y_min = -entity->animation->range.y.min; @@ -28518,7 +28517,7 @@ void update_health() // 1 Only recover MP > mpstableval. // 2 No recover. Drop MP if MP < mpstableval. - // 3 Both: recover if MP if MP < mpstableval and drop if MP > mpstableval. + // 3 Both: recover if MP < mpstableval and drop if MP > mpstableval. // 4 Gain until stable, then fall to stable. // 0 Default. Recover MP at all times. @@ -29622,7 +29621,7 @@ void display_ents() { alty = (int)(e->position.y - (other->position.y + other->animation->platform[other->animpos][PLATFORM_HEIGHT])); temp1 = -1 * (e->position.y - (other->position.y + other->animation->platform[other->animpos][PLATFORM_HEIGHT])) * light.x / 256; // xshift - temp2 = (float)(-e->position.y * light.y / 256); + temp2 = -e->position.y * light.y / 256; qx = (int)(e->position.x - scrx); qy = (int)(e->position.z - scry - other->position.y - other->animation->platform[other->animpos][PLATFORM_HEIGHT]); // + (other->animation->platform[other->animpos][PLATFORM_DEPTH]/2) @@ -30757,7 +30756,7 @@ entity *normal_find_target(int anim, int detect_adj) continue; } - // If anim is defined, then then target must be + // If anim is defined, then target must be // in range of animation. if(anim >= 0) { @@ -44065,7 +44064,7 @@ int obstacle_takedamage(entity *other, s_attack *attack, int fall_flag, s_defens void initialize_item_carry(entity *ent, s_spawn_entry *spawn_entry) { // It's possible to call this from script, so if - // if there is already memory for an item allocated + // there is already memory for an item allocated // here, clear it out to make sure we don't end up // with any memory leaks. if(ent->item_properties) @@ -45607,12 +45606,12 @@ int recordInputs() { if ( playrecstatus->synctime%window >= window-2 ) // last is NULL bytes { - playrecstatus->buffer = (RecKeys*)realloc(playrecstatus->buffer,sizeof(RecKeys)*((int)(trunc(playrecstatus->synctime/window)+1)*window+window)); + playrecstatus->buffer = (RecKeys*)realloc(playrecstatus->buffer,sizeof(RecKeys)*((playrecstatus->synctime/window+1)*window+window)); if (playrecstatus->buffer == NULL) { printf("Error to allocate buffer in record inputs mode.\n"); return 0; - } else memset(playrecstatus->buffer+(playrecstatus->synctime+1),0,(int)(trunc(playrecstatus->synctime/window)+1)*window+window-(playrecstatus->synctime+1)-1); // -2 becouse -1 is to 0 to size-1 + } else memset(playrecstatus->buffer+(playrecstatus->synctime+1),0,(playrecstatus->synctime/window+1)*window+window-(playrecstatus->synctime+1)-1); // -2 because -1 is to 0 to size-1 } } @@ -48885,7 +48884,7 @@ void init_videomodes(int log) } else if(stricmp(command, "colourdepth") == 0) { - printf("\nColordepth is depreciated. All modules are displayed with a 32bit color screen.\n\n"); + printf("\nColordepth is not supported anymore. All modules are displayed with a 32bit color screen.\n\n"); } else if(stricmp(command, "forcemode") == 0) {} else if(command && command[0]) diff --git a/engine/openbor.h b/engine/openbor.h index d3c1bfd74..eefd99556 100644 --- a/engine/openbor.h +++ b/engine/openbor.h @@ -3630,7 +3630,7 @@ typedef struct entity // Size defined ints (for time). unsigned long combotime; // If not expired, continue to next attack in series combo. ~~ unsigned long guardtime; // Next time to auto adjust guardpoints. ~~ - unsigned long freezetime; // Used to store at what point the a frozen entity becomes unfrozen. ~~ + unsigned long freezetime; // Used to store at what point a frozen entity becomes unfrozen. ~~ unsigned long invinctime; // Used to set time for invincibility to expire. ~~ unsigned long knockdowntime; // When knockdown count is expired. ~~ unsigned long magictime; // Next time to auto adjust MP. ~~ @@ -3794,7 +3794,7 @@ typedef struct unsigned long musicoffset; char *name; // must be a name in the model list, so just reference int index; // model index - int weaponindex; // the spawned entity with an weapon item, this is the index of the item model + int weaponindex; // the spawned entity with a weapon item, this is the index of the item model int alpha; // Used for alpha effects int boss; int flip; @@ -3817,7 +3817,7 @@ typedef struct unsigned credit; int aggression; // For enemy A.I. int spawntype; // Pass 1 when a level spawn. - e_entity_type entitytype; // if it's a enemy, player etc.. + e_entity_type entitytype; // if it's an enemy, player etc.. entity *parent; char *weapon; // spawn with a weapon, since it should be in the model list, so the model must be loaded, just reference its name s_model *weaponmodel; diff --git a/engine/openborscript.c b/engine/openborscript.c index ef3ee9ba6..c39d17c2b 100644 --- a/engine/openborscript.c +++ b/engine/openborscript.c @@ -21,7 +21,7 @@ Be sure to call ScriptVariant_Clear if you want to use free to delete those variants. If you want to copy a ScriptVariant from another, use ScriptVariant_Copy instead of assignment, - not because it is faster, but this method is neccessary for string types. + not because it is faster, but this method is necessary for string types. If you want to change types of an ScriptVariant, use ScriptVariant_ChangeType, don't change vt directly. @@ -5005,7 +5005,7 @@ HRESULT openbor_getentityproperty(ScriptVariant **varlist , ScriptVariant **pret case _ep_running_movez: { ScriptVariant_ChangeType(*pretvar, VT_INTEGER); - (*pretvar)->lVal = (LONG)(ent->modeldata.run_config_flags & (RUN_CONFIG_Z_DOWN_ENABLED | RUN_CONFIG_Z_DOWN_ENABLED)); + (*pretvar)->lVal = (LONG)(ent->modeldata.run_config_flags & RUN_CONFIG_Z_DOWN_ENABLED); break; } } @@ -5130,7 +5130,7 @@ HRESULT openbor_getentityproperty(ScriptVariant **varlist , ScriptVariant **pret /* Request from animation or frame that doesn't exist = shutdown. - Let's be more user friendly then that; return empty so modder can evaluate + Let's be more user friendly than that; return empty so modder can evaluate and take action accordingly.*/ if(!validanim(ent, arg->lVal) || !(ent->modeldata.animation[arg->lVal]->numframes >= arg1->lVal)) { @@ -10851,7 +10851,7 @@ HRESULT openbor_savefilestream(ScriptVariant **varlist , ScriptVariant **pretvar arg = varlist[0]; if(FAILED(ScriptVariant_IntegerValue(arg, &filestreamindex))) { - printf("You must give a valid filestrema handle for savefilestream!\n"); + printf("You must give a valid filestream handle for savefilestream!\n"); return E_FAIL; } @@ -11297,7 +11297,6 @@ HRESULT openbor_checkrange(ScriptVariant **varlist , ScriptVariant **pretvar, in { entity *ent = NULL, *target = NULL; LONG ani = 0; - extern int max_animations; if(paramCount < 2) { @@ -13700,7 +13699,6 @@ HRESULT openbor_shutdown(ScriptVariant **varlist , ScriptVariant **pretvar, int HRESULT openbor_jumptobranch(ScriptVariant **varlist , ScriptVariant **pretvar, int paramCount) { LONG ltemp; - extern char branch_name[MAX_NAME_LEN + 1]; *pretvar = NULL; if(paramCount < 1) { @@ -15001,7 +14999,7 @@ HRESULT openbor_setdrawmethod(ScriptVariant **varlist , ScriptVariant **pretvar, return S_OK; setdrawmethod_error: - printf("Function need a valid entity handle and at least 1 interger parameter, setdrawmethod(entity, int flag, int scalex, int scaley, int flipx, int flipy, int shiftx, int alpha, int remap, int fillcolor, int rotate, int fliprotate, int transparencybg, void* colourmap, centerx, centery)\n"); + printf("Function need a valid entity handle and at least 1 integer parameter, setdrawmethod(entity, int flag, int scalex, int scaley, int flipx, int flipy, int shiftx, int alpha, int remap, int fillcolor, int rotate, int fliprotate, int transparencybg, void* colourmap, centerx, centery)\n"); return E_FAIL; } @@ -15046,7 +15044,7 @@ HRESULT openbor_updateframe(ScriptVariant **varlist , ScriptVariant **pretvar, i return S_OK; updateframe_error: - printf("Function need a valid entity handle and at an interger parameter: updateframe(entity, int frame)\n"); + printf("Function need a valid entity handle and at an integer parameter: updateframe(entity, int frame)\n"); return E_FAIL; } diff --git a/engine/sdl/video.h b/engine/sdl/video.h index a6b9c2570..c861c4827 100644 --- a/engine/sdl/video.h +++ b/engine/sdl/video.h @@ -12,7 +12,9 @@ #include "gfxtypes.h" #include "types.h" #include "yuv.h" +#if SDL #include "SDL.h" +#endif extern u8 pDeltaBuffer[480 * 2592]; extern int opengl; diff --git a/engine/source/gamelib/bitmap.c b/engine/source/gamelib/bitmap.c index 2ec4934c9..4bf0d4527 100644 --- a/engine/source/gamelib/bitmap.c +++ b/engine/source/gamelib/bitmap.c @@ -70,7 +70,7 @@ void freebitmap(s_bitmap *bitmap) void getbitmap(int x, int y, int width, int height, s_bitmap *bitmap, s_screen *screen) { - int s, d; + int d; //int i; int j; @@ -108,7 +108,7 @@ void getbitmap(int x, int y, int width, int height, s_bitmap *bitmap, s_screen * d = 0; for(j = 0; j < height; j++) { - s = x + (y + j) * screen->width; + int s = x + (y + j) * screen->width; memcpy(((char *)bitmap->data) + d, ((char *)screen->data) + s, width); d += width; /* @@ -130,7 +130,7 @@ void putbitmap(int x, int y, s_bitmap *bitmap, s_screen *screen) int skiptop = 0; int width = bitmap->width; int height = bitmap->height; - int s, d; + int d; int i; // Clip width and height @@ -163,7 +163,7 @@ void putbitmap(int x, int y, s_bitmap *bitmap, s_screen *screen) do { - s = skiptop * bitmap->width + skipleft; + int s = skiptop * bitmap->width + skipleft; ++skiptop; for(i = 0; i < width; i++) { @@ -184,7 +184,6 @@ void putbitmap(int x, int y, s_bitmap *bitmap, s_screen *screen) void flipbitmap(s_bitmap *bitmap) { int x, xo, y; - unsigned char t; int xsize = bitmap->width; int ysize = bitmap->height; @@ -192,7 +191,7 @@ void flipbitmap(s_bitmap *bitmap) { for(x = 0, xo = xsize - 1; x < xsize / 2; x++, xo--) { - t = bitmap->data[y * xsize + x]; + unsigned char t = bitmap->data[y * xsize + x]; bitmap->data[y * xsize + x] = bitmap->data[y * xsize + xo]; bitmap->data[y * xsize + xo] = t; } @@ -374,6 +373,3 @@ void clipbitmap(s_bitmap *bitmap, int *clip_left, int *clip_right, int *clip_top *clip_bottom = bottom_clipmove; } } - - - diff --git a/engine/source/gamelib/draw.c b/engine/source/gamelib/draw.c index 565437464..9e92e0679 100644 --- a/engine/source/gamelib/draw.c +++ b/engine/source/gamelib/draw.c @@ -275,11 +275,7 @@ void _putpixel(int x, int y, int colour, s_screen *screen, int alpha) return; } pixind = x + y * screen->width; - lut = alpha > 0 ? blendtables[alpha - 1] : NULL; - if(lut) - { - lut += (colour << 8); - } + lut = alpha > 0 ? blendtables[alpha - 1] + (colour << 8) : NULL; screen->data[pixind] = (lut && screen->data[pixind]) ? (lut[(int)(screen->data[pixind]) & 0xFF]) : colour; } @@ -288,7 +284,7 @@ void _putpixel(int x, int y, int colour, s_screen *screen, int alpha) // Code to draw a circle. // I ripped this, not sure how it works... -// It seems it devides the circle into 8 parts, which are drawn +// It seems it divides the circle into 8 parts, which are drawn // simultaneously. // Not much optimization, though, since every pixel is clipped // separately. @@ -421,5 +417,3 @@ void putpixel(unsigned x, unsigned y, int colour, s_screen *screen, s_drawmethod break; } } - - diff --git a/engine/source/gamelib/filecache.c b/engine/source/gamelib/filecache.c index ec5f9714a..f53603283 100644 --- a/engine/source/gamelib/filecache.c +++ b/engine/source/gamelib/filecache.c @@ -6,7 +6,9 @@ #include #include +#ifndef _MSC_VER #include +#endif #include "utils.h" #include "packfile.h" #include "filecache.h" diff --git a/engine/source/gamelib/filters.c b/engine/source/gamelib/filters.c index dd0d683b9..5dbc2b6c6 100644 --- a/engine/source/gamelib/filters.c +++ b/engine/source/gamelib/filters.c @@ -41,8 +41,8 @@ u32 INTERPOLATE(u32 A, u32 B) u32 Q_INTERPOLATE(u32 A, u32 B, u32 C, u32 D) { - register u32 x = ((A & qcolorMask) >> 2) + ((B & qcolorMask) >> 2) + ((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2); - register u32 y = (A & qlowpixelMask) + (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask); + u32 x = ((A & qcolorMask) >> 2) + ((B & qcolorMask) >> 2) + ((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2); + u32 y = (A & qlowpixelMask) + (B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask); y = (y >> 2) & qlowpixelMask; return x + y; } @@ -194,28 +194,33 @@ static inline u16 MAKE_RGB565(float r, float g, float b) ((((unsigned char)b) << 0) & BLUE_MASK565 ); } +static float cube(float x) +{ + return x * x * x; +} + float CUBIC_WEIGHT(float x) { // P(x) = { x, x>0 | 0, x<=0 } // P(x + 2) ^ 3 - 4 * P(x + 1) ^ 3 + 6 * P(x) ^ 3 - 4 * P(x - 1) ^ 3 - double r = 0.; - if(x + 2 > 0) + float r = 0.; + if(x + 2.f > 0) { - r += pow(x + 2, 3); + r += cube(x + 2.f); } - if(x + 1 > 0) + if(x + 1.f > 0) { - r += -4 * pow(x + 1, 3); + r += -4.f * cube(x + 1.f); } - if(x > 0) + if(x > 0) { - r += 6 * pow(x , 3); + r += 6.f * cube(x); } - if(x - 1 > 0) + if(x - 1.f > 0) { - r += -4 * pow(x - 1, 3); + r += -4.f * cube(x - 1.f); } - return (float)r / 6; + return r / 6.f; } void filter_bicubic(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height) @@ -247,12 +252,12 @@ void filter_bicubic(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstP for(m = -1; m <= 2; ++m) { - float r1 = CUBIC_WEIGHT(decy - m); + float r1 = CUBIC_WEIGHT(decy - (float)m); int n; for(n = -1; n <= 2; ++n) { - float r2 = CUBIC_WEIGHT(n - decx); + float r2 = CUBIC_WEIGHT((float)n - decx); const u16 *pIn = p + (iu + n) + (iv + m) * nextlineSrc; MULT(*pIn, &r, &g, &b, r1 * r2); } diff --git a/engine/source/gamelib/packfile.c b/engine/source/gamelib/packfile.c index 4313f0647..a5ce4644d 100644 --- a/engine/source/gamelib/packfile.c +++ b/engine/source/gamelib/packfile.c @@ -213,15 +213,11 @@ int myfilenamecmp(const char *a, size_t asize, const char *b, size_t bsize) { return 1; } - if (*ca == *cb) - { - goto cont; - } - if (tolowerOneChar(ca) != tolowerOneChar(cb)) + if ((*ca != *cb) && (tolowerOneChar(ca) != tolowerOneChar(cb))) { return 1; } -cont: + ca++; cb++; } @@ -1337,18 +1333,15 @@ void packfile_music_read(fileliststruct *filelist, int dListTotal) p = strrchr(pn.namebuf, '.'); if((p && (!stricmp(p, ".bor") || !stricmp(p, ".ogg"))) || (stristr(pn.namebuf, "music"))) { - if(!stristr(pn.namebuf, ".bor") && !stristr(pn.namebuf, ".ogg")) - { - goto nextpak; - } - if(filelist[i].nTracks < MAX_TRACKS) + if ((stristr(pn.namebuf, ".bor") || stristr(pn.namebuf, ".ogg")) && (filelist[i].nTracks < MAX_TRACKS)) { packfile_get_titlename(pn.namebuf, filelist[i].bgmFileName[filelist[i].nTracks]); filelist[i].bgmTracks[filelist[i].nTracks] = off; filelist[i].nTracks++; } } -nextpak: + + // nextpak: off += pn.pns_len; if(fseek(fd, off, SEEK_SET) < 0) { diff --git a/engine/source/gamelib/pixelformat.c b/engine/source/gamelib/pixelformat.c index aa23898ee..bcf60e0fe 100644 --- a/engine/source/gamelib/pixelformat.c +++ b/engine/source/gamelib/pixelformat.c @@ -66,7 +66,7 @@ int usechannel; int useclip; int clipx1, clipy1, clipx2, clipy2; -//may be used many time so make a function +//may be used many times so make a function void drawmethod_global_init(s_drawmethod *drawmethod) { diff --git a/engine/source/gamelib/sprite.c b/engine/source/gamelib/sprite.c index 8d0668fcd..48e7ef423 100644 --- a/engine/source/gamelib/sprite.c +++ b/engine/source/gamelib/sprite.c @@ -22,12 +22,12 @@ static void putsprite_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx < xmax) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -72,12 +72,12 @@ static void putsprite_flip_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx > xmin) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -128,12 +128,12 @@ static void putsprite_remap_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx < xmax) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -183,12 +183,12 @@ static void putsprite_remap_flip_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx > xmin) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -240,12 +240,12 @@ static void putsprite_remapblend_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx < xmax) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -293,12 +293,12 @@ static void putsprite_remapblend_flip_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx > xmin) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -346,12 +346,12 @@ static void putsprite_blend_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx < xmax) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -399,12 +399,12 @@ static void putsprite_blend_flip_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx > xmin) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -637,23 +637,22 @@ static void _putsprite(int x, int y, s_sprite *sprite, s_screen *screen, s_drawm { if(!drawmethod || !(drawmethod->config & DRAWMETHOD_CONFIG_ENABLED)) { - goto plainsprite; + switch (screen->pixelformat) + { + case PIXEL_8: + putsprite_8(x, y, 0, sprite, screen, NULL, NULL); + break; + case PIXEL_16: + putsprite_x8p16(x, y, 0, sprite, screen, (unsigned short*)sprite->palette, NULL); + break; + case PIXEL_32: + putsprite_x8p32(x, y, 0, sprite, screen, (unsigned*)sprite->palette, NULL); + break; + } } - - putsprite_ex(x, y, sprite, screen, drawmethod); - return; -plainsprite: - switch(screen->pixelformat) + else { - case PIXEL_8: - putsprite_8(x, y, 0, sprite, screen, NULL, NULL); - break; - case PIXEL_16: - putsprite_x8p16(x, y, 0, sprite, screen, (unsigned short *)sprite->palette, NULL); - break; - case PIXEL_32: - putsprite_x8p32(x, y, 0, sprite, screen, (unsigned *)sprite->palette, NULL); - break; + putsprite_ex(x, y, sprite, screen, drawmethod); } } diff --git a/engine/source/gamelib/sprite.h b/engine/source/gamelib/sprite.h index 0a476689b..a15c7f5ed 100644 --- a/engine/source/gamelib/sprite.h +++ b/engine/source/gamelib/sprite.h @@ -55,6 +55,6 @@ unsigned blend_hardlight(unsigned color1, unsigned color2); unsigned blend_dodge(unsigned color1, unsigned color2); unsigned blend_half(unsigned color1, unsigned color2); */ -unsigned blend_channel32(register unsigned color1, register unsigned color2, register unsigned a); +unsigned blend_channel32(unsigned color1, unsigned color2, unsigned a); unsigned short blend_channel16(unsigned short color1, unsigned short color2, register unsigned a); #endif diff --git a/engine/source/gamelib/spriteq.h b/engine/source/gamelib/spriteq.h index f10fa4b22..7d7c8f6bb 100644 --- a/engine/source/gamelib/spriteq.h +++ b/engine/source/gamelib/spriteq.h @@ -39,7 +39,7 @@ void spriteq_lock(); void spriteq_unlock(); int spriteq_islocked(); -void spriteq_clear(void); +void spriteq_clear(); #endif diff --git a/engine/source/gamelib/spritex8p16.c b/engine/source/gamelib/spritex8p16.c index d212b0f4d..e22dcb644 100644 --- a/engine/source/gamelib/spritex8p16.c +++ b/engine/source/gamelib/spritex8p16.c @@ -21,12 +21,12 @@ static void putsprite_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx < xmax) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -75,12 +75,12 @@ static void putsprite_flip_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx > xmin) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -133,12 +133,12 @@ static void putsprite_blend_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx < xmax) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -185,12 +185,12 @@ static void putsprite_blend_flip_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; // destination x position + int lx = x; // destination x position unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx > xmin) { - register int count = *data++; // clearcount - number of transparent pixels + int count = *data++; // clearcount - number of transparent pixels if(count == 0xFF) { break; // end-of-line indicator @@ -239,14 +239,14 @@ static void putsprite_mask_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; unsigned char *maskdata = ((unsigned char *)masklinetab) + (*masklinetab); masklinetab++; while(lx < xmax) { - register int count = *data++; + int count = *data++; maskdata++; if(count == 0xFF) { @@ -297,14 +297,14 @@ static void putsprite_mask_flip_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; // destination x position + int lx = x; // destination x position unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; unsigned char *maskdata = ((unsigned char *)masklinetab) + (*masklinetab); masklinetab++; while(lx > xmin) { - register int count = *data++; + int count = *data++; maskdata++; // clearcount - number of transparent pixels if(count == 0xFF) { @@ -478,5 +478,3 @@ void putsprite_x8p16( } ///////////////////////////////////////////////////////////////////////////// - - diff --git a/engine/source/gamelib/spritex8p32.c b/engine/source/gamelib/spritex8p32.c index 315daff7c..9f565e3a4 100644 --- a/engine/source/gamelib/spritex8p32.c +++ b/engine/source/gamelib/spritex8p32.c @@ -22,12 +22,12 @@ static void putsprite_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx < xmax) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -76,12 +76,12 @@ static void putsprite_flip_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx > xmin) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -134,12 +134,12 @@ static void putsprite_blend_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx < xmax) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -186,12 +186,12 @@ static void putsprite_blend_flip_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; while(lx > xmin) { - register int count = *data++; + int count = *data++; if(count == 0xFF) { break; @@ -240,14 +240,14 @@ static void putsprite_mask_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; unsigned char *maskdata = ((unsigned char *)masklinetab) + (*masklinetab); masklinetab++; while(lx < xmax) { - register int count = *data++; + int count = *data++; maskdata++; if(count == 0xFF) { @@ -298,14 +298,14 @@ static void putsprite_mask_flip_( { for(; h > 0; h--, dest += screenwidth) { - register int lx = x; + int lx = x; unsigned char *data = ((unsigned char *)linetab) + (*linetab); linetab++; unsigned char *maskdata = ((unsigned char *)masklinetab) + (*masklinetab); masklinetab++; while(lx > xmin) { - register int count = *data++; + int count = *data++; maskdata++; if(count == 0xFF) { @@ -479,4 +479,3 @@ void putsprite_x8p32( } ///////////////////////////////////////////////////////////////////////////// - diff --git a/engine/source/gamelib/timer.h b/engine/source/gamelib/timer.h index 0fdaff235..a47e70251 100644 --- a/engine/source/gamelib/timer.h +++ b/engine/source/gamelib/timer.h @@ -17,13 +17,12 @@ void borTimerExit(); /* ;---------------------------------------------------------------- ; Proc: timer_getinterval -; In: ECX = frequency (1 to 1193181 Hz) -; Returns: EAX = units passed since last call -; Destroys: EBX ECX EDX +; In: freq = frequency (1 to 1193181 Hz) +; Returns: units passed since last call ; Description: Returns the time that passed since the last call, ; measured in the specified frequency. ; This function is extremely accurate, since all -; rounding errors are compensatred for. +; rounding errors are compensated for. ; Only use for very short intervals! ;---------------------------------------------------------------- */ diff --git a/engine/source/gamelib/transform.c b/engine/source/gamelib/transform.c index 713f527bd..17ee86bfe 100644 --- a/engine/source/gamelib/transform.c +++ b/engine/source/gamelib/transform.c @@ -7,7 +7,7 @@ */ /////////////////////////////////////////////////////////////////////////// -// This file defines some commmon methods used by the gamelib +// This file defines some common methods used by the gamelib //////////////////////////////////////////////////////////////////////////// #include #include "globals.h" @@ -209,7 +209,7 @@ void draw_pixel_bitmap(s_screen *dest, gfx_entry *src, int dx, int dy, int sx, i char sprite_get_pixel(s_sprite *sprite, int x, int y) { int *linetab; - register int lx = 0, count; + int lx = 0, count; unsigned char *data; //should we check? @@ -489,7 +489,7 @@ void _sprite_seek(int x, int y) { int *linetab, *mask_linetab = NULL; unsigned char *data = NULL, *mask_data = NULL; - register int lx = 0, count; + int lx = 0, count; linetab = ((int *)ptr_src) + y; @@ -1451,7 +1451,7 @@ void gfx_draw_scale(s_screen *dest, gfx_entry *src, int x, int y, int centerx, i } #endif -float _sinfactors[256] = {1.0f, 1.0245412285229123f, 1.049067674327418f, 1.0735645635996673f, 1.0980171403295606f, 1.1224106751992162f, 1.1467304744553617f, 1.1709618887603012f, 1.1950903220161282f, 1.2191012401568697f, 1.2429801799032638f, 1.2667127574748984f, 1.2902846772544622f, 1.3136817403988914f, 1.33688985339222f, 1.3598950365349882f, 1.3826834323650898f, 1.4052413140049897f, 1.427555093430282f, 1.4496113296546064f, 1.4713967368259977f, 1.492898192229784f, 1.5141027441932215f, 1.5349976198870971f, 1.5555702330196021f, 1.5758081914178454f, 1.5956993044924332f, 1.6152315905806267f, 1.6343932841636454f, 1.6531728429537766f, 1.6715589548470184f, 1.6895405447370668f, 1.7071067811865474f, 1.724247082951467f, 1.7409511253549592f, 1.7572088465064843f, 1.7730104533627368f, 1.7883464276266063f, 1.8032075314806448f, 1.8175848131515837f, 1.8314696123025453f, 1.8448535652497071f, 1.8577286100002721f, 1.8700869911087112f, 1.881921264348355f, 1.8932243011955152f, 1.9039892931234434f, 1.9142097557035307f, 1.9238795325112867f, 1.9329927988347388f, 1.9415440651830207f, 1.9495281805930366f, 1.956940335732209f, 1.96377606579544f, 1.970031253194544f, 1.9757021300385284f, 1.9807852804032304f, 1.985277642388941f, 1.9891765099647811f, 1.99247953459871f, 1.9951847266721967f, 1.9972904566786902f, 1.9987954562051724f, 1.9996988186962041f, 2.0f, 1.9996988186962041f, 1.9987954562051724f, 1.9972904566786902f, 1.995184726672197f, 1.99247953459871f, 1.9891765099647811f, 1.985277642388941f, 1.9807852804032304f, 1.9757021300385284f, 1.970031253194544f, 1.96377606579544f, 1.956940335732209f, 1.9495281805930366f, 1.9415440651830207f, 1.9329927988347388f, 1.9238795325112867f, 1.9142097557035307f, 1.9039892931234434f, 1.8932243011955152f, 1.881921264348355f, 1.8700869911087114f, 1.8577286100002721f, 1.8448535652497071f, 1.8314696123025453f, 1.8175848131515837f, 1.8032075314806448f, 1.7883464276266063f, 1.773010453362737f, 1.7572088465064848f, 1.740951125354959f, 1.724247082951467f, 1.7071067811865474f, 1.689540544737067f, 1.6715589548470184f, 1.6531728429537766f, 1.6343932841636454f, 1.615231590580627f, 1.5956993044924334f, 1.5758081914178454f, 1.5555702330196021f, 1.5349976198870971f, 1.5141027441932217f, 1.4928981922297841f, 1.471396736825998f, 1.449611329654607f, 1.427555093430282f, 1.40524131400499f, 1.3826834323650898f, 1.3598950365349882f, 1.3368898533922202f, 1.3136817403988914f, 1.2902846772544625f, 1.2667127574748984f, 1.242980179903264f, 1.2191012401568701f, 1.1950903220161286f, 1.1709618887603012f, 1.146730474455362f, 1.1224106751992164f, 1.0980171403295608f, 1.0735645635996677f, 1.0490676743274178f, 1.0245412285229123f, 1.0000000000000002f, 0.9754587714770879f, 0.9509323256725822f, 0.9264354364003325f, 0.9019828596704394f, 0.8775893248007839f, 0.8532695255446384f, 0.8290381112396991f, 0.8049096779838716f, 0.7808987598431302f, 0.7570198200967362f, 0.7332872425251018f, 0.709715322745538f, 0.6863182596011088f, 0.6631101466077799f, 0.6401049634650119f, 0.6173165676349104f, 0.5947586859950102f, 0.5724449065697181f, 0.5503886703453933f, 0.5286032631740023f, 0.5071018077702161f, 0.48589725580677845f, 0.46500238011290307f, 0.44442976698039804f, 0.42419180858215466f, 0.40430069550756675f, 0.3847684094193733f, 0.36560671583635473f, 0.34682715704622346f, 0.32844104515298156f, 0.31045945526293317f, 0.29289321881345254f, 0.2757529170485332f, 0.2590488746450411f, 0.24279115349351576f, 0.22698954663726334f, 0.2116535723733941f, 0.19679246851935494f, 0.18241518684841618f, 0.16853038769745476f, 0.155146434750293f, 0.142271389999728f, 0.12991300889128865f, 0.11807873565164506f, 0.10677569880448478f, 0.09601070687655688f, 0.08579024429646953f, 0.07612046748871348f, 0.06700720116526104f, 0.058455934816979194f, 0.050471819406963325f, 0.043059664267791176f, 0.03622393420456016f, 0.029968746805456026f, 0.02429786996147154f, 0.01921471959676968f, 0.01472235761105889f, 0.010823490035219096f, 0.007520465401289922f, 0.004815273327803071f, 0.002709543321309793f, 0.001204543794827595f, 0.00030118130379575003f, 0.0f, 0.00030118130379575003f, 0.001204543794827595f, 0.002709543321309793f, 0.004815273327803071f, 0.007520465401289922f, 0.010823490035219096f, 0.014722357611058778f, 0.01921471959676957f, 0.02429786996147143f, 0.029968746805456026f, 0.03622393420456005f, 0.043059664267791065f, 0.050471819406963214f, 0.05845593481697908f, 0.06700720116526093f, 0.07612046748871337f, 0.08579024429646942f, 0.09601070687655666f, 0.10677569880448467f, 0.11807873565164495f, 0.12991300889128854f, 0.14227138999972777f, 0.15514643475029277f, 0.16853038769745454f, 0.18241518684841595f, 0.19679246851935472f, 0.21165357237339388f, 0.22698954663726312f, 0.24279115349351543f, 0.2590488746450409f, 0.275752917048533f, 0.2928932188134523f, 0.31045945526293283f, 0.32844104515298133f, 0.3468271570462229f, 0.36560671583635407f, 0.3847684094193726f, 0.40430069550756675f, 0.4241918085821548f, 0.4444297669803978f, 0.46500238011290273f, 0.4858972558067781f, 0.5071018077702157f, 0.5286032631740021f, 0.5503886703453931f, 0.5724449065697175f, 0.5947586859950096f, 0.6173165676349096f, 0.640104963465012f, 0.66311014660778f, 0.6863182596011085f, 0.7097153227455375f, 0.7332872425251014f, 0.7570198200967358f, 0.7808987598431298f, 0.8049096779838712f, 0.8290381112396983f, 0.8532695255446376f, 0.877589324800784f, 0.9019828596704394f, 0.9264354364003325f, 0.9509323256725819f, 0.9754587714770876f}; +static const float _sinfactors[256] = {1.0f, 1.0245412285229123f, 1.049067674327418f, 1.0735645635996673f, 1.0980171403295606f, 1.1224106751992162f, 1.1467304744553617f, 1.1709618887603012f, 1.1950903220161282f, 1.2191012401568697f, 1.2429801799032638f, 1.2667127574748984f, 1.2902846772544622f, 1.3136817403988914f, 1.33688985339222f, 1.3598950365349882f, 1.3826834323650898f, 1.4052413140049897f, 1.427555093430282f, 1.4496113296546064f, 1.4713967368259977f, 1.492898192229784f, 1.5141027441932215f, 1.5349976198870971f, 1.5555702330196021f, 1.5758081914178454f, 1.5956993044924332f, 1.6152315905806267f, 1.6343932841636454f, 1.6531728429537766f, 1.6715589548470184f, 1.6895405447370668f, 1.7071067811865474f, 1.724247082951467f, 1.7409511253549592f, 1.7572088465064843f, 1.7730104533627368f, 1.7883464276266063f, 1.8032075314806448f, 1.8175848131515837f, 1.8314696123025453f, 1.8448535652497071f, 1.8577286100002721f, 1.8700869911087112f, 1.881921264348355f, 1.8932243011955152f, 1.9039892931234434f, 1.9142097557035307f, 1.9238795325112867f, 1.9329927988347388f, 1.9415440651830207f, 1.9495281805930366f, 1.956940335732209f, 1.96377606579544f, 1.970031253194544f, 1.9757021300385284f, 1.9807852804032304f, 1.985277642388941f, 1.9891765099647811f, 1.99247953459871f, 1.9951847266721967f, 1.9972904566786902f, 1.9987954562051724f, 1.9996988186962041f, 2.0f, 1.9996988186962041f, 1.9987954562051724f, 1.9972904566786902f, 1.995184726672197f, 1.99247953459871f, 1.9891765099647811f, 1.985277642388941f, 1.9807852804032304f, 1.9757021300385284f, 1.970031253194544f, 1.96377606579544f, 1.956940335732209f, 1.9495281805930366f, 1.9415440651830207f, 1.9329927988347388f, 1.9238795325112867f, 1.9142097557035307f, 1.9039892931234434f, 1.8932243011955152f, 1.881921264348355f, 1.8700869911087114f, 1.8577286100002721f, 1.8448535652497071f, 1.8314696123025453f, 1.8175848131515837f, 1.8032075314806448f, 1.7883464276266063f, 1.773010453362737f, 1.7572088465064848f, 1.740951125354959f, 1.724247082951467f, 1.7071067811865474f, 1.689540544737067f, 1.6715589548470184f, 1.6531728429537766f, 1.6343932841636454f, 1.615231590580627f, 1.5956993044924334f, 1.5758081914178454f, 1.5555702330196021f, 1.5349976198870971f, 1.5141027441932217f, 1.4928981922297841f, 1.471396736825998f, 1.449611329654607f, 1.427555093430282f, 1.40524131400499f, 1.3826834323650898f, 1.3598950365349882f, 1.3368898533922202f, 1.3136817403988914f, 1.2902846772544625f, 1.2667127574748984f, 1.242980179903264f, 1.2191012401568701f, 1.1950903220161286f, 1.1709618887603012f, 1.146730474455362f, 1.1224106751992164f, 1.0980171403295608f, 1.0735645635996677f, 1.0490676743274178f, 1.0245412285229123f, 1.0000000000000002f, 0.9754587714770879f, 0.9509323256725822f, 0.9264354364003325f, 0.9019828596704394f, 0.8775893248007839f, 0.8532695255446384f, 0.8290381112396991f, 0.8049096779838716f, 0.7808987598431302f, 0.7570198200967362f, 0.7332872425251018f, 0.709715322745538f, 0.6863182596011088f, 0.6631101466077799f, 0.6401049634650119f, 0.6173165676349104f, 0.5947586859950102f, 0.5724449065697181f, 0.5503886703453933f, 0.5286032631740023f, 0.5071018077702161f, 0.48589725580677845f, 0.46500238011290307f, 0.44442976698039804f, 0.42419180858215466f, 0.40430069550756675f, 0.3847684094193733f, 0.36560671583635473f, 0.34682715704622346f, 0.32844104515298156f, 0.31045945526293317f, 0.29289321881345254f, 0.2757529170485332f, 0.2590488746450411f, 0.24279115349351576f, 0.22698954663726334f, 0.2116535723733941f, 0.19679246851935494f, 0.18241518684841618f, 0.16853038769745476f, 0.155146434750293f, 0.142271389999728f, 0.12991300889128865f, 0.11807873565164506f, 0.10677569880448478f, 0.09601070687655688f, 0.08579024429646953f, 0.07612046748871348f, 0.06700720116526104f, 0.058455934816979194f, 0.050471819406963325f, 0.043059664267791176f, 0.03622393420456016f, 0.029968746805456026f, 0.02429786996147154f, 0.01921471959676968f, 0.01472235761105889f, 0.010823490035219096f, 0.007520465401289922f, 0.004815273327803071f, 0.002709543321309793f, 0.001204543794827595f, 0.00030118130379575003f, 0.0f, 0.00030118130379575003f, 0.001204543794827595f, 0.002709543321309793f, 0.004815273327803071f, 0.007520465401289922f, 0.010823490035219096f, 0.014722357611058778f, 0.01921471959676957f, 0.02429786996147143f, 0.029968746805456026f, 0.03622393420456005f, 0.043059664267791065f, 0.050471819406963214f, 0.05845593481697908f, 0.06700720116526093f, 0.07612046748871337f, 0.08579024429646942f, 0.09601070687655666f, 0.10677569880448467f, 0.11807873565164495f, 0.12991300889128854f, 0.14227138999972777f, 0.15514643475029277f, 0.16853038769745454f, 0.18241518684841595f, 0.19679246851935472f, 0.21165357237339388f, 0.22698954663726312f, 0.24279115349351543f, 0.2590488746450409f, 0.275752917048533f, 0.2928932188134523f, 0.31045945526293283f, 0.32844104515298133f, 0.3468271570462229f, 0.36560671583635407f, 0.3847684094193726f, 0.40430069550756675f, 0.4241918085821548f, 0.4444297669803978f, 0.46500238011290273f, 0.4858972558067781f, 0.5071018077702157f, 0.5286032631740021f, 0.5503886703453931f, 0.5724449065697175f, 0.5947586859950096f, 0.6173165676349096f, 0.640104963465012f, 0.66311014660778f, 0.6863182596011085f, 0.7097153227455375f, 0.7332872425251014f, 0.7570198200967358f, 0.7808987598431298f, 0.8049096779838712f, 0.8290381112396983f, 0.8532695255446376f, 0.877589324800784f, 0.9019828596704394f, 0.9264354364003325f, 0.9509323256725819f, 0.9754587714770876f}; #define distortion(x, a) ((int)(_sinfactors[x]*a+0.5)) void gfx_draw_water(s_screen *dest, gfx_entry *src, int x, int y, int centerx, int centery, s_drawmethod *drawmethod) @@ -1718,4 +1718,3 @@ void gfx_draw_plane(s_screen *dest, gfx_entry *src, int x, int y, int centerx, i } } - diff --git a/engine/source/gamelib/translation.c b/engine/source/gamelib/translation.c index e5dc3655e..23dc6bbf4 100644 --- a/engine/source/gamelib/translation.c +++ b/engine/source/gamelib/translation.c @@ -100,26 +100,11 @@ static int ob_loadtrans() This operation is needed only if the english translation file uses some custom menu texts for english language too */ if(buffer_pakfile("translation/translation.txt", &buf, &size) != 1) - { - goto default_file; - } - else - { - goto proceed; - } - -default_file: - - if(buffer_pakfile("data/translation.txt", &buf, &size) != 1) - { - return 0; - } - else - { - goto proceed; - } + if(buffer_pakfile("data/translation.txt", &buf, &size) != 1) // if above fails, try other location, too + { + return 0; + } -proceed: //printf("Loading translation table\n"); pos = 0; @@ -240,5 +225,3 @@ char *ob_gettrans(char *id) return (laststr = id); } - - diff --git a/engine/source/gfxlib/interp.h b/engine/source/gfxlib/interp.h index 82a93e82d..a45483da4 100644 --- a/engine/source/gfxlib/interp.h +++ b/engine/source/gfxlib/interp.h @@ -123,8 +123,8 @@ static inline u16 interp_16_97(u16 p1, u16 p2) | INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 9 + INTERP_16_MASK_2(p2) * 7) / 16); } -#define INTERP_32_MASK_1(v) (v & 0xFF00FF) -#define INTERP_32_MASK_2(v) (v & 0x00FF00) +#define INTERP_32_MASK_1(v) ((v) & 0xFF00FF) +#define INTERP_32_MASK_2(v) ((v) & 0x00FF00) static inline u32 interp_32_521(u32 p1, u32 p2, u32 p3) { diff --git a/engine/source/omath.h b/engine/source/omath.h index 2afd9ef03..38e6747e6 100644 --- a/engine/source/omath.h +++ b/engine/source/omath.h @@ -15,8 +15,8 @@ extern float sin_table[]; extern float cos_table[]; -static volatile const double Infinity = INFINITY; -static volatile const double Tiny = 0x1p-1022; +static const double Infinity = INFINITY; +static const double Tiny = 0x1p-1022; // double2 represents a number equal to d0 + d1, with |d1| <= 1/2 ULP(d0). typedef struct { double d0, d1; } double2; diff --git a/engine/source/openborscript/audio.c b/engine/source/openborscript/audio.c index f63ac2308..0843984c9 100644 --- a/engine/source/openborscript/audio.c +++ b/engine/source/openborscript/audio.c @@ -107,7 +107,7 @@ const s_property_access_map music_channel_get_property_map(const void* acting_ob * 2024-01-31 * * Return a property. Requires -* a object pointer and property +* an object pointer and property * constant to access. */ HRESULT openbor_get_music_channel_property(const ScriptVariant* const* varlist, ScriptVariant** const pretvar, const int paramCount) diff --git a/engine/source/openborscript/binding.c b/engine/source/openborscript/binding.c index 11d441603..811d5005d 100644 --- a/engine/source/openborscript/binding.c +++ b/engine/source/openborscript/binding.c @@ -119,7 +119,7 @@ const s_property_access_map bind_get_property_map(const void* acting_object_para * 2023-03-03 * * Return a property. Requires -* a object pointer and property +* an object pointer and property * constant to access. */ HRESULT openbor_get_bind_property(const ScriptVariant* const* varlist, ScriptVariant** const pretvar, const int paramCount) diff --git a/engine/source/openborscript/constants.c b/engine/source/openborscript/constants.c index f3226e677..bba845c15 100644 --- a/engine/source/openborscript/constants.c +++ b/engine/source/openborscript/constants.c @@ -1661,25 +1661,21 @@ int mapstrings_transconst(ScriptVariant **varlist, int paramCount) HRESULT openbor_transconst(ScriptVariant **varlist , ScriptVariant **pretvar, int paramCount) { static char buf[128]; - if(paramCount < 1) + if (paramCount >= 1) { - goto transconst_error; - } + //if(varlist[0]->vt == VT_INTEGER) printf("debug: mapstring for openborconstant works!\n"); - //if(varlist[0]->vt == VT_INTEGER) printf("debug: mapstring for openborconstant works!\n"); + mapstrings_transconst(varlist, paramCount); - mapstrings_transconst(varlist, paramCount); - - if(varlist[0]->vt == VT_INTEGER) // return value already determined by mapstrings - { - ScriptVariant_Copy((*pretvar), varlist[0]); - return S_OK; + if (varlist[0]->vt == VT_INTEGER) // return value already determined by mapstrings + { + ScriptVariant_Copy((*pretvar), varlist[0]); + return S_OK; + } } -transconst_error: ScriptVariant_ToString(varlist[0], buf); printf("Can't translate constant %s\n", buf); *pretvar = NULL; return E_FAIL; } - diff --git a/engine/source/openborscript/string.c b/engine/source/openborscript/string.c index 90ebe8744..34c03080a 100644 --- a/engine/source/openborscript/string.c +++ b/engine/source/openborscript/string.c @@ -120,16 +120,13 @@ HRESULT openbor_strleft(ScriptVariant **varlist , ScriptVariant **pretvar, int p //strlength(char string); HRESULT openbor_strlength(ScriptVariant **varlist , ScriptVariant **pretvar, int paramCount) { - if(paramCount < 1 || varlist[0]->vt != VT_STR) + if(paramCount >= 1 && varlist[0]->vt == VT_STR) { - goto strlength_error; + ScriptVariant_ChangeType(*pretvar, VT_INTEGER); + (*pretvar)->lVal = strlen((char*)StrCache_Get(varlist[0]->strVal)); + return S_OK; } - ScriptVariant_ChangeType(*pretvar, VT_INTEGER); - (*pretvar)->lVal = strlen((char *)StrCache_Get(varlist[0]->strVal)); - return S_OK; - -strlength_error: printf("Error, strlength({string}): Invalid or missing parameter. Strlength must be passed a valid {string}.\n"); *pretvar = NULL; return E_FAIL; @@ -139,17 +136,14 @@ HRESULT openbor_strlength(ScriptVariant **varlist , ScriptVariant **pretvar, int HRESULT openbor_strwidth(ScriptVariant **varlist , ScriptVariant **pretvar, int paramCount) { LONG ltemp; - if(paramCount < 2 || varlist[0]->vt != VT_STR || - FAILED(ScriptVariant_IntegerValue(varlist[1], <emp))) + if(paramCount >= 2 && varlist[0]->vt == VT_STR && + SUCCEEDED(ScriptVariant_IntegerValue(varlist[1], <emp))) { - goto strwidth_error; + ScriptVariant_ChangeType(*pretvar, VT_INTEGER); + (*pretvar)->lVal = font_string_width((int)ltemp, (char*)StrCache_Get(varlist[0]->strVal)); + return S_OK; } - ScriptVariant_ChangeType(*pretvar, VT_INTEGER); - (*pretvar)->lVal = font_string_width((int)ltemp, (char *)StrCache_Get(varlist[0]->strVal)); - return S_OK; - -strwidth_error: printf("Error, strwidth({string}, {font}): Invalid or missing parameter.\n"); *pretvar = NULL; return E_FAIL; diff --git a/engine/source/safealloc.h b/engine/source/safealloc.h index be169509c..d379c0eb2 100644 --- a/engine/source/safealloc.h +++ b/engine/source/safealloc.h @@ -14,7 +14,11 @@ #include "utils.h" // for checkAlloc #undef strdup +#ifndef _MSC_VER #define MALLOCLIKE __attribute__((__malloc__)) +#else +#define MALLOCLIKE +#endif static inline void *safeRealloc(void *ptr, size_t size, const char *func, const char *file, int line) { diff --git a/engine/source/scriptlib/Interpreter.c b/engine/source/scriptlib/Interpreter.c index b237ada44..2351fc422 100644 --- a/engine/source/scriptlib/Interpreter.c +++ b/engine/source/scriptlib/Interpreter.c @@ -529,7 +529,7 @@ HRESULT Interpreter_CompileInstructions(Interpreter *pinterpreter) COMPILEUNARYOP; break; - //Use the BINARYOP macro to do a multipy + //Use the BINARYOP macro to do a multiply case MUL: //Use the BINARYOP macro to do a divide case DIV: @@ -539,7 +539,7 @@ HRESULT Interpreter_CompileInstructions(Interpreter *pinterpreter) case ADD: //Use the BINARYOP macro to do a subtract case SUB: - //Use the BINARYOP macro to do an left shift + //Use the BINARYOP macro to do a left shift case SHL: //Use the BINARYOP macro to do a right shift case SHR: @@ -573,7 +573,7 @@ HRESULT Interpreter_CompileInstructions(Interpreter *pinterpreter) //Create a new CSymbol and add it to the symbol table case PARAM: - Instruction_NewData(pInstruction); //cache the the new variant + Instruction_NewData(pInstruction); //cache the new variant pToken = pInstruction->theToken; pSymbol = (Symbol *)malloc(sizeof(Symbol)); Symbol_Init(pSymbol, pToken->theSource, 0, NULL, pInstruction); diff --git a/engine/source/stringptr.c b/engine/source/stringptr.c index d424f2141..ebf4f0444 100644 --- a/engine/source/stringptr.c +++ b/engine/source/stringptr.c @@ -7,7 +7,6 @@ */ #include "stringptr.h" -#include #include stringptr *new_string(size_t size) diff --git a/engine/source/tracelib2/tracelib2.c b/engine/source/tracelib2/tracelib2.c index 97c412e1d..4b491b927 100644 --- a/engine/source/tracelib2/tracelib2.c +++ b/engine/source/tracelib2/tracelib2.c @@ -54,7 +54,7 @@ void *tlmalloc(int line, char *file, size_t size) tlInfo *mem = NULL; if(!size) { - fprintf(stderr, "tried to nallocate memory with size 0, called from %s:%d\n", file, line); + fprintf(stderr, "tried to allocate memory with size 0, called from %s:%d\n", file, line); return NULL; } mem = malloc(size + sizeof(tlInfo)); diff --git a/engine/source/utils.c b/engine/source/utils.c index 2fcac57db..80b5eca79 100644 --- a/engine/source/utils.c +++ b/engine/source/utils.c @@ -487,8 +487,8 @@ char* multistrcatsp(char* buf, ...) char* safe_strncpy(char* dst, const char* src, size_t size) { if (size > 0) { - register char *d = dst; - register const char *s = src; + char *d = dst; + const char *s = src; do { if ((*d++ = *s++) == 0) { diff --git a/engine/source/webmlib/yuv.c b/engine/source/webmlib/yuv.c index 911ba0713..9b474fa11 100644 --- a/engine/source/webmlib/yuv.c +++ b/engine/source/webmlib/yuv.c @@ -269,7 +269,7 @@ static void Color16DitherYV12Mod1X( unsigned char *lum, unsigned char *cr, x = cols_2; while( x-- ) { - register int L; + int L; cr_r = 0*768+256 + colortab[ *cr + 0*256 ]; crb_g = 1*768+256 + colortab[ *cr + 1*256 ] @@ -338,7 +338,7 @@ static void Color32DitherYV12Mod1X( unsigned char *lum, unsigned char *cr, x = cols_2; while( x-- ) { - register int L; + int L; cr_r = 0*768+256 + colortab[ *cr + 0*256 ]; crb_g = 1*768+256 + colortab[ *cr + 1*256 ] diff --git a/tools/win-sdk.7z b/tools/win-sdk.7z deleted file mode 100644 index cb88e6d38..000000000 Binary files a/tools/win-sdk.7z and /dev/null differ