From d614b8f3b6cf5cf0975d2a923fabca2ea91fbf6a Mon Sep 17 00:00:00 2001 From: hypov8 Date: Sun, 14 Apr 2024 15:15:04 +1000 Subject: [PATCH] fix kaas compiler errors removed kaas prefix renamed kaas vector names to suit kpq3 naming updated wep lerp hmg timmer changed fixed team bonus crash. in dm added HD suport for md3 vertex position(dynamic grid) --- code/botlib/be_aas_cluster.h | 6 +- code/botlib/be_aas_def.h | 4 +- code/botlib/be_aas_entity.h | 2 +- code/botlib/be_aas_funcs.h | 2 +- code/botlib/be_aas_reach.cc | 4 +- code/botlib/be_aas_sample.cc | 5 +- code/botlib/l_memory.h | 8 +- code/botlib/l_precomp.cc | 7 +- code/cgame/cg_event.c | 9 +- code/cgame/cg_playerstate.c | 42 ++++---- code/cgame/cg_weapons.c | 85 +++++++++------- code/game/ai_dmq3.c | 3 +- code/game/bg_misc.c | 4 +- code/game/bg_pmove.c | 61 ++++++----- code/game/bg_public.h | 9 +- code/game/g_active.c | 5 +- code/game/g_combat.c | 2 +- code/kaas/aas_areamerging.c | 4 +- code/kaas/aas_create.c | 30 +++--- code/kaas/aas_file.c | 2 +- code/kaas/aas_gsubdiv.c | 16 +-- code/kaas/aas_map.c | 32 +++--- code/kaas/aas_store.c | 58 +++++++---- code/kaas/be_aas_bspc.c | 12 +-- code/kaas/be_aas_bspc.h | 2 +- code/kaas/brushbsp.c | 22 ++-- code/kaas/bspc.c | 2 +- code/kaas/csg.c | 10 +- code/kaas/kaas.vcxproj | 32 ++++-- code/kaas/l_bsp_q3.c | 37 ++++--- code/kaas/l_cmd.c | 4 +- code/kaas/l_math.c | 4 +- code/kaas/l_math.h | 9 +- code/kaas/l_mem.c | 43 ++++---- code/kaas/l_mem.h | 22 +--- code/kaas/l_poly.c | 185 ++++++++++++++++------------------ code/kaas/l_poly.h | 20 ++-- code/kaas/l_qfiles.c | 1 - code/kaas/l_qfiles.h | 1 + code/kaas/l_utils.h | 30 +++++- code/kaas/leakfile.c | 1 - code/kaas/map.c | 36 +++---- code/kaas/map_q3.c | 4 +- code/kaas/portals.c | 10 +- code/kaas/qbsp.h | 7 -- code/kaas/textures.c | 10 +- code/kaas/tree.c | 2 +- code/qcommon/cm_load.cc | 2 - code/qcommon/cm_local.h | 7 +- code/qcommon/cm_patch.cc | 24 +++-- code/qcommon/cm_polylib.h | 7 +- code/qcommon/q_platform.h | 3 +- code/qcommon/q_shared.h | 42 +------- code/qcommon/qcommon.h | 4 +- code/qcommon/qfiles.h | 14 +-- code/renderer/tr_init.cc | 4 +- code/renderer/tr_model_md3.cc | 58 ++++++++++- kmap2/common/qfiles.h | 2 +- 58 files changed, 580 insertions(+), 493 deletions(-) diff --git a/code/botlib/be_aas_cluster.h b/code/botlib/be_aas_cluster.h index 0cf931b..3b27415 100644 --- a/code/botlib/be_aas_cluster.h +++ b/code/botlib/be_aas_cluster.h @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * $Archive: /source/code/botlib/be_aas_cluster.h $ * *****************************************************************************/ -#ifndef BE_AAS_CLUSTER_H_ +#ifndef BE_AAS_CLUSTER_H_ #define BE_AAS_CLUSTER_H_ #ifdef AASINTERN //initialize the AAS clustering @@ -38,5 +38,5 @@ void AAS_InitClustering(void); void AAS_SetViewPortalsAsClusterPortals(void); #endif //AASINTERN void AAS_InitClustering(void); -#endif - +#endif + diff --git a/code/botlib/be_aas_def.h b/code/botlib/be_aas_def.h index a0e4cc8..4454198 100644 --- a/code/botlib/be_aas_def.h +++ b/code/botlib/be_aas_def.h @@ -204,8 +204,8 @@ typedef struct aas_s float time; int numframes; //name of the aas file - char filename[MAX_PATH]; - char mapname[MAX_PATH]; + char *filename; // [MAX_PATH]; + char *mapname; // [MAX_PATH]; //bounding boxes int numbboxes; aas_bbox_t *bboxes; diff --git a/code/botlib/be_aas_entity.h b/code/botlib/be_aas_entity.h index 6a6b08c..42c1ea0 100644 --- a/code/botlib/be_aas_entity.h +++ b/code/botlib/be_aas_entity.h @@ -38,7 +38,7 @@ void AAS_UnlinkInvalidEntities(void); //resets the entity AAS and BSP links (sets areas and leaves pointers to NULL) void AAS_ResetEntityLinks(void); //updates an entity -#ifndef BSPC +#if 1 //ndef BSPC int AAS_UpdateEntity(int ent, bot_entitystate_t *state); //gives the entity data used for collision detection void AAS_EntityBSPData(int entnum, bsp_entdata_t *entdata); diff --git a/code/botlib/be_aas_funcs.h b/code/botlib/be_aas_funcs.h index a7e5d10..7cfcbb2 100644 --- a/code/botlib/be_aas_funcs.h +++ b/code/botlib/be_aas_funcs.h @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#if 1 //ndef BSPCINCLUDE +#ifndef BSPCINCLUDE #include "be_aas_main.h" #include "be_aas_entity.h" diff --git a/code/botlib/be_aas_reach.cc b/code/botlib/be_aas_reach.cc index 633254a..fb63022 100644 --- a/code/botlib/be_aas_reach.cc +++ b/code/botlib/be_aas_reach.cc @@ -3593,7 +3593,7 @@ void AAS_Reachability_JumpPad(void) botimport.Print(PRT_MESSAGE, "absmaxs = %f %f %f\n", absmaxs[0], absmaxs[1], absmaxs[2]); #endif REACH_DEBUG VectorAdd(absmins, absmaxs, origin); - Vec3_Scale (origin, 0.5, origin); + VectorScale (origin, 0.5, origin); //get the start areas VectorCopy(origin, teststart); @@ -3635,7 +3635,7 @@ void AAS_Reachability_JumpPad(void) continue; } //end if // set s.origin2 to the push velocity - Vec3_Subtract ( ent2origin, origin, velocity); + VectorSubtract ( ent2origin, origin, velocity); dist = VectorNormalize( velocity); forward = dist / time; //FIXME: why multiply by 1.1 diff --git a/code/botlib/be_aas_sample.cc b/code/botlib/be_aas_sample.cc index 038b149..dc4fc6f 100644 --- a/code/botlib/be_aas_sample.cc +++ b/code/botlib/be_aas_sample.cc @@ -971,7 +971,7 @@ qboolean AAS_InsideFace(aas_face_t *face, vec3_t pnormal, vec3_t point, float ep //this is done by checking the sign of the dot product of the //vector orthogonal vector from above and the vector from the //origin (first vertex of edge) to the point - //if the Vec3_DotProduct is smaller than zero the point is outside the face + //if the DotProduct is smaller than zero the point is outside the face if (DotProduct(pointvec, sepnormal) < -epsilon) return qfalse; } //end for return qtrue; @@ -1395,7 +1395,8 @@ int AAS_AreaInfo( int areanum, aas_areainfo_t *info ) //=========================================================================== aas_plane_t *AAS_PlaneFromNum(int planenum) { - if (!aasworld.loaded) return NULL; + if (!aasworld.loaded) + return NULL; return &aasworld.planes[planenum]; } //end of the function AAS_PlaneFromNum diff --git a/code/botlib/l_memory.h b/code/botlib/l_memory.h index 51a05c8..82aa02a 100644 --- a/code/botlib/l_memory.h +++ b/code/botlib/l_memory.h @@ -52,10 +52,14 @@ void *GetHunkMemoryDebug(unsigned long size, char *label, char *file, int line); void *GetClearedHunkMemoryDebug(unsigned long size, char *label, char *file, int line); #else -// #ifdef BSPC +//allocate a memory block of the given size +void *GetMemory(size_t size); +//allocate a memory block of the given size and clear it +void *GetClearedMemory(size_t size); +// #define GetHunkMemory GetMemory -//#define GetClearedHunkMemory GetClearedMemory +#define GetClearedHunkMemory GetClearedMemory #else //allocate a memory block of the given size void *GetMemory(unsigned long size); diff --git a/code/botlib/l_precomp.cc b/code/botlib/l_precomp.cc index 9e48cab..c217933 100644 --- a/code/botlib/l_precomp.cc +++ b/code/botlib/l_precomp.cc @@ -81,12 +81,7 @@ typedef enum {qfalse, qtrue} qboolean; #include "../kaas/qbsp.h" #include "../kaas/l_log.h" #include "../kaas/l_mem.h" -/////////////#include "../kaas/be_aas_bspc.h" #include "../botlib/l_precomp.h" -//#include "../botlib/l_utils.h" //hypov8 add -//#include "../qcommon/q_shared.h" - -#include "../botlib/be_aas_main.h" //typedef enum {qfalse, qtrue} qboolean; //#define qtrue true @@ -1040,7 +1035,7 @@ int PC_Directive_include(source_t *source) { script_t *script; token_t token; - char path[MAX_PATH] = ""; + char path[2*MAX_PATH] = ""; #ifdef QUAKE foundfile_t file; #endif //QUAKE diff --git a/code/cgame/cg_event.c b/code/cgame/cg_event.c index 7d01bd9..6d07f26 100644 --- a/code/cgame/cg_event.c +++ b/code/cgame/cg_event.c @@ -944,14 +944,17 @@ void CG_EntityEvent(centity_t *cent, vec3_t position) DEBUGNAME("EV_FIRE_SHOTGUN"); CG_FireWeapon(cent, qfalse); break; - case EV_FIRE_SPISTOL: + case EV_FIRE_SPISTOL: DEBUGNAME("EV_FIRE_SPISTOL"); CG_FireWeapon(cent, qtrue); break; - case EV_FIRE_HMG_SHOT: //hypov8 todo: cleanup. not used anymore + /*case EV_FIRE_HMG_SHOT: //hypov8 todo: cleanup. not used anymore DEBUGNAME("EV_FIRE_HMG_SHOT"); CG_FireWeapon(cent, qfalse); - break; + break;*/ + /*case EV_FIRE_COOLDOWN: + //todo + break;*/ case EV_RELOAD_WEAPON: DEBUGNAME("EV_RELOAD_WEAPON"); CG_ReloadWeapon(cent); diff --git a/code/cgame/cg_playerstate.c b/code/cgame/cg_playerstate.c index ef5c4f6..9cf7c5f 100644 --- a/code/cgame/cg_playerstate.c +++ b/code/cgame/cg_playerstate.c @@ -190,27 +190,27 @@ hypov8 view recoil for 1st person */ void CG_ShootFeedback(int weaponUsed) { - float kick; - int timeAdd; - - switch (weaponUsed) - { - case WP_CROWBAR: timeAdd = WP_TIME_FIRE_CROWBAR / 2; kick = 1; break; - case WP_PISTOL: timeAdd = WP_TIME_FIRE_PISTOL / 2; kick = 2.5; break; - case WP_SHOTGUN: timeAdd = WP_TIME_FIRE_SHOTGUN / 2; kick = 4; break; - case WP_MACHINEGUN: timeAdd = WP_TIME_FIRE_MACHINEGUN / 2; kick = 0.5f; break; - case WP_GRENADE_LAUNCHER: timeAdd = WP_TIME_FIRE_GRENADE_LAUNCHER / 2; kick = 5; break; - case WP_ROCKET_LAUNCHER: timeAdd = WP_TIME_FIRE_ROCKET_LAUNCHER / 2; kick = 5; break; - case WP_HMG: timeAdd = WP_TIME_FIRE_HMG /2; kick = 1.5; break; - case WP_FLAMER: timeAdd = WP_TIME_FIRE_FLAMEGUN / 2; kick = 0.2f; break; - default: timeAdd = 0; kick = 0; break; - } - - cg.v_dmg_roll = (float)(((rand() / (float)RAND_MAX) * 1.0 - 0.5)); - cg.v_dmg_pitch = -kick; - cg.v_dmg_time = cg.time + timeAdd; - - cg.damageTime = cg.snap->serverTime; + float kick; + int timeAdd; + + switch (weaponUsed) + { + case WP_CROWBAR: timeAdd = WP_TIME_FIRE_CROWBAR / 2; kick = 1; break; + case WP_PISTOL: timeAdd = WP_TIME_FIRE_PISTOL / 2; kick = 2.5; break; + case WP_SHOTGUN: timeAdd = WP_TIME_FIRE_SHOTGUN / 2; kick = 4; break; + case WP_MACHINEGUN: timeAdd = WP_TIME_FIRE_MACHINEGUN / 2; kick = 0.5f; break; + case WP_GRENADE_LAUNCHER: timeAdd = WP_TIME_FIRE_GRENADE_LAUNCHER / 2; kick = 5; break; + case WP_ROCKET_LAUNCHER: timeAdd = WP_TIME_FIRE_ROCKET_LAUNCHER / 2; kick = 5; break; + case WP_HMG: timeAdd = WP_TIME_FIRE_HMG_3RD / 3; kick = 1.5; break; + case WP_FLAMER: timeAdd = WP_TIME_FIRE_FLAMEGUN / 2; kick = 0.2f; break; + default: timeAdd = 0; kick = 0; break; + } + + cg.v_dmg_roll = (float)(((rand() / (float)RAND_MAX) * 1.0 - 0.5)); + cg.v_dmg_pitch = -kick; + cg.v_dmg_time = cg.time + timeAdd; + + cg.damageTime = cg.snap->serverTime; } diff --git a/code/cgame/cg_weapons.c b/code/cgame/cg_weapons.c index 0d8aa1e..db81f7c 100644 --- a/code/cgame/cg_weapons.c +++ b/code/cgame/cg_weapons.c @@ -695,7 +695,7 @@ static int CG_WeaponFireTimeOffset(int weaponIndex) case WP_ROCKET_LAUNCHER: return WP_TIME_FIRE_ROCKET_LAUNCHER; case WP_HMG: - return WP_TIME_FIRE_HMG_LAST; + return WP_TIME_FIRE_HMG_FULL; #ifdef USE_FLAMEGUN case WP_FLAMER: return WP_TIME_FIRE_FLAMEGUN; @@ -704,6 +704,18 @@ static int CG_WeaponFireTimeOffset(int weaponIndex) return WP_TIME_FIRE_GRAPPLING_HOOK; } } +// +/*static int CG_WeaponFireTimeOffset_mod(int weaponIndex) +{ + switch (weaponIndex) + { + case WP_HMG: + return WP_TIME_FIRE_HMG_LAST; + + default: + return WP_TIME_RELOAD_PISTOL; + } +}*/ /* ================ @@ -757,12 +769,12 @@ static qboolean CG_ParseWeaponAnimationFile(const char *filename, animation_t *a float fps; char text[1024]; fileHandle_t f; - int maxWepStates = WEAPON_RELOAD_MOD; + int maxWepStates = MAX_WEAPON_STATES; - if ( weaponNum == WP_SHOTGUN || weaponNum == WP_CROWBAR ) - maxWepStates = MAX_WEAPON_STATES; //hypov8 todo: add WEAPON_MOD to all animation.cfg + //if ( weaponNum == WP_SHOTGUN || weaponNum == WP_CROWBAR ) + // maxWepStates = MAX_WEAPON_STATES; //hypov8 todo: add WEAPON_MOD to all animation.cfg - Com_Memset(animations, 0, sizeof(animation_t) * MAX_WEAPON_STATES); + Com_Memset(animations, 0, sizeof(animation_t) * maxWepStates); if (cg_debugWeaponAnim.integer) Com_Printf("loading animation file: %s\n", filename); @@ -827,42 +839,41 @@ static qboolean CG_ParseWeaponAnimationFile(const char *filename, animation_t *a fps = 15; } - //add hypov8 sync animation using a #defined total animation time in engine, not animation.cfg - //this allows the complete animation sequence to run in the set timeframe - if (ws == WEAPON_RELOADING && animations[ws].numFrames > 0) - { - animations[ws].frameLerp = floor(CG_WeaponReloadTimeOffset(weaponNum) / animations[ws].numFrames); - animations[ws].initialLerp = floor(CG_WeaponReloadTimeOffset(weaponNum) / animations[ws].numFrames); - } - else if (ws == WEAPON_RELOAD_MOD && animations[ws].numFrames > 0) - { - animations[ws].frameLerp = floor(CG_WeaponModTimeOffset(weaponNum) / animations[ws].numFrames); - animations[ws].initialLerp = floor(CG_WeaponModTimeOffset(weaponNum) / animations[ws].numFrames); - } - else if (ws == WEAPON_FIRING && animations[ws].numFrames > 0) - { - if (animations[ws].loopFrames == 0) + //add hypov8 sync animation using a #defined total animation time in engine, not animation.cfg + //this allows the complete animation sequence to run in the set timeframe + if (ws == WEAPON_RELOADING && animations[ws].numFrames > 0) { - animations[ws].frameLerp = floor(CG_WeaponFireTimeOffset(weaponNum) / animations[ws].numFrames); - animations[ws].initialLerp = floor(CG_WeaponFireTimeOffset(weaponNum) / animations[ws].numFrames); + animations[ws].frameLerp = floor(CG_WeaponReloadTimeOffset(weaponNum) / animations[ws].numFrames); + animations[ws].initialLerp = floor(CG_WeaponReloadTimeOffset(weaponNum) / animations[ws].numFrames); } - else //hypov8 allow looping. use fps. adds variance to fast fire weapons (tommy/flamer) + else if (ws == WEAPON_RELOAD_MOD && animations[ws].numFrames > 0) { - animations[ws].frameLerp = 1000 / fps; + animations[ws].frameLerp = floor(CG_WeaponModTimeOffset(weaponNum) / animations[ws].numFrames); + animations[ws].initialLerp = floor(CG_WeaponModTimeOffset(weaponNum) / animations[ws].numFrames); + } + else if (ws == WEAPON_FIRING && animations[ws].numFrames > 0) + { + if (animations[ws].loopFrames == 0) + { + animations[ws].frameLerp = floor(CG_WeaponFireTimeOffset(weaponNum) / animations[ws].numFrames); + animations[ws].initialLerp = floor(CG_WeaponFireTimeOffset(weaponNum) / animations[ws].numFrames); + } + else //hypov8 allow looping. use fps. adds variance to fast fire weapons (tommy/flamer) + { + animations[ws].frameLerp = 1000 / fps; + animations[ws].initialLerp = 1000 / fps; + } + } + else if ((ws == WEAPON_DROPPING || ws == WEAPON_RAISING) && animations[ws].numFrames > 0) + { + animations[ws].frameLerp = floor(CG_WeaponChangeTimeOffset(weaponNum) / animations[ws].numFrames); + animations[ws].initialLerp = floor(CG_WeaponChangeTimeOffset(weaponNum) / animations[ws].numFrames); + } + else //WEAPON_READY + { + animations[ws].frameLerp = 1000 / fps; animations[ws].initialLerp = 1000 / fps; } - } - else if ((ws == WEAPON_DROPPING || ws == WEAPON_RAISING) && animations[ws].numFrames > 0) - { - animations[ws].frameLerp = floor(CG_WeaponChangeTimeOffset(weaponNum) / animations[ws].numFrames); - animations[ws].initialLerp = floor(CG_WeaponChangeTimeOffset(weaponNum) / animations[ws].numFrames); - } - else //WEAPON_READY - { - animations[ws].frameLerp = 1000 / fps; - animations[ws].initialLerp = 1000 / fps; - } - if (cg_debugWeaponAnim.integer) Com_Printf(S_COLOR_WHITE"Mode %d: %d %d %d %f\n", ws, animations[ws].firstFrame, animations[ws].numFrames, animations[ws].loopFrames , fps ); @@ -1383,7 +1394,7 @@ static int CG_MapTorsoToWeaponFrame(clientInfo_t *ci, int frame, int anim, int w } else if (anim == TORSO_RAISE && frame < 9) { - return frame + weapon->animations[WEAPON_RAISING].firstFrame;; + return frame + weapon->animations[WEAPON_RAISING].firstFrame; } else if ((anim == TORSO_ATTACK || anim == TORSO_ATTACK2 || anim == TORSO_ATTACK3)) // stand attack { diff --git a/code/game/ai_dmq3.c b/code/game/ai_dmq3.c index 57b28ab..dabfe22 100644 --- a/code/game/ai_dmq3.c +++ b/code/game/ai_dmq3.c @@ -6334,7 +6334,8 @@ void BotCheckEvents(bot_state_t *bs, entityState_t *state) //FIXME: either add to sound queue or mark player as someone making noise case EV_FIRE_SHOTGUN:// add hypov8 case EV_FIRE_SPISTOL: //add hypov8 - case EV_FIRE_HMG_SHOT: + //case EV_FIRE_HMG_SHOT: + //case EV_FIRE_COOLDOWN: break; case EV_USE_ITEM0: case EV_USE_ITEM1: diff --git a/code/game/bg_misc.c b/code/game/bg_misc.c index 3011786..be69995 100644 --- a/code/game/bg_misc.c +++ b/code/game/bg_misc.c @@ -135,10 +135,10 @@ gitem_t bg_itemlist[] = "", // precache "" // sounds }, - +//hypov8: not loading? also add reload mod? /*QUAKED item_health_mega (.3 .3 1) (-16 -16 -16) (16 16 16) suspended 5 */ { - "item_health_mega", + "item_health_mega", "sound/world/pickups/health.ogg", /* 0xA5EA */ { "models/pu_icon/adrenaline/tris.md3", diff --git a/code/game/bg_pmove.c b/code/game/bg_pmove.c index 09e0289..e8622d0 100644 --- a/code/game/bg_pmove.c +++ b/code/game/bg_pmove.c @@ -2328,7 +2328,7 @@ PM_WeaponFireTimeOffset */ static int PM_WeaponFireTimeOffset(int weapon, qboolean hmgLastBullet) { - switch (pm->ps->weapon) + switch (weapon) //pm->ps->weapon) { default: case WP_CROWBAR: @@ -2347,12 +2347,14 @@ static int PM_WeaponFireTimeOffset(int weapon, qboolean hmgLastBullet) return WP_TIME_FIRE_ROCKET_LAUNCHER; // 0xA5EA case WP_HMG: if (hmgLastBullet) + { if (pm->ps->stats[STAT_WEAP_MODS] & (1 << PW_WPMOD_COOLING)) - return (int)(WP_TIME_FIRE_HMG_LAST / 2); + return WP_TIME_FIRE_HMG_3RD; else - return WP_TIME_FIRE_HMG_LAST; + return WP_TIME_FIRE_HMG_3RD * 2; + } else - return WP_TIME_FIRE_HMG; + return (int)(WP_TIME_FIRE_HMG_3RD/3.0f); #ifdef USE_FLAMEGUN case WP_FLAMER: @@ -2373,6 +2375,7 @@ static void PM_Weapon(void) { int addTime = 200; //default addTime - should never be used qboolean attack1 = ( pm->cmd.buttons & BUTTON_ATTACK ); + qboolean wepCoolDown = qfalse; //hmg cooldown // Ignore weapons in some cases if (pm->ps->persistant[PERS_TEAM] == TEAM_SPECTATOR) @@ -2557,9 +2560,11 @@ static void PM_Weapon(void) // fire events for non auto weapons if ( attack1 || (pm->ps->hmgBulletNum && pm->ps->weapon == WP_HMG)) { - if ( pm->ps->weapon == WP_PISTOL && pm->ps->stats[ STAT_WEAP_MODS ] & ( 1 << PW_WPMOD_SILENCER ) ) + if (pm->ps->weapon == WP_PISTOL && pm->ps->stats[STAT_WEAP_MODS] & (1 << PW_WPMOD_SILENCER)) PM_AddEvent(EV_FIRE_SPISTOL); - else + else if (!(pm->ps->hmgBulletNum == 3 && pm->ps->weapon == WP_HMG)) //dont shoot for cooldown + /* PM_AddEvent(EV_FIRE_COOLDOWN); + else*/ PM_AddEvent(EV_FIRE_WEAPON); } else @@ -2600,30 +2605,38 @@ static void PM_Weapon(void) PM_StartTorsoAnim(BG_AttackTorsoAnim(pm->ps->weapon)); if (pm->ps->hmgBulletNum == 0) { - pm->ps->hmgBulletNum = 1; + pm->ps->hmgBulletNum = 1; //#1 addTime = PM_WeaponFireTimeOffset(pm->ps->weapon, qfalse); + PM_StartWeaponAnim(WEAPON_FIRING); } else if (pm->ps->hmgBulletNum == 1) { - pm->ps->hmgBulletNum = 2; + pm->ps->hmgBulletNum = 2; //#2 addTime = PM_WeaponFireTimeOffset(pm->ps->weapon, qfalse); + PM_ContinueWeaponAnim(WEAPON_FIRING); } else if (pm->ps->hmgBulletNum == 2) { - pm->ps->hmgBulletNum = 0; + pm->ps->hmgBulletNum = 3; //#3 + addTime = PM_WeaponFireTimeOffset(pm->ps->weapon, qfalse); + PM_ContinueWeaponAnim(WEAPON_FIRING); + } + else if (pm->ps->hmgBulletNum == 3) + { + wepCoolDown = true; + pm->ps->hmgBulletNum = 0; //cooldown addTime = PM_WeaponFireTimeOffset(pm->ps->weapon, qtrue); + PM_ContinueWeaponAnim(WEAPON_FIRING); } - break; default: - //case WP_SHOTGUN: PM_StartTorsoAnim(BG_AttackTorsoAnim(pm->ps->weapon)); addTime = PM_WeaponFireTimeOffset(pm->ps->weapon, qfalse); break; } - if (pm->ps->weapon != WP_CROWBAR) + if (pm->ps->weapon != WP_CROWBAR && pm->ps->weapon != WP_HMG) { //cycle animation using fps in animation.cfg if (pm->ps->weapon == WP_FLAMER || pm->ps->weapon == WP_MACHINEGUN ) PM_ContinueWeaponAnim(WEAPON_FIRING); @@ -2634,19 +2647,21 @@ static void PM_Weapon(void) pm->ps->weaponstate = WEAPON_FIRING; - //make view bob with bullet recoil - pm->ps->viewShootBob++; - if ( pm->ps->viewShootBob > 255 ) - pm->ps->viewShootBob = 1; - - // take an ammo away if not infinite - if (pm->ps->ammo_mag[pm->ps->weapon] != INFINITE_AMMO) + if (!wepCoolDown) { - pm->ps->ammo_mag[pm->ps->weapon]--; - if (pm->ps->ammo_mag[pm->ps->weapon] < 0) - pm->ps->ammo_mag[pm->ps->weapon] = 0; - } + //make view bob with bullet recoil + pm->ps->viewShootBob++; + if (pm->ps->viewShootBob > 255) + pm->ps->viewShootBob = 1; + // take an ammo away if not infinite + if (pm->ps->ammo_mag[pm->ps->weapon] != INFINITE_AMMO) + { + pm->ps->ammo_mag[pm->ps->weapon]--; + if (pm->ps->ammo_mag[pm->ps->weapon] < 0) + pm->ps->ammo_mag[pm->ps->weapon] = 0; + } + } pm->ps->weaponTime += addTime; //+ } diff --git a/code/game/bg_public.h b/code/game/bg_public.h index 5e6bb00..7078f46 100644 --- a/code/game/bg_public.h +++ b/code/game/bg_public.h @@ -243,6 +243,7 @@ typedef enum WEAPON_FIRING, WEAPON_RELOADING, WEAPON_RELOAD_MOD, //reload shotty mod. + //WEAPON_FIRE_MOD, //cooldown. ROF //hypov8 todo: add silencer, mods etc.. MAX_WEAPON_STATES, WEAPON_HM_LOCK @@ -505,8 +506,8 @@ typedef enum #define WP_TIME_FIRE_MACHINEGUN (1*100) #define WP_TIME_FIRE_GRENADE_LAUNCHER ((4+8)*100) //fire + cycle mag #define WP_TIME_FIRE_ROCKET_LAUNCHER (8*100) -#define WP_TIME_FIRE_HMG (2*100) -#define WP_TIME_FIRE_HMG_LAST (12*100) +#define WP_TIME_FIRE_HMG_FULL (12*100) //anim broken into 1/3 sections(3x shoot, cooldown1, cooldown2) +#define WP_TIME_FIRE_HMG_3RD (int)(WP_TIME_FIRE_HMG_FULL/3) #define WP_TIME_FIRE_FLAMEGUN (1*100) #define WP_TIME_FIRE_GRAPPLING_HOOK (4*100) @@ -520,7 +521,7 @@ typedef enum #define WP_TIME_RELOAD_FLAMEGUN (14*100) //WEAPON_RAISING || WEAPON_DROPPING -#define WP_TIME_CHANGE_GUNS 500 +#define WP_TIME_CHANGE_GUNS 500 //hypov8 note: check mplayer speeds... #define WP_TIME_CHANGE_MELEE 250 //WEAPON_RELOAD_MOD //shotty needs to @@ -639,8 +640,8 @@ typedef enum EV_FIRE_WEAPON, EV_FIRE_SHOTGUN, // add hypov8 EV_FIRE_SPISTOL, //add hypov8 - EV_FIRE_HMG_SHOT, EV_FIRE_CROWBAR, //hypov8 add + //EV_FIRE_COOLDOWN, //hypov8 todo. for weps with speed mods EV_RELOAD_WEAPON, EV_RELOAD_SHOTGUN, // add hypov8 shotgun reload sequence diff --git a/code/game/g_active.c b/code/game/g_active.c index 3b4307a..812ecb4 100644 --- a/code/game/g_active.c +++ b/code/game/g_active.c @@ -691,9 +691,12 @@ void ClientEvents(gentity_t *ent, int oldEventSequence) case EV_FIRE_WEAPON: case EV_FIRE_SHOTGUN: // case EV_FIRE_SPISTOL: //hypov8 - case EV_FIRE_HMG_SHOT: + //case EV_FIRE_HMG_SHOT: FireWeapon(ent); break; + /*case EV_FIRE_COOLDOWN: + //todo + break;*/ case EV_USE_ITEM1: // teleporter // drop flags in CTF diff --git a/code/game/g_combat.c b/code/game/g_combat.c index 35fd812..1706f22 100644 --- a/code/game/g_combat.c +++ b/code/game/g_combat.c @@ -726,7 +726,7 @@ void player_die(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int } // Add team bonuses - if (attacker)// add hypov8 + if (attacker && g_gametype.integer > 0)// add hypov8 { if (self->s.number != attacker->s.number) Team_FragBonuses(self, inflictor, attacker); diff --git a/code/kaas/aas_areamerging.c b/code/kaas/aas_areamerging.c index 9b8e393..8e29c11 100755 --- a/code/kaas/aas_areamerging.c +++ b/code/kaas/aas_areamerging.c @@ -75,12 +75,12 @@ int NonConvex(tmp_face_t *face1, tmp_face_t *face2, int side1, int side2) //check if one of the points of face1 is at the back of the plane of face2 for (i = 0; i < w1->numpoints; i++) { - if (Vec3_DotProduct(plane2->normal, w1->p[i]) - plane2->dist < -CONVEX_EPSILON) return qtrue; + if (DotProduct(plane2->normal, w1->p[i]) - plane2->dist < -CONVEX_EPSILON) return qtrue; } //end for //check if one of the points of face2 is at the back of the plane of face1 for (i = 0; i < w2->numpoints; i++) { - if (Vec3_DotProduct(plane1->normal, w2->p[i]) - plane1->dist < -CONVEX_EPSILON) return qtrue; + if (DotProduct(plane1->normal, w2->p[i]) - plane1->dist < -CONVEX_EPSILON) return qtrue; } //end for return qfalse; diff --git a/code/kaas/aas_create.c b/code/kaas/aas_create.c index c89b486..f6542fb 100644 --- a/code/kaas/aas_create.c +++ b/code/kaas/aas_create.c @@ -209,10 +209,10 @@ int AAS_GapFace(tmp_face_t *tmpface, int side) //if the face is a solid or ground face it can't be a gap if (tmpface->faceflags & (FACE_GROUND | FACE_SOLID)) return 0; - Vec3_Copy(cfg.phys_gravitydirection, invgravity); - Vec3_Inverse(invgravity); + VectorCopy(cfg.phys_gravitydirection, invgravity); + VectorInverse(invgravity); - return (Vec3_DotProduct(invgravity, mapplanes[tmpface->planenum ^ side].normal) > cfg.phys_maxsteepness); + return (DotProduct(invgravity, mapplanes[tmpface->planenum ^ side].normal) > cfg.phys_maxsteepness); } //end of the function AAS_GapFace //=========================================================================== // returns true if the face is a ground face @@ -228,10 +228,10 @@ int AAS_GroundFace(tmp_face_t *tmpface) //must be a solid face if (!(tmpface->faceflags & FACE_SOLID)) return 0; - Vec3_Copy(cfg.phys_gravitydirection, invgravity); - Vec3_Inverse(invgravity); + VectorCopy(cfg.phys_gravitydirection, invgravity); + VectorInverse(invgravity); - return (Vec3_DotProduct(invgravity, mapplanes[tmpface->planenum].normal) > cfg.phys_maxsteepness); + return (DotProduct(invgravity, mapplanes[tmpface->planenum].normal) > cfg.phys_maxsteepness); } //end of the function AAS_GroundFace //=========================================================================== // adds the side of a face to an area @@ -326,11 +326,11 @@ void AAS_CheckArea(tmp_area_t *tmparea) //side of the face the area is on side = face->frontarea != tmparea; WindingCenter(face->winding, wcenter); - Vec3_Add(acenter, wcenter, acenter); + VectorAdd(acenter, wcenter, acenter); n++; } //end for n = 1 / n; - Vec3_Scale(acenter, n, acenter); + VectorScale(acenter, n, acenter); for (face = tmparea->tmpfaces; face; face = face->next[side]) { //side of the face the area is on @@ -346,7 +346,7 @@ void AAS_CheckArea(tmp_area_t *tmparea) plane = &mapplanes[face->planenum ^ side]; - if (Vec3_DotProduct(plane->normal, acenter) - plane->dist < 0) + if (DotProduct(plane->normal, acenter) - plane->dist < 0) { Log_Print("AAS_CheckArea: area %d face %d is flipped\n", tmparea->areanum, face->num); Log_Print("AAS_CheckArea: area %d center is %f %f %f\n", tmparea->areanum, acenter[0], acenter[1], acenter[2]); @@ -383,14 +383,14 @@ void AAS_CheckFaceWindingPlane(tmp_face_t *face) WindingPlane(face->winding, normal, &dist); plane = &mapplanes[face->planenum]; // - sign1 = Vec3_DotProduct(plane->normal, normal); + sign1 = DotProduct(plane->normal, normal); // if (fabs(dist - plane->dist) > 0.4 || fabs(normal[0] - plane->normal[0]) > 0.0001 || fabs(normal[1] - plane->normal[1]) > 0.0001 || fabs(normal[2] - plane->normal[2]) > 0.0001) { - Vec3_Inverse(normal); + VectorInverse(normal); dist = -dist; if (fabs(dist - plane->dist) > 0.4 || fabs(normal[0] - plane->normal[0]) > 0.0001 || @@ -400,7 +400,7 @@ void AAS_CheckFaceWindingPlane(tmp_face_t *face) Log_Write("AAS_CheckFaceWindingPlane: face %d winding plane unequal to face plane\r\n", face->num); // - sign2 = Vec3_DotProduct(plane->normal, normal); + sign2 = DotProduct(plane->normal, normal); if ((sign1 < 0 && sign2 > 0) || (sign1 > 0 && sign2 < 0)) { @@ -465,11 +465,11 @@ void AAS_FlipAreaFaces(tmp_area_t *tmparea) //side of the face the area is on side = face->frontarea != tmparea; WindingCenter(face->winding, wcenter); - Vec3_Add(acenter, wcenter, acenter); + VectorAdd(acenter, wcenter, acenter); n++; } //end for n = 1 / n; - Vec3_Scale(acenter, n, acenter); + VectorScale(acenter, n, acenter); for (face = tmparea->tmpfaces; face; face = face->next[side]) { //side of the face the area is on @@ -477,7 +477,7 @@ void AAS_FlipAreaFaces(tmp_area_t *tmparea) plane = &mapplanes[face->planenum ^ side]; - if (Vec3_DotProduct(plane->normal, acenter) - plane->dist < 0) + if (DotProduct(plane->normal, acenter) - plane->dist < 0) { Log_Print("area %d face %d flipped: front area %d, back area %d\n", tmparea->areanum, face->num, face->frontarea ? face->frontarea->areanum : 0, diff --git a/code/kaas/aas_file.c b/code/kaas/aas_file.c index 422999b..7d7272f 100755 --- a/code/kaas/aas_file.c +++ b/code/kaas/aas_file.c @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "aas_file.h" #include "aas_store.h" #include "aas_create.h" -#include "../botlib/be_aas_main.h" + void QDECL AAS_Error(char *fmt, ...); //#define AAS_Error Error diff --git a/code/kaas/aas_gsubdiv.c b/code/kaas/aas_gsubdiv.c index ee36425..097c512 100755 --- a/code/kaas/aas_gsubdiv.c +++ b/code/kaas/aas_gsubdiv.c @@ -157,7 +157,7 @@ int AAS_TestSplitPlane(tmp_area_t *tmparea, vec3_t normal, float dist, front = back = 0; for (j = 0; j < w->numpoints; j++) { - d = Vec3_DotProduct(w->p[j], normal) - dist; + d = DotProduct(w->p[j], normal) - dist; if (d > d_front) d_front = d; if (d < d_back) d_back = d; @@ -334,8 +334,8 @@ int AAS_FindBestAreaSplitPlane(tmp_area_t *tmparea, vec3_t normal, float *dist) float tmpdist; //get inverse of gravity direction - Vec3_Copy(cfg.phys_gravitydirection, invgravity); - Vec3_Inverse(invgravity); + VectorCopy(cfg.phys_gravitydirection, invgravity); + VectorInverse(invgravity); foundsplitter = qfalse; bestvalue = -999999; @@ -394,7 +394,7 @@ int AAS_FindBestAreaSplitPlane(tmp_area_t *tmparea, vec3_t normal, float *dist) value += epsilonfaces * -1000; if (value > bestvalue) { - Vec3_Copy(tmpnormal, normal); + VectorCopy(tmpnormal, normal); *dist = tmpdist; bestvalue = value; bestepsilonfaces = epsilonfaces; @@ -554,7 +554,7 @@ tmp_node_t *AAS_LadderSubdivideArea_r(tmp_node_t *tmpnode) { plane = &mapplanes[face1->planenum]; //the ladder face plane should be pretty much vertical - if (Vec3_DotProduct(plane->normal, normal) > -0.1) + if (DotProduct(plane->normal, normal) > -0.1) { foundladderface = qtrue; //find lowest point @@ -562,7 +562,7 @@ tmp_node_t *AAS_LadderSubdivideArea_r(tmp_node_t *tmpnode) { if (face1->winding->p[i][2] < lowestpoint[2]) { - Vec3_Copy(face1->winding->p[i], lowestpoint); + VectorCopy(face1->winding->p[i], lowestpoint); } //end if } //end for } //end if @@ -584,7 +584,7 @@ tmp_node_t *AAS_LadderSubdivideArea_r(tmp_node_t *tmpnode) //the ground plane plane = &mapplanes[face1->planenum]; //get the difference between the ground plane and the lowest point - dist = Vec3_DotProduct(plane->normal, lowestpoint) - plane->dist; + dist = DotProduct(plane->normal, lowestpoint) - plane->dist; //if the lowest point is very near one of the ground planes if (dist > -1 && dist < 1) { @@ -592,7 +592,7 @@ tmp_node_t *AAS_LadderSubdivideArea_r(tmp_node_t *tmpnode) } //end if } //end for // - dist = Vec3_DotProduct(normal, lowestpoint); + dist = DotProduct(normal, lowestpoint); planenum = FindFloatPlane(normal, dist); // w = AAS_SplitWinding(tmparea, planenum); diff --git a/code/kaas/aas_map.c b/code/kaas/aas_map.c index a6e4763..c135d7c 100755 --- a/code/kaas/aas_map.c +++ b/code/kaas/aas_map.c @@ -81,9 +81,9 @@ vec_t BoxOriginDistanceFromPlane(vec3_t normal, vec3_t mins, vec3_t maxs, int si else v1[i] = 0; } //end for } //end else - Vec3_Copy(normal, v2); - Vec3_Inverse(v2); - return Vec3_DotProduct(v1, v2); + VectorCopy(normal, v2); + VectorInverse(v2); + return DotProduct(v1, v2); } //end of the function BoxOriginDistanceFromPlane //=========================================================================== // @@ -301,7 +301,7 @@ void AAS_FixMapBrush(mapbrush_t *brush) { if (brush->mins[i] < -MAX_MAP_BOUNDS) { - Vec3_Clear(normal); + VectorClear(normal); normal[i] = -1; dist = MAX_MAP_BOUNDS - 10; planenum = FindFloatPlane(normal, dist); @@ -311,7 +311,7 @@ void AAS_FixMapBrush(mapbrush_t *brush) } //end if if (brush->maxs[i] > MAX_MAP_BOUNDS) { - Vec3_Clear(normal); + VectorClear(normal); normal[i] = 1; dist = MAX_MAP_BOUNDS - 10; planenum = FindFloatPlane(normal, dist); @@ -584,10 +584,10 @@ int AAS_TransformPlane(int planenum, vec3_t origin, vec3_t angles) vec3_t normal; //rotate the node plane - Vec3_Copy(mapplanes[planenum].normal, normal); + VectorCopy(mapplanes[planenum].normal, normal); CreateRotationMatrix(angles, matrix); RotatePoint(normal, matrix); - newdist = mapplanes[planenum].dist + Vec3_DotProduct(normal, origin); + newdist = mapplanes[planenum].dist + DotProduct(normal, origin); return FindFloatPlane(normal, newdist); } //end of the function AAS_TransformPlane //=========================================================================== @@ -605,7 +605,7 @@ void AAS_PositionFuncRotatingBrush(entity_t *mapent, mapbrush_t *brush) side_t *s; spawnflags = FloatForKey(mapent, "spawnflags"); - Vec3_Clear(movedir); + VectorClear(movedir); if (spawnflags & DOOR_X_AXIS) movedir[2] = 1.0; //roll else if (spawnflags & DOOR_Y_AXIS) @@ -615,21 +615,21 @@ void AAS_PositionFuncRotatingBrush(entity_t *mapent, mapbrush_t *brush) // check for reverse rotation if (spawnflags & DOOR_REVERSE) - Vec3_Inverse(movedir); + VectorInverse(movedir); distance = FloatForKey(mapent, "distance"); if (!distance) distance = 90; GetVectorForKey(mapent, "angles", angles); - Vec3_Copy(angles, pos1); - Vec3_MA(angles, -distance, movedir, pos2); + VectorCopy(angles, pos1); + VectorMA(angles, -distance, movedir, pos2); // if it starts open, switch the positions if (spawnflags & DOOR_START_OPEN) { - Vec3_Copy(pos2, angles); - Vec3_Copy(pos1, pos2); - Vec3_Copy(angles, pos1); - Vec3_Inverse(movedir); + VectorCopy(pos2, angles); + VectorCopy(pos1, pos2); + VectorCopy(angles, pos1); + VectorInverse(movedir); } //end if // for (i = 0; i < brush->numsides; i++) @@ -668,7 +668,7 @@ void AAS_PositionBrush(entity_t *mapent, mapbrush_t *brush) { s = &brush->original_sides[i]; newdist = mapplanes[s->planenum].dist + - Vec3_DotProduct(mapplanes[s->planenum].normal, mapent->origin); + DotProduct(mapplanes[s->planenum].normal, mapent->origin); s->planenum = FindFloatPlane(mapplanes[s->planenum].normal, newdist); } //end for } //end if diff --git a/code/kaas/aas_store.c b/code/kaas/aas_store.c index 751fc8e..35ab334 100755 --- a/code/kaas/aas_store.c +++ b/code/kaas/aas_store.c @@ -146,6 +146,15 @@ void AAS_AllocMaxAAS(void) int i; AAS_InitMaxAAS(); +#if 1 //hypov8: changed to pointer to fix debugger not showing values + aasworld.filename = (char *)GetClearedMemory(MAX_PATH * sizeof(char)); + allocatedaasmem += MAX_PATH * sizeof(char); + + aasworld.mapname = (char *)GetClearedMemory(MAX_PATH * sizeof(char)); + allocatedaasmem += MAX_PATH * sizeof(char); +#endif + + //bounding boxes aasworld.numbboxes = 0; aasworld.bboxes = (aas_bbox_t *) GetClearedMemory(max_aas.max_bboxes * sizeof(aas_bbox_t)); @@ -211,14 +220,20 @@ void AAS_AllocMaxAAS(void) aas_planechain = (int *) GetClearedMemory(max_aas.max_planes * sizeof(int)); aas_edgechain = (int *) GetClearedMemory(max_aas.max_edges * sizeof(int)); // - for (i = 0; i < max_aas.max_vertexes; i++) aas_vertexchain[i] = -1; - for (i = 0; i < VERTEX_HASH_SIZE * VERTEX_HASH_SIZE; i++) aas_hashverts[i] = -1; + for (i = 0; i < max_aas.max_vertexes; i++) + aas_vertexchain[i] = -1; + for (i = 0; i < VERTEX_HASH_SIZE * VERTEX_HASH_SIZE; i++) + aas_hashverts[i] = -1; // - for (i = 0; i < max_aas.max_planes; i++) aas_planechain[i] = -1; - for (i = 0; i < PLANE_HASH_SIZE; i++) aas_hashplanes[i] = -1; + for (i = 0; i < max_aas.max_planes; i++) + aas_planechain[i] = -1; + for (i = 0; i < PLANE_HASH_SIZE; i++) + aas_hashplanes[i] = -1; // - for (i = 0; i < max_aas.max_edges; i++) aas_edgechain[i] = -1; - for (i = 0; i < EDGE_HASH_SIZE; i++) aas_hashedges[i] = -1; + for (i = 0; i < max_aas.max_edges; i++) + aas_edgechain[i] = -1; + for (i = 0; i < EDGE_HASH_SIZE; i++) + aas_hashedges[i] = -1; } //end of the function AAS_AllocMaxAAS //=========================================================================== // @@ -391,7 +406,7 @@ qboolean AAS_GetVertex(vec3_t v, int *vnum) { Error("AAS_MAX_VERTEXES = %d", max_aas.max_vertexes); } //end if - Vec3_Copy(vert, aasworld.vertexes[aasworld.numvertexes]); + VectorCopy(vert, aasworld.vertexes[aasworld.numvertexes]); *vnum = aasworld.numvertexes; #ifdef VERTEX_HASHING @@ -696,12 +711,12 @@ qboolean AAS_GetPlane(vec3_t normal, vec_t dist, int *planenum) #ifdef STOREPLANESDOUBLE plane = &aasworld.planes[aasworld.numplanes]; - Vec3_Copy(normal, plane->normal); + VectorCopy(normal, plane->normal); plane->dist = dist; plane->type = (plane+1)->type = PlaneTypeForNormal(plane->normal); - Vec3_Copy(normal, (plane+1)->normal); - Vec3_Negate((plane+1)->normal, (plane+1)->normal); + VectorCopy(normal, (plane+1)->normal); + VectorNegate((plane+1)->normal, (plane+1)->normal); (plane+1)->dist = -dist; aasworld.numplanes += 2; @@ -726,7 +741,7 @@ qboolean AAS_GetPlane(vec3_t normal, vec_t dist, int *planenum) return qfalse; #else plane = &aasworld.planes[aasworld.numplanes]; - Vec3_Copy(normal, plane->normal); + VectorCopy(normal, plane->normal); plane->dist = dist; plane->type = AAS_PlaneTypeForNormal(normal); @@ -931,7 +946,7 @@ int AAS_StoreArea(tmp_area_t *tmparea) aasarea->numfaces = 0; aasarea->firstface = aasworld.faceindexsize; ClearBounds(aasarea->mins, aasarea->maxs); - Vec3_Clear(aasarea->center); + VectorClear(aasarea->center); // // Log_Write("tmparea %d became aasarea %d\r\n", tmparea->areanum, aasarea->areanum); //store the aas area number at the tmp area @@ -977,19 +992,19 @@ int AAS_StoreArea(tmp_area_t *tmparea) } //end else //add face points to the area bounds and //calculate the face 'center' - Vec3_Clear(facecenter); + VectorClear(facecenter); for (edgenum = 0; edgenum < aasface->numedges; edgenum++) { edge = &aasworld.edges[abs(aasworld.edgeindex[aasface->firstedge + edgenum])]; for (i = 0; i < 2; i++) { AddPointToBounds(aasworld.vertexes[edge->v[i]], aasarea->mins, aasarea->maxs); - Vec3_Add(aasworld.vertexes[edge->v[i]], facecenter, facecenter); + VectorAdd(aasworld.vertexes[edge->v[i]], facecenter, facecenter); } //end for } //end for - Vec3_Scale(facecenter, 1.0 / (aasface->numedges * 2.0), facecenter); + VectorScale(facecenter, 1.0 / (aasface->numedges * 2.0), facecenter); //add the face 'center' to the area 'center' - Vec3_Add(aasarea->center, facecenter, aasarea->center); + VectorAdd(aasarea->center, facecenter, aasarea->center); // if (aasworld.faceindexsize >= max_aas.max_faceindexsize) { @@ -1001,7 +1016,7 @@ int AAS_StoreArea(tmp_area_t *tmparea) //if the area has no faces at all (return 0, = solid leaf) if (!aasarea->numfaces) return 0; // - Vec3_Scale(aasarea->center, 1.0 / aasarea->numfaces, aasarea->center); + VectorScale(aasarea->center, 1.0 / aasarea->numfaces, aasarea->center); //Log_Write("area %d center %f %f %f\r\n", aasworld.numareas, // aasarea->center[0], aasarea->center[1], aasarea->center[2]); //store the area settings @@ -1026,12 +1041,15 @@ int AAS_StoreTree_r(tmp_node_t *tmpnode) aas_node_t *aasnode; //if it is a solid leaf - if (!tmpnode) return 0; + if (!tmpnode) + return 0; //negative so it's an area - if (tmpnode->tmparea) return AAS_StoreArea(tmpnode->tmparea); + if (tmpnode->tmparea) + return AAS_StoreArea(tmpnode->tmparea); //it's another node //the first node is a dummy - if (aasworld.numnodes == 0) aasworld.numnodes = 1; + if (aasworld.numnodes == 0) + aasworld.numnodes = 1; if (aasworld.numnodes >= max_aas.max_nodes) { Error("AAS_MAX_NODES = %d", max_aas.max_nodes); diff --git a/code/kaas/be_aas_bspc.c b/code/kaas/be_aas_bspc.c index ff9042f..de293bb 100644 --- a/code/kaas/be_aas_bspc.c +++ b/code/kaas/be_aas_bspc.c @@ -119,12 +119,12 @@ void BotImport_Trace(bsp_trace_t *bsptrace, vec3_t start, vec3_t mins, vec3_t ma bsptrace->allsolid = result.allsolid; bsptrace->contents = result.contents; - Vec3_Copy(result.endpos, bsptrace->endpos); + VectorCopy(result.endpos, bsptrace->endpos); bsptrace->ent = result.entityNum; bsptrace->fraction = result.fraction; bsptrace->exp_dist = 0; bsptrace->plane.dist = result.plane.dist; - Vec3_Copy(result.plane.normal, bsptrace->plane.normal); + VectorCopy(result.plane.normal, bsptrace->plane.normal); bsptrace->plane.signbits = result.plane.signbits; bsptrace->plane.type = result.plane.type; bsptrace->sidenum = 0; @@ -195,11 +195,11 @@ void BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmin } //end for } //end if if (outmins) - Vec3_Copy(mins, outmins); + VectorCopy(mins, outmins); if (outmaxs) - Vec3_Copy(maxs, outmaxs); + VectorCopy(maxs, outmaxs); if (origin) - Vec3_Clear(origin); + VectorClear(origin); } //end of the function BotImport_BSPModelMinsMaxsOrigin //=========================================================================== // @@ -207,7 +207,7 @@ void BotImport_BSPModelMinsMaxsOrigin(int modelnum, vec3_t angles, vec3_t outmin // Returns: - // Changes Globals: - //=========================================================================== -void KAAS_Com_DPrintf(char *fmt, ...) +void Com_DPrintf(const char *fmt, ...) { va_list argptr; char buf[1024]; diff --git a/code/kaas/be_aas_bspc.h b/code/kaas/be_aas_bspc.h index e7e18a6..3acc019 100644 --- a/code/kaas/be_aas_bspc.h +++ b/code/kaas/be_aas_bspc.h @@ -25,5 +25,5 @@ void AAS_CalcReachAndClusters(struct quakefile_s *qf); void AAS_InitBotImport(void); //void Com_Memcpy2 (void* dest, const void* src, const size_t count); //void Com_Memset2 (void* dest, const int val, const size_t count); -void KAAS_Com_DPrintf(char *fmt, ...); //hypov8 +void Com_DPrintf(const char *fmt, ...); //hypov8 #endif // BE_AAS_BSPC_H_ \ No newline at end of file diff --git a/code/kaas/brushbsp.c b/code/kaas/brushbsp.c index fb72a18..da0996b 100644 --- a/code/kaas/brushbsp.c +++ b/code/kaas/brushbsp.c @@ -301,7 +301,7 @@ bspbrush_t *BrushFromBounds (vec3_t mins, vec3_t maxs) b->numsides = 6; for (i=0 ; i<3 ; i++) { - Vec3_Clear (normal); + VectorClear (normal); normal[i] = 1; dist = maxs[i]; b->sides[i].planenum = FindFloatPlane (normal, dist); @@ -365,7 +365,7 @@ vec_t BrushVolume (bspbrush_t *brush) if (w) break; } //end for if (!w) return 0; - Vec3_Copy (w->p[0], corner); + VectorCopy (w->p[0], corner); // make tetrahedrons to all other faces volume = 0; @@ -374,7 +374,7 @@ vec_t BrushVolume (bspbrush_t *brush) w = brush->sides[i].winding; if (!w) continue; plane = &mapplanes[brush->sides[i].planenum]; - d = -(Vec3_DotProduct (corner, plane->normal) - plane->dist); + d = -(DotProduct (corner, plane->normal) - plane->dist); area = WindingArea(w); volume += d * area; } //end for @@ -515,7 +515,7 @@ bspnode_t *PointInLeaf (bspnode_t *node, vec3_t point) while (node->planenum != PLANENUM_LEAF) { plane = &mapplanes[node->planenum]; - d = Vec3_DotProduct (point, plane->normal) - plane->dist; + d = DotProduct (point, plane->normal) - plane->dist; if (d > 0) node = node->children[0]; else @@ -566,8 +566,8 @@ int BoxOnPlaneSide_Local (vec3_t mins, vec3_t maxs, plane_t *plane) } } - dist1 = Vec3_DotProduct (plane->normal, corners[0]) - plane->dist; - dist2 = Vec3_DotProduct (plane->normal, corners[1]) - plane->dist; + dist1 = DotProduct (plane->normal, corners[0]) - plane->dist; + dist2 = DotProduct (plane->normal, corners[1]) - plane->dist; side = 0; if (dist1 >= PLANESIDE_EPSILON) side = PSIDE_FRONT; @@ -773,7 +773,7 @@ int TestBrushToPlanenum (bspbrush_t *brush, int planenum, front = back = 0; for (j = 0; j < w->numpoints; j++) { - d = Vec3_DotProduct(w->p[j], plane->normal) - plane->dist; + d = DotProduct(w->p[j], plane->normal) - plane->dist; if (d > d_front) d_front = d; if (d < d_back) d_back = d; if (d > 0.1) // PLANESIDE_EPSILON) @@ -834,7 +834,7 @@ qboolean WindingIsTiny (winding_t *w) for (i=0 ; inumpoints ; i++) { j = i == w->numpoints - 1 ? 0 : i+1; - Vec3_Subtract (w->p[j], w->p[i], delta); + VectorSubtract (w->p[j], w->p[i], delta); len = VectorLength (delta); if (len > EDGE_LENGTH) { @@ -1125,7 +1125,7 @@ int BrushMostlyOnSide (bspbrush_t *brush, plane_t *plane) continue; for (j=0 ; jnumpoints ; j++) { - d = Vec3_DotProduct (w->p[j], plane->normal) - plane->dist; + d = DotProduct (w->p[j], plane->normal) - plane->dist; if (d > max) { max = d; @@ -1170,7 +1170,7 @@ void SplitBrush (bspbrush_t *brush, int planenum, continue; for (j=0 ; jnumpoints ; j++) { - d = Vec3_DotProduct (w->p[j], plane->normal) - plane->dist; + d = DotProduct (w->p[j], plane->normal) - plane->dist; if (d > 0 && d > d_front) d_front = d; if (d < 0 && d < d_back) @@ -1738,7 +1738,7 @@ void BuildTree(tree_t *tree) Log_Print("%6d threads max\n", numthreads); if (use_nodequeue) Log_Print("breadth first bsp building\n"); else Log_Print("depth first bsp building\n"); - qprintf("%6d splits", 0); + qprintf("%6d splits ", 0); //add the first node to the list AddNodeToList(tree->headnode); //start the threads diff --git a/code/kaas/bspc.c b/code/kaas/bspc.c index 4c0b6dc..04aecb4 100644 --- a/code/kaas/bspc.c +++ b/code/kaas/bspc.c @@ -53,7 +53,7 @@ char name[1024]; vec_t microvolume = 1.0; char outbase[32]; int entity_num; -aas_settings_t aassettings; +//aas_settings_t aassettings; qboolean noprune; //don't prune nodes (bspc.c) qboolean glview; //create a gl view diff --git a/code/kaas/csg.c b/code/kaas/csg.c index d4d21ae..16e0255 100755 --- a/code/kaas/csg.c +++ b/code/kaas/csg.c @@ -532,7 +532,7 @@ bspbrush_t *MakeBspBrushList(int startbrush, int endbrush, for (i=0 ; i<2 ; i++) { - Vec3_Clear (normal); + VectorClear (normal); normal[i] = 1; dist = clipmaxs[i]; maxplanenums[i] = FindFloatPlane(normal, dist); @@ -583,8 +583,8 @@ bspbrush_t *MakeBspBrushList(int startbrush, int endbrush, if (newbrush->sides[j].surf & SURF_HINT) newbrush->sides[j].flags |= SFL_VISIBLE; // hints are always visible } - Vec3_Copy (mb->mins, newbrush->mins); - Vec3_Copy (mb->maxs, newbrush->maxs); + VectorCopy (mb->mins, newbrush->mins); + VectorCopy (mb->maxs, newbrush->maxs); // // carve off anything outside the clip box @@ -976,8 +976,8 @@ tree_t *ProcessWorldBrushes(int brush_start, int brush_end) tree = Tree_Alloc(); tree->headnode = node; - Vec3_Copy(mins, tree->mins); - Vec3_Copy(maxs, tree->maxs); + VectorCopy(mins, tree->mins); + VectorCopy(maxs, tree->maxs); } //end if else { diff --git a/code/kaas/kaas.vcxproj b/code/kaas/kaas.vcxproj index 2652d8a..34842b3 100644 --- a/code/kaas/kaas.vcxproj +++ b/code/kaas/kaas.vcxproj @@ -88,7 +88,8 @@ - false + true + true false @@ -100,8 +101,8 @@ false - true - true + false + false true @@ -172,11 +173,14 @@ - false + true + true - + + true + true true @@ -192,6 +196,8 @@ false + + CompileAsCpp @@ -342,6 +348,7 @@ {4E4EBC16-F345-4667-84E1-86633BAFDAE6} kaas + 8.1 @@ -377,6 +384,7 @@ ..\..\build\debug-win32\kaas\ false $(ProjectName).x86 + false ..\..\build\release-win32\ @@ -405,8 +413,9 @@ ProgramDatabase true true - StreamingSIMDExtensions2 + NoExtensions ..\..\code\qcommon;..\..\code\botlib;..\..\code\ogg\include;..\..\code\vorbis\include;..\..\code\zlib;..\..\code\SDL12\include;..\..\code\freetype\include;..\..\code\OpenAL1.1\include;..\..\libcurl;..\..\code\libspeex\include;..\..\code\theora\include;..\..\code\glew\include;%(AdditionalIncludeDirectories) + false _DEBUG;%(PreprocessorDefinitions) @@ -424,8 +433,9 @@ true $(IntDir)kaas.map false - user32.lib;advapi32.lib;winmm.lib;wsock32.lib;ws2_32.lib;SDL.lib;OpenGL32.lib;glew.lib;alibcof32.lib;psapi.lib;libvorbisfile.lib;libvorbis.lib;libpng14.lib;libogg.lib;libtheora.lib;freetype244MT.lib;msvcrt.lib;zlib1.lib;SDLmain.lib;%(AdditionalDependencies) + %(AdditionalDependencies) libcmt.lib + true rem bash -c "perl ./unix/cons -- release-TA" @@ -443,7 +453,7 @@ xcopy /y /d "$(TargetPath)" "D:\kpq3_beta2\" Default WIN32;NDEBUG;_CONSOLE;BSPC;_CRT_SECURE_NO_WARNINGS;RNDER_EXTENDED;_CRT_SECURE_NO_DEPRECATE;USE_LOCAL_HEADERS;COMPAT_KPQ3;%(PreprocessorDefinitions) true - MultiThreadedDLL + MultiThreaded true $(IntDir)kaas.pch @@ -457,7 +467,7 @@ xcopy /y /d "$(TargetPath)" "D:\kpq3_beta2\" false - StreamingSIMDExtensions2 + NoExtensions false ..\..\code\qcommon;..\..\code\botlib;..\..\code\ogg\include;..\..\code\vorbis\include;..\..\code\zlib;..\..\code\SDL12\include;..\..\code\freetype\include;..\..\code\OpenAL1.1\include;..\..\libcurl;..\..\code\libspeex\include;..\..\code\theora\include;..\..\code\glew\include;%(AdditionalIncludeDirectories) @@ -480,9 +490,11 @@ xcopy /y /d "$(TargetPath)" "D:\kpq3_beta2\" $(IntDir)kaas.map - + true true true + true + false rem bash -c "perl ./unix/cons -- release-TA" diff --git a/code/kaas/l_bsp_q3.c b/code/kaas/l_bsp_q3.c index 4eef9cf..604cc4f 100644 --- a/code/kaas/l_bsp_q3.c +++ b/code/kaas/l_bsp_q3.c @@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#include "../qcommon/q_shared.h" #include "l_cmd.h" #include "l_math.h" #include "l_mem.h" @@ -170,12 +169,12 @@ void Q3_PlaneFromPoints(vec3_t p0, vec3_t p1, vec3_t p2, vec3_t normal, float *d { vec3_t t1, t2; - Vec3_Subtract(p0, p1, t1); - Vec3_Subtract(p2, p1, t2); + VectorSubtract(p0, p1, t1); + VectorSubtract(p2, p1, t2); CrossProduct(t1, t2, normal); VectorNormalize(normal); - *dist = Vec3_DotProduct(p0, normal); + *dist = DotProduct(p0, normal); } //end of the function PlaneFromPoints //=========================================================================== // @@ -195,8 +194,8 @@ void Q3_SurfacePlane(dsurface_t *surface, vec3_t normal, float *dist) { p1 = q3_drawVerts[surface->firstVert + ((i) % surface->numVerts)].xyz; p2 = q3_drawVerts[surface->firstVert + ((i+1) % surface->numVerts)].xyz; - Vec3_Subtract(p0, p1, t1); - Vec3_Subtract(p2, p1, t2); + VectorSubtract(p0, p1, t1); + VectorSubtract(p2, p1, t2); CrossProduct(t1, t2, normal); VectorNormalize(normal); if (VectorLength(normal)) break; @@ -208,11 +207,11 @@ void Q3_SurfacePlane(dsurface_t *surface, vec3_t normal, float *dist) p0 = q3_drawVerts[surface->firstVert + ((i) % surface->numVerts)].xyz; p1 = q3_drawVerts[surface->firstVert + ((i+1) % surface->numVerts)].xyz; p2 = q3_drawVerts[surface->firstVert + ((i+2) % surface->numVerts)].xyz; - Vec3_Subtract(p0, p1, t1); - Vec3_Subtract(p2, p1, t2); + VectorSubtract(p0, p1, t1); + VectorSubtract(p2, p1, t2); VectorNormalize(t1); VectorNormalize(t2); - dot = Vec3_DotProduct(t1, t2); + dot = DotProduct(t1, t2); if (dot > -0.9 && dot < 0.9 && VectorLength(t1) > 0.1 && VectorLength(t2) > 0.1) break; } //end for @@ -229,7 +228,7 @@ void Q3_SurfacePlane(dsurface_t *surface, vec3_t normal, float *dist) Log_Print("p%d = %f %f %f\n", i, p1[0], p1[1], p1[2]); } //end for } //end if - *dist = Vec3_DotProduct(p0, normal); + *dist = DotProduct(p0, normal); } //end of the function Q3_SurfacePlane //=========================================================================== // @@ -269,7 +268,7 @@ void Q3_SurfacePlane(q3_dsurface_t *surface, vec3_t normal, float *dist) //take the plane information from the lightmap vector //VectorCopy(surface->lightmapVecs[2], normal); //calculate plane dist with first surface vertex - //*dist = Vec3_DotProduct(q3_drawVerts[surface->firstVert].xyz, normal); + //*dist = DotProduct(q3_drawVerts[surface->firstVert].xyz, normal); Q3_PlaneFromPoints(q3_drawVerts[surface->firstVert].xyz, q3_drawVerts[surface->firstVert+1].xyz, q3_drawVerts[surface->firstVert+2].xyz, normal, dist); @@ -302,10 +301,10 @@ float Q3_FaceOnWinding(dsurface_t *surface, winding_t *winding) v2 = q3_drawVerts[surface->firstVert + ((i+1) % surface->numVerts)].xyz; //create a plane through the edge from v1 to v2, orthogonal to the //surface plane and with the normal vector pointing inward - Vec3_Subtract(v2, v1, edgevec); + VectorSubtract(v2, v1, edgevec); CrossProduct(edgevec, plane.normal, normal); VectorNormalize(normal); - dist = Vec3_DotProduct(normal, v1); + dist = DotProduct(normal, v1); // ChopWindingInPlace(&w, normal, dist, -0.1); //CLIP_EPSILON } //end for @@ -341,7 +340,7 @@ winding_t *Q3_BrushSideWinding(dbrush_t *brush, dbrushside_t *baseside) if (side->planeNum == baseside->planeNum) continue; //also don't use planes that are almost equal plane = &q3_dplanes[side->planeNum]; - if (Vec3_DotProduct(baseplane->normal, plane->normal) > 0.999 + if (DotProduct(baseplane->normal, plane->normal) > 0.999 && fabs(baseplane->dist - plane->dist) < 0.01) continue; // plane = &q3_dplanes[side->planeNum^1]; @@ -430,7 +429,7 @@ void Q3_FindVisibleBrushSides(void) plane = &q3_surfaceplanes[k]; //the surface plane and the brush side plane should be pretty much the same if (fabs(fabs(plane->dist) - fabs(q3_dplanes[brushside->planeNum].dist)) > 5) continue; - dot = Vec3_DotProduct(plane->normal, q3_dplanes[brushside->planeNum].normal); + dot = DotProduct(plane->normal, q3_dplanes[brushside->planeNum].normal); if (dot > -0.9 && dot < 0.9) continue; //if the face is partly or totally on the brush side if (Q3_FaceOnWinding(surface, w)) @@ -519,14 +518,14 @@ void Q3_SwapBSPFile( void ) { #ifdef NO_TYPE_PUNNING byteptr = q3_visBytes; - Vec4_Copy(byteptr, bi.b); + Vector4Copy(byteptr, bi.b); LittleLongl(bi.i); - Vec4_Copy(bi.b, byteptr); + Vector4Copy(bi.b, byteptr); byteptr = q3_visBytes + 4; - Vec4_Copy(byteptr, bi.b); + Vector4Copy(byteptr, bi.b); LittleLongl(bi.i); - Vec4_Copy(bi.b, byteptr); + Vector4Copy(bi.b, byteptr); #else // vis ((int *)&q3_visBytes)[0] = LittleLongl( ((int *)&q3_visBytes)[0] ); diff --git a/code/kaas/l_cmd.c b/code/kaas/l_cmd.c index c3d0d6a..5708c46 100755 --- a/code/kaas/l_cmd.c +++ b/code/kaas/l_cmd.c @@ -230,7 +230,7 @@ void qprintf(char *format, ...) } //end of the function qprintf //hypov8 -void KAAS_Com_Error(int level, char *error, ...) +void Com_Error(int level, const char *error, ...) { va_list argptr; char text[1024]; @@ -241,7 +241,7 @@ void KAAS_Com_Error(int level, char *error, ...) Error(text); } //end of the funcion Com_Error -void KAAS_Com_Printf( const char *fmt, ... ) +void Com_Printf( const char *fmt, ... ) { va_list argptr; char text[1024]; diff --git a/code/kaas/l_math.c b/code/kaas/l_math.c index bb15485..e20de60 100644 --- a/code/kaas/l_math.c +++ b/code/kaas/l_math.c @@ -212,7 +212,7 @@ vec_t VectorNormalize(vec3_t inout) length = sqrt (inout[0]*inout[0] + inout[1]*inout[1] + inout[2]*inout[2]); if (length == 0) { - Vec3_Clear (inout); + VectorClear (inout); return 0; } @@ -231,7 +231,7 @@ vec_t VectorNormalize2(const vec3_t in, vec3_t out) length = sqrt (in[0]*in[0] + in[1]*in[1] + in[2]*in[2]); if (length == 0) { - Vec3_Clear (out); + VectorClear (out); return 0; } diff --git a/code/kaas/l_math.h b/code/kaas/l_math.h index 0a4195c..12c0ab9 100644 --- a/code/kaas/l_math.h +++ b/code/kaas/l_math.h @@ -28,8 +28,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define USE_Q_SHARED #ifdef USE_Q_SHARED -//#include "../qcommon/q_platform.h" -//#include "../qcommon/q_shared.h" +#include "../qcommon/q_platform.h" //hypov8 re-enable +#include "../qcommon/q_shared.h" //hypov8 re-enable +#include "../qcommon/q_math.h" #define BSPC_SIDE_FRONT 0 #define BSPC_SIDE_ON 2 @@ -104,13 +105,13 @@ qboolean lVectorCompare (vec3_t v1, vec3_t v2); #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) #define VectorSubtract(a,b,c) {c[0]=a[0]-b[0];c[1]=a[1]-b[1];c[2]=a[2]-b[2];} #define VectorAdd(a,b,c) {c[0]=a[0]+b[0];c[1]=a[1]+b[1];c[2]=a[2]+b[2];} -#ifndef Vec3_Copy +#ifndef VectorCopy #define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2]) #endif #define Vector4Copy(a,b) {b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];} #define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s)) //#define VectorClear(x) {x[0] = x[1] = x[2] = 0;} -#define Vec3_Clear(a) ((a)[0]=(a)[1]=(a)[2]=0) +#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0) #define VectorNegate(x, y) {y[0]=-x[0];y[1]=-x[1];y[2]=-x[2];} #define VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s)) diff --git a/code/kaas/l_mem.c b/code/kaas/l_mem.c index 8afb2c0..630f2b9 100755 --- a/code/kaas/l_mem.c +++ b/code/kaas/l_mem.c @@ -70,23 +70,24 @@ int MemorySize(void *ptr) // Returns: - // Changes Globals: - //=========================================================================== -void *KAAS_GetClearedMemory(int size) +void *GetClearedMemory(size_t size) { void *ptr; ptr = (void *) malloc(size); - if (!ptr) Error("out of memory"); + if (!ptr) + Error("out of memory"); memset(ptr, 0, size); allocedmemory += MemorySize(ptr); return ptr; -} //end of the function KAAS_GetClearedMemory +} //end of the function GetClearedMemory //=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== -void *KAAS_GetMemory(unsigned long size) +void *GetMemory(size_t size) { void *ptr; ptr = malloc(size); @@ -100,11 +101,11 @@ void *KAAS_GetMemory(unsigned long size) // Returns: - // Changes Globals: - //=========================================================================== -void KAAS_FreeMemory(void *ptr) +void FreeMemory(void *ptr) { allocedmemory -= MemorySize(ptr); free(ptr); -} //end of the function KAAS_FreeMemory +} //end of the function FreeMemory //=========================================================================== // // Parameter: - @@ -202,7 +203,7 @@ void *GetMemory(unsigned long size) #ifdef MEMDEBUG void *GetClearedMemoryDebug(unsigned long size, char *label, char *file, int line) #else -void *KAAS_GetClearedMemory(unsigned long size) +void *GetClearedMemory(size_t size) #endif //MEMDEBUG { void *ptr; @@ -222,7 +223,7 @@ void *KAAS_GetClearedMemory(unsigned long size) //=========================================================================== void *GetClearedHunkMemory(unsigned long size) { - return KAAS_GetClearedMemory(size); + return GetClearedMemory(size); } //end of the function GetClearedHunkMemory //=========================================================================== // @@ -250,7 +251,7 @@ memoryblock_t *BlockFromPointer(void *ptr, char *str) //char *crash = (char *) NULL; //crash[0] = 1; Error("%s: NULL pointer\n", str); -#endif MEMDEBUG +#endif return NULL; } //end if block = (memoryblock_t *) ((char *) ptr - sizeof(memoryblock_t)); @@ -271,7 +272,7 @@ memoryblock_t *BlockFromPointer(void *ptr, char *str) // Returns: - // Changes Globals: - //=========================================================================== -void KAAS_FreeMemory(void *ptr) +void FreeMemory(void *ptr) { memoryblock_t *block; @@ -282,7 +283,7 @@ void KAAS_FreeMemory(void *ptr) numblocks--; // free(block); -} //end of the function KAAS_FreeMemory +} //end of the function FreeMemory //=========================================================================== // // Parameter: - @@ -351,7 +352,7 @@ void DumpMemory(void) for (block = memory; block; block = memory) { - KAAS_FreeMemory(block->ptr); + FreeMemory(block->ptr); } //end for totalmemorysize = 0; } //end of the function DumpMemory @@ -395,7 +396,7 @@ void Hunk_ClearHigh(void) for (h = memhunk_high; h; h = nexth) { nexth = h->next; - KAAS_FreeMemory(h); + FreeMemory(h); } //end for memhunk_high = NULL; memhunk_high_size = 16 * 1024 * 1024; @@ -406,30 +407,30 @@ void Hunk_ClearHigh(void) // Returns: - // Changes Globals: - //=========================================================================== -#if 1 //hypov8 in qcommon\common.cc -void *KAAS_Hunk_Alloc(int size) +void *Hunk_Alloc(size_t size, ha_pref preference) { memhunk_t *h; + ha_pref tmp = preference; //unused if (!size) return (void *) memhunk_high_size; // - h = (memhunk_t*)KAAS_GetClearedMemory(size + sizeof(memhunk_t)); + h = (memhunk_t*)GetClearedMemory(size + sizeof(memhunk_t)); h->ptr = (char *) h + sizeof(memhunk_t); h->next = memhunk_high; memhunk_high = h; memhunk_high_size -= size; return h->ptr; } //end of the function Hunk_Alloc -#endif + //=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== -void *KAAS_Z_Malloc(int size) +void *Z_Malloc(size_t size) { - return KAAS_GetClearedMemory(size); + return GetClearedMemory(size); } //end of the function Z_Malloc //=========================================================================== // @@ -437,7 +438,7 @@ void *KAAS_Z_Malloc(int size) // Returns: - // Changes Globals: - //=========================================================================== -void KAAS_Z_Free (void *ptr) +void Z_Free (void *ptr) { - KAAS_FreeMemory(ptr); + FreeMemory(ptr); } //end of the function Z_Free diff --git a/code/kaas/l_mem.h b/code/kaas/l_mem.h index 2807215..ad5f90d 100755 --- a/code/kaas/l_mem.h +++ b/code/kaas/l_mem.h @@ -29,25 +29,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef MEMDEBUG -#ifndef BSPC -void *GetClearedMemory(int size); -void *GetMemory(unsigned long size); -void *Hunk_Alloc(int size); -#else -void *KAAS_GetClearedMemory(int size); -void *KAAS_GetMemory(unsigned long size); -void *KAAS_Hunk_Alloc(int size); -void *KAAS_Z_Malloc(int size); -void KAAS_Z_Free(void *ptr); -void KAAS_FreeMemory(void *ptr); - -#define Hunk_Alloc(size, p) (KAAS_Hunk_Alloc(size)) -#define GetMemory KAAS_GetMemory -#define GetClearedMemory KAAS_GetClearedMemory -#define GetClearedHunkMemory KAAS_GetClearedMemory// GetClearedMemory -#define Z_Malloc KAAS_Z_Malloc -#define Z_Free KAAS_Z_Free -#define FreeMemory KAAS_FreeMemory +#if 1 //ndef BSPC +void *GetClearedMemory(size_t size); +void *GetMemory(size_t size); #endif #else diff --git a/code/kaas/l_poly.c b/code/kaas/l_poly.c index ddd3a2c..4c068cb 100755 --- a/code/kaas/l_poly.c +++ b/code/kaas/l_poly.c @@ -21,7 +21,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include -#include "../qcommon/q_shared.h" //hypov8 add #include "l_cmd.h" #include "l_math.h" #include "l_poly.h" @@ -34,7 +33,7 @@ extern int numthreads; // counters are only bumped when running single threaded, // because they are an awefull coherence problem -#if 0 // +#if 1 // int c_active_windings; int c_peak_windings; int c_winding_allocs; @@ -45,7 +44,7 @@ int c_peak_windingmemory; int c_windingmemory; char windingerror[1024]; -#if 0 // +#if 1 // void pw(winding_t *w) { int i; @@ -53,7 +52,6 @@ void pw(winding_t *w) printf ("(%5.3f, %5.3f, %5.3f)\n",w->p[i][0], w->p[i][1],w->p[i][2]); } - void ResetWindings(void) { c_active_windings = 0; @@ -76,7 +74,7 @@ winding_t *AllocWinding (int points) //hypov8 differs in cm_polylib int s; s = sizeof(vec_t)*3*points + sizeof(int); - w = GetMemory(s); + w = (winding_t *)GetMemory(s); memset(w, 0, s); if (numthreads == 1) @@ -142,15 +140,15 @@ void RemoveColinearPoints (winding_t *w) { j = (i+1)%w->numpoints; k = (i+w->numpoints-1)%w->numpoints; - Vec3_Subtract (w->p[j], w->p[i], v1); - Vec3_Subtract (w->p[i], w->p[k], v2); + VectorSubtract (w->p[j], w->p[i], v1); + VectorSubtract (w->p[i], w->p[k], v2); VectorNormalize(v1); VectorNormalize(v2); - if (Vec3_DotProduct(v1, v2) < 0.999) + if (DotProduct(v1, v2) < 0.999) { if (nump >= MAX_POINTS_ON_WINDING) Error("RemoveColinearPoints: MAX_POINTS_ON_WINDING"); - Vec3_Copy (w->p[i], p[nump]); + VectorCopy (w->p[i], p[nump]); nump++; } } @@ -177,13 +175,13 @@ void WindingPlane (winding_t *w, vec3_t normal, vec_t *dist) //hypov8 differs in //find two vectors each longer than 0.5 units for (i = 0; i < w->numpoints; i++) { - Vec3_Subtract(w->p[(i+1) % w->numpoints], w->p[i], v1); - Vec3_Subtract(w->p[(i+2) % w->numpoints], w->p[i], v2); + VectorSubtract(w->p[(i+1) % w->numpoints], w->p[i], v1); + VectorSubtract(w->p[(i+2) % w->numpoints], w->p[i], v2); if (VectorLength(v1) > 0.5 && VectorLength(v2) > 0.5) break; } //end for CrossProduct(v2, v1, normal); VectorNormalize(normal); - *dist = Vec3_DotProduct(w->p[0], normal); + *dist = DotProduct(w->p[0], normal); } //end of the function WindingPlane /* @@ -200,8 +198,8 @@ vec_t WindingArea (winding_t *w) total = 0; for (i=2 ; inumpoints ; i++) { - Vec3_Subtract (w->p[i-1], w->p[0], d1); - Vec3_Subtract (w->p[i], w->p[0], d2); + VectorSubtract (w->p[i-1], w->p[0], d1); + VectorSubtract (w->p[i], w->p[0], d2); CrossProduct (d1, d2, cross); total += 0.5 * VectorLength ( cross ); } @@ -239,7 +237,7 @@ void WindingCenter (winding_t *w, vec3_t center) int i; float scale; - Vec3_Copy (vec3_origin, center); + VectorCopy (vec3_origin, center); for (i=0 ; inumpoints ; i++) VectorAdd (w->p[i], center, center); @@ -275,7 +273,7 @@ winding_t *BaseWindingForPlane (vec3_t normal, vec_t dist) if (x==-1) Error ("BaseWindingForPlane: no axis found"); - Vec3_Copy (vec3_origin, vup); + VectorCopy (vec3_origin, vup); switch (x) { case 0: @@ -287,7 +285,7 @@ winding_t *BaseWindingForPlane (vec3_t normal, vec_t dist) break; } - v = Vec3_DotProduct (vup, normal); + v = DotProduct (vup, normal); VectorMA (vup, -v, normal, vup); VectorNormalize (vup); @@ -301,17 +299,17 @@ winding_t *BaseWindingForPlane (vec3_t normal, vec_t dist) // project a really big axis aligned box onto the plane w = AllocWinding (4); - Vec3_Subtract (org, vright, w->p[0]); + VectorSubtract (org, vright, w->p[0]); VectorAdd (w->p[0], vup, w->p[0]); VectorAdd (org, vright, w->p[1]); VectorAdd (w->p[1], vup, w->p[1]); VectorAdd (org, vright, w->p[2]); - Vec3_Subtract (w->p[2], vup, w->p[2]); + VectorSubtract (w->p[2], vup, w->p[2]); - Vec3_Subtract (org, vright, w->p[3]); - Vec3_Subtract (w->p[3], vup, w->p[3]); + VectorSubtract (org, vright, w->p[3]); + VectorSubtract (w->p[3], vup, w->p[3]); w->numpoints = 4; @@ -329,7 +327,8 @@ winding_t *CopyWinding (winding_t *w) winding_t *c; c = AllocWinding (w->numpoints); - size = (int)((winding_t *)0)->p[w->numpoints]; + size = (int)((winding_t *)0)->p[w->numpoints]; //kpq3 orig + //size = sizeof(*w) + sizeof(*w->p) * w->numpoints; // q3 orig memcpy (c, w, size); return c; } @@ -347,7 +346,7 @@ winding_t *ReverseWinding (winding_t *w) c = AllocWinding (w->numpoints); for (i=0 ; inumpoints ; i++) { - Vec3_Copy (w->p[w->numpoints-1-i], c->p[i]); + VectorCopy (w->p[w->numpoints-1-i], c->p[i]); } c->numpoints = w->numpoints; return c; @@ -378,7 +377,7 @@ void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, // determine sides for each point for (i=0 ; inumpoints ; i++) { - dot = Vec3_DotProduct (in->p[i], normal); + dot = DotProduct (in->p[i], normal); dot -= dist; dists[i] = dot; if (dot > epsilon) @@ -419,21 +418,21 @@ void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, if (sides[i] == BSPC_SIDE_ON) { - Vec3_Copy (p1, f->p[f->numpoints]); + VectorCopy (p1, f->p[f->numpoints]); f->numpoints++; - Vec3_Copy (p1, b->p[b->numpoints]); + VectorCopy (p1, b->p[b->numpoints]); b->numpoints++; continue; } if (sides[i] == BSPC_SIDE_FRONT) { - Vec3_Copy (p1, f->p[f->numpoints]); + VectorCopy (p1, f->p[f->numpoints]); f->numpoints++; } if (sides[i] == BSPC_SIDE_BACK) { - Vec3_Copy (p1, b->p[b->numpoints]); + VectorCopy (p1, b->p[b->numpoints]); b->numpoints++; } @@ -454,9 +453,9 @@ void ClipWindingEpsilon (winding_t *in, vec3_t normal, vec_t dist, mid[j] = p1[j] + dot*(p2[j]-p1[j]); } - Vec3_Copy (mid, f->p[f->numpoints]); + VectorCopy (mid, f->p[f->numpoints]); f->numpoints++; - Vec3_Copy (mid, b->p[b->numpoints]); + VectorCopy (mid, b->p[b->numpoints]); b->numpoints++; } @@ -475,7 +474,7 @@ ChopWindingInPlace void ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t epsilon) { winding_t *in; - vec_t dists[MAX_POINTS_ON_WINDING+4]; + vec_t dists[MAX_POINTS_ON_WINDING+4]; int sides[MAX_POINTS_ON_WINDING+4]; int counts[3]; //MrElusive: DOH can't use statics when unsing multithreading!!! @@ -492,7 +491,7 @@ void ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t eps // determine sides for each point for (i=0 ; inumpoints ; i++) { - dot = Vec3_DotProduct (in->p[i], normal); + dot = DotProduct (in->p[i], normal); dot -= dist; dists[i] = dot; if (dot > epsilon) @@ -528,14 +527,14 @@ void ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t eps if (sides[i] == BSPC_SIDE_ON) { - Vec3_Copy (p1, f->p[f->numpoints]); + VectorCopy (p1, f->p[f->numpoints]); f->numpoints++; continue; } if (sides[i] == BSPC_SIDE_FRONT) { - Vec3_Copy (p1, f->p[f->numpoints]); + VectorCopy (p1, f->p[f->numpoints]); f->numpoints++; } @@ -556,7 +555,7 @@ void ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t eps mid[j] = p1[j] + dot*(p2[j]-p1[j]); } - Vec3_Copy (mid, f->p[f->numpoints]); + VectorCopy (mid, f->p[f->numpoints]); f->numpoints++; } @@ -625,20 +624,20 @@ void CheckWinding (winding_t *w) j = i+1 == w->numpoints ? 0 : i+1; // check the point is on the face plane - d = Vec3_DotProduct (p1, facenormal) - facedist; + d = DotProduct (p1, facenormal) - facedist; if (d < -ON_EPSILON || d > ON_EPSILON) Error ("CheckWinding: point off plane"); // check the edge isnt degenerate p2 = w->p[j]; - Vec3_Subtract (p2, p1, dir); + VectorSubtract (p2, p1, dir); if (VectorLength (dir) < ON_EPSILON) Error ("CheckWinding: degenerate edge"); CrossProduct (facenormal, dir, edgenormal); VectorNormalize (edgenormal); - edgedist = Vec3_DotProduct (p1, edgenormal); + edgedist = DotProduct (p1, edgenormal); edgedist += ON_EPSILON; // all other points must be on front side @@ -646,7 +645,7 @@ void CheckWinding (winding_t *w) { if (j == i) continue; - d = Vec3_DotProduct (w->p[j], edgenormal); + d = DotProduct (w->p[j], edgenormal); if (d > edgedist) Error ("CheckWinding: non-convex"); } @@ -669,7 +668,7 @@ int WindingOnPlaneSide (winding_t *w, vec3_t normal, vec_t dist) back = qfalse; for (i=0 ; inumpoints ; i++) { - d = Vec3_DotProduct (w->p[i], normal) - dist; + d = DotProduct (w->p[i], normal) - dist; if (d < -ON_EPSILON) { if (front) @@ -757,25 +756,25 @@ winding_t *TryMergeWinding (winding_t *f1, winding_t *f2, vec3_t planenormal) // if the slopes are colinear, the point can be removed // back = f1->p[(i+f1->numpoints-1)%f1->numpoints]; - Vec3_Subtract (p1, back, delta); + VectorSubtract (p1, back, delta); CrossProduct (planenormal, delta, normal); VectorNormalize (normal); back = f2->p[(j+2)%f2->numpoints]; - Vec3_Subtract (back, p1, delta); - dot = Vec3_DotProduct (delta, normal); + VectorSubtract (back, p1, delta); + dot = DotProduct (delta, normal); if (dot > CONTINUOUS_EPSILON) return NULL; // not a convex polygon keep1 = (qboolean)(dot < -CONTINUOUS_EPSILON); back = f1->p[(i+2)%f1->numpoints]; - Vec3_Subtract (back, p2, delta); + VectorSubtract (back, p2, delta); CrossProduct (planenormal, delta, normal); VectorNormalize (normal); back = f2->p[(j+f2->numpoints-1)%f2->numpoints]; - Vec3_Subtract (back, p2, delta); - dot = Vec3_DotProduct (delta, normal); + VectorSubtract (back, p2, delta); + dot = DotProduct (delta, normal); if (dot > CONTINUOUS_EPSILON) return NULL; // not a convex polygon keep2 = (qboolean)(dot < -CONTINUOUS_EPSILON); @@ -791,7 +790,7 @@ winding_t *TryMergeWinding (winding_t *f1, winding_t *f2, vec3_t planenormal) if (k==(i+1)%f1->numpoints && !keep2) continue; - Vec3_Copy (f1->p[k], newf->p[newf->numpoints]); + VectorCopy (f1->p[k], newf->p[newf->numpoints]); newf->numpoints++; } @@ -800,7 +799,7 @@ winding_t *TryMergeWinding (winding_t *f1, winding_t *f2, vec3_t planenormal) { if (l==(j+1)%f2->numpoints && !keep1) continue; - Vec3_Copy (f2->p[l], newf->p[newf->numpoints]); + VectorCopy (f2->p[l], newf->p[newf->numpoints]); newf->numpoints++; } @@ -830,10 +829,10 @@ winding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal) // for (i = 0; i < w2->numpoints; i++) { - Vec3_Copy(w2->p[i], v); + VectorCopy(w2->p[i], v); for (j = 0; j < numpoints; j++) { - Vec3_Subtract(newp[(j+1)%numpoints], + VectorSubtract(newp[(j+1)%numpoints], newp[(j)%numpoints], edgevec); CrossProduct(edgevec, planenormal, sepnormal); VectorNormalize(sepnormal); @@ -842,7 +841,7 @@ winding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal) //remove the point from the new winding for (n = j; n < numpoints-1; n++) { - Vec3_Copy(newp[n+1], newp[n]); + VectorCopy(newp[n+1], newp[n]); sides[n] = sides[n+1]; } //end for numpoints--; @@ -852,8 +851,8 @@ winding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal) sepnormal[2]); continue; } //end if - dist = Vec3_DotProduct(newp[(j)%numpoints], sepnormal); - if (Vec3_DotProduct(v, sepnormal) - dist < -0.1) sides[j] = BSPC_SIDE_BACK; + dist = DotProduct(newp[(j)%numpoints], sepnormal); + if (DotProduct(v, sepnormal) - dist < -0.1) sides[j] = BSPC_SIDE_BACK; else sides[j] = BSPC_SIDE_FRONT; } //end for //remove all unnecesary points @@ -865,7 +864,7 @@ winding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal) //remove the point from the new winding for (n = (j+1)%numpoints; n < numpoints-1; n++) { - Vec3_Copy(newp[n+1], newp[n]); + VectorCopy(newp[n+1], newp[n]); sides[n] = sides[n+1]; } //end for numpoints--; @@ -896,10 +895,10 @@ winding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal) //insert the new point after j+1 for (n = numpoints-1; n > insertafter; n--) { - Vec3_Copy(newp[n], newp[n+1]); + VectorCopy(newp[n], newp[n+1]); } //end for numpoints++; - Vec3_Copy(v, newp[(insertafter+1)%numpoints]); + VectorCopy(v, newp[(insertafter+1)%numpoints]); break; } //end if } //end for @@ -912,12 +911,6 @@ winding_t *MergeWindings(winding_t *w1, winding_t *w2, vec3_t planenormal) } //end of the function MergeWindings //=========================================================================== -int WindingMemory(void) -{ - return c_windingmemory; -} //end of the function WindingMemory - - // // Parameter: - // Returns: - @@ -973,7 +966,7 @@ int WindingError(winding_t *w) j = i+1 == w->numpoints ? 0 : i+1; // check the point is on the face plane - d = Vec3_DotProduct (p1, facenormal) - facedist; + d = DotProduct (p1, facenormal) - facedist; if (d < -ON_EPSILON || d > ON_EPSILON) { sprintf(windingerror, "winding point %d off plane", i); @@ -982,7 +975,7 @@ int WindingError(winding_t *w) // check the edge isnt degenerate p2 = w->p[j]; - Vec3_Subtract (p2, p1, dir); + VectorSubtract (p2, p1, dir); if (VectorLength (dir) < ON_EPSILON) { @@ -992,7 +985,7 @@ int WindingError(winding_t *w) CrossProduct (facenormal, dir, edgenormal); VectorNormalize (edgenormal); - edgedist = Vec3_DotProduct (p1, edgenormal); + edgedist = DotProduct (p1, edgenormal); edgedist += ON_EPSILON; // all other points must be on front side @@ -1000,7 +993,7 @@ int WindingError(winding_t *w) { if (j == i) continue; - d = Vec3_DotProduct (w->p[j], edgenormal); + d = DotProduct (w->p[j], edgenormal); if (d > edgedist) { sprintf(windingerror, "winding non-convex"); @@ -1022,16 +1015,16 @@ void RemoveEqualPoints(winding_t *w, float epsilon) vec3_t v; vec3_t p[MAX_POINTS_ON_WINDING]; - Vec3_Copy(w->p[0], p[0]); + VectorCopy(w->p[0], p[0]); nump = 1; for (i = 1; i < w->numpoints; i++) { - Vec3_Subtract(w->p[i], p[nump-1], v); + VectorSubtract(w->p[i], p[nump-1], v); if (VectorLength(v) > epsilon) { if (nump >= MAX_POINTS_ON_WINDING) Error("RemoveColinearPoints: MAX_POINTS_ON_WINDING"); - Vec3_Copy (w->p[i], p[nump]); + VectorCopy (w->p[i], p[nump]); nump++; } //end if } //end for @@ -1070,11 +1063,11 @@ winding_t *AddWindingPoint(winding_t *w, vec3_t point, int spot) { if (i == spot) { - Vec3_Copy(point, neww->p[i]); + VectorCopy(point, neww->p[i]); } //end if else { - Vec3_Copy(w->p[j], neww->p[i]); + VectorCopy(w->p[j], neww->p[i]); j++; } //end else } //end for @@ -1099,24 +1092,24 @@ int PointOnWinding(winding_t *w, vec3_t normal, float dist, vec3_t point, int *s *spot = 0; //the point must be on the winding plane - dot = Vec3_DotProduct(point, normal) - dist; + dot = DotProduct(point, normal) - dist; if (dot < -MELT_ON_EPSILON || dot > MELT_ON_EPSILON) return qfalse; // for (i = 0; i < w->numpoints; i++) { j = (i+1) % w->numpoints; //get a plane orthogonal to the winding plane through the edge - Vec3_Subtract(w->p[j], w->p[i], edgevec); + VectorSubtract(w->p[j], w->p[i], edgevec); CrossProduct(normal, edgevec, edgenormal); VectorNormalize(edgenormal); - edgedist = Vec3_DotProduct(edgenormal, w->p[i]); + edgedist = DotProduct(edgenormal, w->p[i]); //point must be not too far from the plane - dot = Vec3_DotProduct(point, edgenormal) - edgedist; + dot = DotProduct(point, edgenormal) - edgedist; if (dot < -MELT_ON_EPSILON || dot > MELT_ON_EPSILON) continue; //vector from first point of winding to the point to test - Vec3_Subtract(point, w->p[i], v1); + VectorSubtract(point, w->p[i], v1); //vector from second point of winding to the point to test - Vec3_Subtract(point, w->p[j], v2); + VectorSubtract(point, w->p[j], v2); //if the length of the vector is not larger than 0.5 units then //the point is assumend to be the same as one of the winding points if (VectorNormalize3(v1) < 0.5) return qfalse; @@ -1124,7 +1117,7 @@ int PointOnWinding(winding_t *w, vec3_t normal, float dist, vec3_t point, int *s //point must be between the two winding points //(the two vectors must be directed towards each other, and on the //same straight line) - if (Vec3_DotProduct(v1, v2) < -0.99) + if (DotProduct(v1, v2) < -0.99) { *spot = i + 1; return qtrue; @@ -1151,7 +1144,7 @@ int FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir, { i2 = (i+1) % w1->numpoints; // - Vec3_Subtract(w1->p[i2], w1->p[i], v1); + VectorSubtract(w1->p[i2], w1->p[i], v1); if (VectorLength(v1) < 0.1) { //Log_Write("FindPlaneSeperatingWindings: winding1 with degenerate edge\r\n"); @@ -1159,13 +1152,13 @@ int FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir, } //end if CrossProduct(v1, dir, normal1); VectorNormalize(normal1); - dist1 = Vec3_DotProduct(normal1, w1->p[i]); + dist1 = DotProduct(normal1, w1->p[i]); // for (j = 0; j < w2->numpoints; j++) { j2 = (j+1) % w2->numpoints; // - Vec3_Subtract(w2->p[j2], w2->p[j], v2); + VectorSubtract(w2->p[j2], w2->p[j], v2); if (VectorLength(v2) < 0.1) { //Log_Write("FindPlaneSeperatingWindings: winding2 with degenerate edge\r\n"); @@ -1173,13 +1166,13 @@ int FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir, } //end if CrossProduct(v2, dir, normal2); VectorNormalize(normal2); - dist2 = Vec3_DotProduct(normal2, w2->p[j]); + dist2 = DotProduct(normal2, w2->p[j]); // diff = dist1 - dist2; if (diff < -0.1 || diff > 0.1) { dist2 = -dist2; - Vec3_Negate(normal2, normal2); + VectorNegate(normal2, normal2); diff = dist1 - dist2; if (diff < -0.1 || diff > 0.1) continue; } //end if @@ -1195,7 +1188,7 @@ int FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir, sides1[0] = sides1[1] = sides1[2] = 0; for (n = 0; n < w1->numpoints; n++) { - dot = Vec3_DotProduct(w1->p[n], normal1) - dist1; + dot = DotProduct(w1->p[n], normal1) - dist1; if (dot > 0.1) sides1[0]++; else if (dot < -0.1) sides1[1]++; else sides1[2]++; @@ -1206,7 +1199,7 @@ int FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir, for (n = 0; n < w2->numpoints; n++) { //used normal1 and dist1 (they are equal to normal2 and dist2) - dot = Vec3_DotProduct(w2->p[n], normal1) - dist1; + dot = DotProduct(w2->p[n], normal1) - dist1; if (dot > 0.1) sides2[0]++; else if (dot < -0.1) sides2[1]++; else sides2[2]++; @@ -1232,7 +1225,7 @@ int FindPlaneSeperatingWindings(winding_t *w1, winding_t *w2, vec3_t dir, //the windings must be at different sides of the seperating plane if ((!sides1[0] && !sides2[1]) || (!sides1[1] && !sides2[0])) { - Vec3_Copy(normal1, normal); + VectorCopy(normal1, normal); *dist = dist1; return qtrue; } //end if @@ -1259,12 +1252,12 @@ int WindingsNonConvex(winding_t *w1, winding_t *w2, //check if one of the points of face1 is at the back of the plane of face2 for (i = 0; i < w1->numpoints; i++) { - if (Vec3_DotProduct(normal2, w1->p[i]) - dist2 > WCONVEX_EPSILON) return qtrue; + if (DotProduct(normal2, w1->p[i]) - dist2 > WCONVEX_EPSILON) return qtrue; } //end for //check if one of the points of face2 is at the back of the plane of face1 for (i = 0; i < w2->numpoints; i++) { - if (Vec3_DotProduct(normal1, w2->p[i]) - dist1 > WCONVEX_EPSILON) return qtrue; + if (DotProduct(normal1, w2->p[i]) - dist1 > WCONVEX_EPSILON) return qtrue; } //end for return qfalse; @@ -1322,7 +1315,7 @@ winding_t *AAS_MergeWindings(winding_t *w1, winding_t *w2, vec3_t windingnormal) //get the points of the winding which are on the seperating plane for (i = 0; i < winding->numpoints; i++) { - dot = Vec3_DotProduct(winding->p[i], normal) - dist; + dot = DotProduct(winding->p[i], normal) - dist; if (dot > -ON_EPSILON && dot < ON_EPSILON) { //don't allow more than 64 points on the seperating plane @@ -1354,7 +1347,7 @@ winding_t *AAS_MergeWindings(winding_t *w1, winding_t *w2, vec3_t windingnormal) p1 = points[0][0]; //point before p1 p2 = (p1 + w1->numpoints - 1) % w1->numpoints; - Vec3_Subtract(w1->p[p1], w1->p[p2], delta); + VectorSubtract(w1->p[p1], w1->p[p2], delta); CrossProduct(windingnormal, delta, normal); VectorNormalize(normal, normal); @@ -1362,8 +1355,8 @@ winding_t *AAS_MergeWindings(winding_t *w1, winding_t *w2, vec3_t windingnormal) p1 = points[1][numpoints[1]-1]; //point after p1 p2 = (p1 + 1) % w2->numpoints; - Vec3_Subtract(w2->p[p2], w2->p[p1], delta); - dot = Vec3_DotProduct(delta, normal); + VectorSubtract(w2->p[p2], w2->p[p1], delta); + dot = DotProduct(delta, normal); if (dot > CONTINUOUS_EPSILON) return NULL; //merging would create a non-convex polygon keep[0] = (qboolean)(dot < -CONTINUOUS_EPSILON); @@ -1371,7 +1364,7 @@ winding_t *AAS_MergeWindings(winding_t *w1, winding_t *w2, vec3_t windingnormal) p1 = points[1][0]; //point before p1 p2 = (p1 + w2->numpoints - 1) % w2->numpoints; - Vec3_Subtract(w2->p[p1], w2->p[p2], delta); + VectorSubtract(w2->p[p1], w2->p[p2], delta); CrossProduct(windingnormal, delta, normal); VectorNormalize(normal, normal); @@ -1379,8 +1372,8 @@ winding_t *AAS_MergeWindings(winding_t *w1, winding_t *w2, vec3_t windingnormal) p1 = points[0][numpoints[0]-1]; //point after p1 p2 = (p1 + 1) % w1->numpoints; - Vec3_Subtract(w1->p[p2], w1->p[p1], delta); - dot = Vec3_DotProduct(delta, normal); + VectorSubtract(w1->p[p2], w1->p[p1], delta); + dot = DotProduct(delta, normal); if (dot > CONTINUOUS_EPSILON) return NULL; //merging would create a non-convex polygon keep[1] = (qboolean)(dot < -CONTINUOUS_EPSILON); @@ -1406,7 +1399,7 @@ winding_t *AAS_MergeWindings(winding_t *w1, winding_t *w2, vec3_t windingnormal) Log_Print("numpoints[1] = %d\n", numpoints[1]); Error("AAS_MergeWindings: k = %d >= newnumpoints = %d\n", k, newnumpoints); } //end if - Vec3_Copy(winding->p[i], neww->p[k]); + VectorCopy(winding->p[i], neww->p[k]); k++; } //end for } //end for diff --git a/code/kaas/l_poly.h b/code/kaas/l_poly.h index c9bd233..ffd95e5 100755 --- a/code/kaas/l_poly.h +++ b/code/kaas/l_poly.h @@ -20,23 +20,27 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ +#ifndef L_POLY_H +#define L_POLY_H //hypov8 add. loaded twice in cm_... + //a winding gives the bounding points of a convex polygon +#if 0 //hypov8 todo: use kass? #include "../qcommon/cm_polylib.h" -#if 0 +#else typedef struct { int numpoints; vec3_t p[4]; //variable sized } winding_t; #endif -#ifdef MAX_POINTS_ON_WINDING -#undef MAX_POINTS_ON_WINDING +//#ifdef MAX_POINTS_ON_WINDING +//#undef MAX_POINTS_ON_WINDING #define MAX_POINTS_ON_WINDING 96 -#endif +//#endif //you can define on_epsilon in the makefile as tighter #ifndef ON_EPSILON -#define ON_EPSILON 0.1 +#define ON_EPSILON 0.1f #endif //winding errors #define WE_NONE 0 @@ -47,7 +51,7 @@ typedef struct #define WE_DEGENERATEEDGE 5 #define WE_NONCONVEX 6 -#if 0 +#if 1 //allocates a winding winding_t *AllocWinding (int points); //returns the area of the winding @@ -141,4 +145,6 @@ char *WindingErrorString(void); int WindingError(winding_t *w); int WindingsNonConvex(winding_t *w1, winding_t *w2, vec3_t normal1, vec3_t normal2, - float dist1, float dist2); \ No newline at end of file + float dist1, float dist2); + +#endif //L_POLY_H \ No newline at end of file diff --git a/code/kaas/l_qfiles.c b/code/kaas/l_qfiles.c index 5911996..63329d7 100755 --- a/code/kaas/l_qfiles.c +++ b/code/kaas/l_qfiles.c @@ -31,7 +31,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif #include "qbsp.h" -#include "../kaas/unzip.h" //file extensions with their type typedef struct qfile_exttype_s diff --git a/code/kaas/l_qfiles.h b/code/kaas/l_qfiles.h index 8f535dc..6b66fc1 100644 --- a/code/kaas/l_qfiles.h +++ b/code/kaas/l_qfiles.h @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "../kaas/unzip.h" +#include "l_utils.h" #define QFILETYPE_UNKNOWN 0x8000 //#define QFILETYPE_PAK 0x0001 diff --git a/code/kaas/l_utils.h b/code/kaas/l_utils.h index e13a4ae..52233ee 100755 --- a/code/kaas/l_utils.h +++ b/code/kaas/l_utils.h @@ -20,10 +20,34 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ -#ifndef MAX_PATH - #define MAX_PATH 128 //hypov8: was 64. +#ifndef L_UTILS_H +#define L_UTILS_H + + +#if 0 //ndef MAX_PATH //MAX_PATH + #define MAX_PATH 128 //hypov8: was 64. MAX_PATH +#endif + +// maximum path length +#ifdef _WIN32 + #ifndef _MAX_PATH + #error unexpected + #endif + #ifndef MAX_PATH + #define MAX_PATH _MAX_PATH + #endif + #if MAX_PATH != _MAX_PATH + #error unexpected + #endif +#else + #ifdef MAX_PATH + #error unexpected + #endif + #define MAX_PATH 8192 #endif + + #ifndef PATH_SEPERATORSTR #if defined(WIN32)|defined(_WIN32)|defined(__NT__)|defined(__WINDOWS__)|defined(__WINDOWS_386__) #define PATHSEPERATOR_STR "\\" @@ -75,5 +99,5 @@ qboolean FindQuakeFile(char *filename, foundfile_t *file); qboolean FindQuakeFile(char *basedir, char *gamedir, char *filename, foundfile_t *file); #endif //BOTLIB - +#endif diff --git a/code/kaas/leakfile.c b/code/kaas/leakfile.c index 497b61d..ee29108 100755 --- a/code/kaas/leakfile.c +++ b/code/kaas/leakfile.c @@ -21,7 +21,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "qbsp.h" -#include "../qcommon/cm_polylib.h" //hypov8 /* ============================================================================== diff --git a/code/kaas/map.c b/code/kaas/map.c index 3cb70ca..69d88f5 100644 --- a/code/kaas/map.c +++ b/code/kaas/map.c @@ -185,12 +185,12 @@ int CreateNewFloatPlane (vec3_t normal, vec_t dist) Error ("MAX_MAPFILE_PLANES"); p = &mapplanes[nummapplanes]; - Vec3_Copy (normal, p->normal); + VectorCopy (normal, p->normal); p->dist = dist; p->type = (p+1)->type = PlaneTypeForNormal (p->normal); p->signbits = PlaneSignBits(p->normal); - Vec3_Subtract (vec3_origin, normal, (p+1)->normal); + VectorSubtract (vec3_origin, normal, (p+1)->normal); (p+1)->dist = -dist; (p+1)->signbits = PlaneSignBits((p+1)->normal); @@ -230,13 +230,13 @@ void SnapVectorKAAS(vec3_t normal) { if ( fabs(normal[i] - 1) < NORMAL_EPSILON ) { - Vec3_Clear (normal); + VectorClear (normal); normal[i] = 1; break; } if ( fabs(normal[i] - -1) < NORMAL_EPSILON ) { - Vec3_Clear (normal); + VectorClear (normal); normal[i] = -1; break; } @@ -320,12 +320,12 @@ int BSPC_PlaneFromPoints (int *p0, int *p1, int *p2) vec3_t t1, t2, normal; vec_t dist; - Vec3_Subtract (p0, p1, t1); - Vec3_Subtract (p2, p1, t2); + VectorSubtract (p0, p1, t1); + VectorSubtract (p2, p1, t2); CrossProduct (t1, t2, normal); VectorNormalize (normal); - dist = Vec3_DotProduct (p0, normal); + dist = DotProduct (p0, normal); return FindFloatPlane (normal, dist); } //end of the function BSPC_PlaneFromPoints @@ -374,7 +374,7 @@ void AddBrushBevels (mapbrush_t *b) Error ("MAX_MAP_BRUSHSIDES"); nummapbrushsides++; b->numsides++; - Vec3_Clear (normal); + VectorClear (normal); normal[axis] = dir; if (dir == 1) dist = b->maxs[axis]; @@ -427,7 +427,7 @@ void AddBrushBevels (mapbrush_t *b) for (j=0 ; jnumpoints ; j++) { k = (j+1)%w->numpoints; - Vec3_Subtract (w->p[j], w->p[k], vec); + VectorSubtract (w->p[j], w->p[k], vec); if (VectorNormalize3(vec) < 0.5) continue; SnapVectorKAAS (vec); @@ -443,12 +443,12 @@ void AddBrushBevels (mapbrush_t *b) for (dir=-1 ; dir <= 1 ; dir+=2) { // construct a plane - Vec3_Clear (vec2); + VectorClear (vec2); vec2[axis] = dir; CrossProduct (vec, vec2, normal); if (VectorNormalize3(normal) < 0.5) continue; - dist = Vec3_DotProduct (w->p[j], normal); + dist = DotProduct (w->p[j], normal); // if all the points on all the sides are // behind this plane, it is a proper edge bevel @@ -464,7 +464,7 @@ void AddBrushBevels (mapbrush_t *b) continue; for (l=0 ; lnumpoints ; l++) { - d = Vec3_DotProduct (w2->p[l], normal) - dist; + d = DotProduct (w2->p[l], normal) - dist; if (d > 0.1) break; // point in front } @@ -686,7 +686,7 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin) if (origin[0] || origin[1] || origin[2]) { newdist = mapplanes[s->planenum].dist + - Vec3_DotProduct(mapplanes[s->planenum].normal, origin); + DotProduct(mapplanes[s->planenum].normal, origin); planenum = FindFloatPlane(mapplanes[s->planenum].normal, newdist); } //end if else @@ -797,8 +797,8 @@ qboolean WriteMapBrush(FILE *fp, mapbrush_t *brush, vec3_t origin) // TextureAxisFromPlane(plane, axis[0], axis[1]); //calculate texture shift done by entity origin - originshift[0] = Vec3_DotProduct(origin, axis[0]); - originshift[1] = Vec3_DotProduct(origin, axis[1]); + originshift[0] = DotProduct(origin, axis[0]); + originshift[1] = DotProduct(origin, axis[1]); //the texture shift without origin shift shift[0] = ti->vecs[0][3] - originshift[0]; shift[1] = ti->vecs[1][3] - originshift[1]; @@ -875,7 +875,7 @@ qboolean WriteOriginBrush(FILE *fp, vec3_t origin) for (s = -1; s <= 1; s += 2) { // - Vec3_Clear(normal); + VectorClear(normal); normal[i] = s; dist = origin[i] * s + 16; // @@ -1173,8 +1173,8 @@ void ResetMapLoading(void) memset(map_texinfo, 0, MAX_MAPFILE_TEXINFO * sizeof(map_texinfo_t)); map_numtexinfo = 0; // - Vec3_Clear(map_mins); - Vec3_Clear(map_maxs); + VectorClear(map_mins); + VectorClear(map_maxs); // c_boxbevels = 0; c_edgebevels = 0; diff --git a/code/kaas/map_q3.c b/code/kaas/map_q3.c index 1aa5a6f..f8481f6 100644 --- a/code/kaas/map_q3.c +++ b/code/kaas/map_q3.c @@ -513,7 +513,7 @@ void AAS_CreateCurveBrushes(void) Log_Print("CM_GeneratePatchCollide \n"); pc = CM_GeneratePatchCollide(width, height, points); // - Log_Print("for (j = 0; j < pc->numFacets; j++)\n"); + Log_Print("for (j = 0; j < pc->numFacets; j++) (q3_numDrawSurfaces: %i)\n", i); for (j = 0; j < pc->numFacets; j++) { facet = &pc->facets[j]; @@ -528,7 +528,7 @@ void AAS_CreateCurveBrushes(void) brush->contents = CONTENTS_SOLID; // //qprintf("\r%6d curve brushes", nummapbrushsides);//++numcurvebrushes); - qprintf("\r%6d curve brushes", ++numcurvebrushes); + qprintf("\r%6d curve brushes (face: %i)", ++numcurvebrushes, j); // planenum = FindFloatPlane(pc->planes[facet->surfacePlane].plane, pc->planes[facet->surfacePlane].plane[3]); // diff --git a/code/kaas/portals.c b/code/kaas/portals.c index d30c955..5843556 100644 --- a/code/kaas/portals.c +++ b/code/kaas/portals.c @@ -385,7 +385,7 @@ winding_t *BaseWindingForNode (bspnode_t *node) } else { // take back - Vec3_Subtract (vec3_origin, plane->normal, normal); + VectorSubtract (vec3_origin, plane->normal, normal); dist = -plane->dist; ChopWindingInPlace (&w, normal, dist, BASE_WINDING_EPSILON); } @@ -422,13 +422,13 @@ void MakeNodePortal (bspnode_t *node) if (p->nodes[0] == node) { side = 0; - Vec3_Copy (p->plane.normal, normal); + VectorCopy (p->plane.normal, normal); dist = p->plane.dist; } //end if else if (p->nodes[1] == node) { side = 1; - Vec3_Subtract (vec3_origin, p->plane.normal, normal); + VectorSubtract (vec3_origin, p->plane.normal, normal); dist = -p->plane.dist; } //end else if else @@ -825,7 +825,7 @@ qboolean PlaceOccupant (bspnode_t *headnode, vec3_t origin, entity_t *occupant) Error("PlaceOccupant: invalid node->planenum\n"); } //end if plane = &mapplanes[node->planenum]; - d = Vec3_DotProduct(origin, plane->normal) - plane->dist; + d = DotProduct(origin, plane->normal) - plane->dist; if (d >= 0) { node = node->children[0]; @@ -1256,7 +1256,7 @@ void FindPortalSide (portal_t *p) } //end if // see how close the match is p2 = &mapplanes[side->planenum&~1]; - dot = Vec3_DotProduct (p1->normal, p2->normal); + dot = DotProduct (p1->normal, p2->normal); if (dot > bestdot) { bestdot = dot; diff --git a/code/kaas/qbsp.h b/code/kaas/qbsp.h index bd1b9df..bd1906b 100644 --- a/code/kaas/qbsp.h +++ b/code/kaas/qbsp.h @@ -27,13 +27,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include //hypov8 bspc #include -/////#include "../qcommon/q_platform.h" -//#include "../qcommon/q_platform.h" -//#include "../qcommon/qfiles.h" -#include "../qcommon/q_shared.h" - -//#include "../qcommon/surfaceflags.h" -//#include "../qcommon/cm_polylib.h" #include "l_cmd.h" #include "../kaas/l_math.h" diff --git a/code/kaas/textures.c b/code/kaas/textures.c index 4eec716..84f05bd 100755 --- a/code/kaas/textures.c +++ b/code/kaas/textures.c @@ -96,7 +96,7 @@ void TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv) for (i=0 ; i<6 ; i++) { - dot = Vec3_DotProduct (pln->normal, baseaxis[i*3]); + dot = DotProduct (pln->normal, baseaxis[i*3]); if (dot > best) { best = dot; @@ -104,8 +104,8 @@ void TextureAxisFromPlane(plane_t *pln, vec3_t xv, vec3_t yv) } } - Vec3_Copy (baseaxis[bestaxis*3+1], xv); - Vec3_Copy (baseaxis[bestaxis*3+2], yv); + VectorCopy (baseaxis[bestaxis*3+1], xv); + VectorCopy (baseaxis[bestaxis*3+2], yv); } //end of the function TextureAxisFromPlane //=========================================================================== // @@ -134,8 +134,8 @@ int TexinfoForBrushTexture(plane_t *plane, brush_texture_t *bt, vec3_t origin) TextureAxisFromPlane(plane, vecs[0], vecs[1]); - shift[0] = Vec3_DotProduct (origin, vecs[0]); - shift[1] = Vec3_DotProduct (origin, vecs[1]); + shift[0] = DotProduct (origin, vecs[0]); + shift[1] = DotProduct (origin, vecs[1]); if (!bt->scale[0]) bt->scale[0] = 1; diff --git a/code/kaas/tree.c b/code/kaas/tree.c index 05acb62..a99a4ce 100755 --- a/code/kaas/tree.c +++ b/code/kaas/tree.c @@ -42,7 +42,7 @@ bspnode_t *NodeForPoint (bspnode_t *node, vec3_t origin) while (node->planenum != PLANENUM_LEAF) { plane = &mapplanes[node->planenum]; - d = Vec3_DotProduct (origin, plane->normal) - plane->dist; + d = DotProduct (origin, plane->normal) - plane->dist; if (d >= 0) node = node->children[0]; else diff --git a/code/qcommon/cm_load.cc b/code/qcommon/cm_load.cc index d349e8e..35b0f25 100644 --- a/code/qcommon/cm_load.cc +++ b/code/qcommon/cm_load.cc @@ -26,9 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cm_local.h" #ifdef BSPC - #include "../kaas/be_aas_bspc.h" #include "../kaas/l_qfiles.h" - #include "../kaas/l_mem.h" //hypov8 add #endif // to allow boxes to be treated as brush models, we allocate diff --git a/code/qcommon/cm_local.h b/code/qcommon/cm_local.h index 81d7817..df855dc 100644 --- a/code/qcommon/cm_local.h +++ b/code/qcommon/cm_local.h @@ -24,14 +24,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define CM_LOCAL_H_ #include "q_shared.h" +#include "qcommon.h" +#include "cm_polylib.h" #ifdef BSPC -#include "../kaas/l_math.h" +//#include "../kaas/l_math.h" #endif -#include "qcommon.h" -#include "cm_polylib.h" - #define MAX_SUBMODELS MAX_MODELS // was 256 #define BOX_MODEL_HANDLE (MAX_SUBMODELS -1) // was 255 #define CAPSULE_MODEL_HANDLE (MAX_SUBMODELS -2) // was 254 diff --git a/code/qcommon/cm_patch.cc b/code/qcommon/cm_patch.cc index b15bc32..ebb9ba2 100644 --- a/code/qcommon/cm_patch.cc +++ b/code/qcommon/cm_patch.cc @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "cm_local.h" #include "cm_patch.h" -#ifdef BSPC +#if 0 //def BSPC #include "../kaas/be_aas_bspc.h" #include "../kaas/l_mem.h" #endif @@ -683,6 +683,7 @@ static int CM_GridPlane(int gridPlanes[MAX_GRID_SIZE][MAX_GRID_SIZE][2], int i, //FIXME (0xA5EA): getting ingame warnings from here, with kpq3dm5 // should never happen //hypov8 ERRORS are now reported at the location of issues so it can be fixed + // note: issue was a patch control point places at mesh centre(0,0,0) Com_Printf("WARNING: CM_GridPlane unresolvable\n"); return -1; } @@ -705,7 +706,8 @@ static int CM_EdgePlaneNum(cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRID p2 = grid->points[i + 1][j]; p = CM_GridPlane(gridPlanes, i, j, 0); //hypov8 report the location of errors. so issues can be fixed - if (p == -1) Com_Printf(" top %f %f %f\n", grid->points[i + 1][j][0], grid->points[i + 1][j][1], grid->points[i + 1][j][2]); + if (p == -1) + Com_Error(ERR_DROP, "CM_GridPlane: top %f %f %f\n", grid->points[i + 1][j][0], grid->points[i + 1][j][1], grid->points[i + 1][j][2]); VectorMA(p1, 4, planes[p].plane, up); return CM_FindPlane(p1, p2, up); @@ -713,7 +715,8 @@ static int CM_EdgePlaneNum(cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRID p1 = grid->points[i][j + 1]; p2 = grid->points[i + 1][j + 1]; p = CM_GridPlane(gridPlanes, i, j, 1); - if (p == -1) Com_Printf(" bot %f %f %f\n", grid->points[i + 1][j][0], grid->points[i + 1][j][1], grid->points[i + 1][j][2]); + if (p == -1) + Com_Error(ERR_DROP, "CM_GridPlane: bot %f %f %f\n", grid->points[i + 1][j][0], grid->points[i + 1][j][1], grid->points[i + 1][j][2]); VectorMA(p1, 4, planes[p].plane, up); return CM_FindPlane(p2, p1, up); @@ -721,7 +724,8 @@ static int CM_EdgePlaneNum(cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRID p1 = grid->points[i][j]; p2 = grid->points[i][j + 1]; p = CM_GridPlane(gridPlanes, i, j, 1); - if (p == -1) Com_Printf(" left %f %f %f\n", grid->points[i][j][0], grid->points[i ][j][1], grid->points[i][j][2]); + if (p == -1) + Com_Error(ERR_DROP, "CM_GridPlane: left %f %f %f\n", grid->points[i][j][0], grid->points[i ][j][1], grid->points[i][j][2]); VectorMA(p1, 4, planes[p].plane, up); return CM_FindPlane(p2, p1, up); @@ -729,7 +733,8 @@ static int CM_EdgePlaneNum(cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRID p1 = grid->points[i + 1][j]; p2 = grid->points[i + 1][j + 1]; p = CM_GridPlane(gridPlanes, i, j, 0); - if (p == -1) Com_Printf(" right %f %f %f\n", grid->points[i][j][0], grid->points[i][j][1], grid->points[i][j][2]); + if (p == -1) + Com_Error(ERR_DROP, "CM_GridPlane: right %f %f %f\n", grid->points[i][j][0], grid->points[i][j][1], grid->points[i][j][2]); VectorMA(p1, 4, planes[p].plane, up); return CM_FindPlane(p1, p2, up); @@ -737,7 +742,8 @@ static int CM_EdgePlaneNum(cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRID p1 = grid->points[i + 1][j + 1]; p2 = grid->points[i][j]; p = CM_GridPlane(gridPlanes, i, j, 0); - if (p == -1) Com_Printf(" diag0 %f %f %f\n", grid->points[i + 1][j+1][0], grid->points[i + 1][j+1][1], grid->points[i + 1][j+1][2]); + if (p == -1) + Com_Error(ERR_DROP, "CM_GridPlane: diag0 %f %f %f\n", grid->points[i + 1][j+1][0], grid->points[i + 1][j+1][1], grid->points[i + 1][j+1][2]); VectorMA(p1, 4, planes[p].plane, up); return CM_FindPlane(p1, p2, up); @@ -745,10 +751,14 @@ static int CM_EdgePlaneNum(cGrid_t *grid, int gridPlanes[MAX_GRID_SIZE][MAX_GRID p1 = grid->points[i][j]; p2 = grid->points[i + 1][j + 1]; p = CM_GridPlane(gridPlanes, i, j, 1); - if (p == -1) Com_Printf(" diag1 %f %f %f\n", grid->points[i + 1][j][0], grid->points[i + 1][j][1], grid->points[i + 1][j][2]); + if (p == -1) + Com_Error(ERR_DROP, "CM_GridPlane: diag1 %f %f %f\n", grid->points[i + 1][j][0], grid->points[i + 1][j][1], grid->points[i + 1][j][2]); VectorMA(p1, 4, planes[p].plane, up); return CM_FindPlane(p1, p2, up); + default: + break; + } Com_Error(ERR_DROP, "CM_EdgePlaneNum: bad k"); diff --git a/code/qcommon/cm_polylib.h b/code/qcommon/cm_polylib.h index 38ef703..3e31e90 100644 --- a/code/qcommon/cm_polylib.h +++ b/code/qcommon/cm_polylib.h @@ -24,15 +24,18 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define CM_POLYLIB_H // this is only used for visualization tools in cm_ debug functions - +#ifdef BSPC //hypov8 use kass +#include "../kaas/l_poly.h" +#else typedef struct { int numpoints; vec3_t p[4]; // variable sized } winding_t; - + #define MAX_POINTS_ON_WINDING 64 +#endif #if 0 #define SIDE_FRONT 0 diff --git a/code/qcommon/q_platform.h b/code/qcommon/q_platform.h index 7a88bd0..050ba29 100644 --- a/code/qcommon/q_platform.h +++ b/code/qcommon/q_platform.h @@ -19,6 +19,7 @@ along with Quake III Arena source code; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ + #ifndef __Q_PLATFORM_H #define __Q_PLATFORM_H @@ -37,7 +38,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define idppc_altivec 0 #define idsparc 0 -#else +#else // !Q3_VM #if (defined _M_IX86 || defined __i386__) && !defined(C_ONLY) #define id386 1 diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 420abd5..5834b28 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -318,6 +318,8 @@ typedef enum { #else # ifndef BSPC //hypov8 void *Hunk_Alloc(int size, ha_pref preference); +# else + void *Hunk_Alloc(size_t size, ha_pref preference); # endif #endif @@ -338,13 +340,9 @@ typedef enum { #define CIN_shader 16 // this is only here so the functions in q_shared.c and bg_*.c can link - -#ifndef BSPC //_MSC_VER //BSPC //hypov8 void QDECL Com_Error(int level, const char *error, ...) __attribute__ ((format (printf, 2, 3))); void QDECL Com_Printf(const char *msg, ...) __attribute__ ((format (printf, 1, 2))); -#else - //todo -#endif + /* ============================================================== @@ -749,38 +747,6 @@ void ByteToDir(int b, vec3_t dir); unsigned ColorBytes3 (float r, float g, float b); unsigned ColorBytes4 (float r, float g, float b, float a); -#ifdef BSPC //hypov8 add -// -//double Vector_Length(vec3_t v); -//cm_trace.cc -void RotatePoint(vec3_t point, float matrix[3][3]); -//void CreateRotationMatrix(const vec3_t angles, vec3_t matrix[3]); -//void CreateRotationMatrix(vec3_t angles, float matrix[3][3]); - -void KAAS_Com_Error(int level, char *error, ...); -void KAAS_Com_Printf(const char *fmt, ...); -void KAAS_Com_DPrintf(char *fmt, ...); -#define Com_Error KAAS_Com_Error -#define Com_Printf KAAS_Com_Printf -#define Com_DPrintf KAAS_Com_DPrintf -//int BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, cplane_t *p); - -//hypov8 todo rename these for kaas -#define Vec3_DotProduct DotProduct -#define Vec3_Copy VectorCopy -#define Vec3_Inverse VectorInverse //hypov8 now macro -#define Vec3_Add VectorAdd -#define Vec3_Scale VectorScale -#define Vec3_Clear VectorClear -#define Vec3_MA VectorMA -#define Vec3_Negate VectorNegate -#define Vec3_Subtract VectorSubtract -#define Vec4_Copy Vector4Copy - -#define Vector_Length VectorLength - -extern vec3_t vec3_origin; -#endif //FIXME (0xA5EA): brakes aas build ? float NormalizeColor(const vec3_t in, vec3_t out); @@ -1719,7 +1685,7 @@ typedef enum { CHAN_ANNOUNCER // announcer voices, etc } soundChannel_t; -#if 2 //ndef BSPC //hypov8 +#if 1 //ndef BSPC //hypov8 #ifndef Q3_VM extern force_inline int BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs, struct cplane_s * p) { diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index 553001a..bc60ff2 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -757,7 +757,7 @@ void Info_Print(const char *s); void Com_BeginRedirect(char *buffer, int buffersize, void (*flush)(char *)); void Com_EndRedirect(void); -#ifndef BSPC +#if 1 //ndef BSPC void QDECL Com_Printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); void QDECL Com_DPrintf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); void QDECL Com_Error( int code, const char *fmt, ... ) __attribute__ ((noreturn, format(printf, 2, 3))); @@ -873,9 +873,7 @@ void *Z_MallocDebug(int size, char *label, char *file, int line); // void *S_MallocDebug(int size, char *label, char *file, int line); // returns 0 filled memory #else void *Z_TagMalloc(size_t size, int tag); // NOT 0 filled memory -#ifndef BSPC void *Z_Malloc(size_t size); // returns 0 filled memory -#endif void *S_Malloc(size_t size); // NOT 0 filled memory only for small allocations #endif void Z_Free(void *ptr); diff --git a/code/qcommon/qfiles.h b/code/qcommon/qfiles.h index fa6f305..41af8a7 100644 --- a/code/qcommon/qfiles.h +++ b/code/qcommon/qfiles.h @@ -37,7 +37,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif // surface geometry should not exceed these limits -#define SHADER_MAX_VERTEXES 10000 +#define SHADER_MAX_VERTEXES 10000 // match kmap2, was 100000. hypov8 todo check this #define SHADER_MAX_INDEXES (SHADER_MAX_VERTEXES * 6) #define SHADER_MAX_TRIANGLES (SHADER_MAX_INDEXES / 3) @@ -186,7 +186,7 @@ typedef struct int ident; int version; - char name[64]; // model name + char name[64]; // model name int flags; @@ -872,7 +872,7 @@ typedef struct } dmodel_t; typedef struct { - char shader[64]; + char shader[64]; // MAX_QPATH int surfaceFlags; int contentFlags; } dshader_t; @@ -910,7 +910,7 @@ typedef struct typedef struct { - int planeNum; // positive plane side faces out of the leaf + int planeNum; // positive plane side faces out of the leaf int shaderNum; } dbrushside_t; @@ -922,7 +922,7 @@ typedef struct } dbrush_t; typedef struct { - char shader[64]; + char shader[64]; //MAX_QPATH int brushNum; int visibleSide; // the brush side that ray tests need to clip against (-1 == none) } dfog_t; @@ -930,8 +930,8 @@ typedef struct { // light grid typedef struct { - float ambient[3]; //hypov8 kpq3 float, was byte - float directed[3]; //hypov8 kpq3 float, was byte + float ambient[3]; //hypov8 kpq3 float(was byte). kmap2 = xbspGridPoint_t + float directed[3]; //hypov8 kpq3 float, was byte byte latLong[2]; } dgridPoint_t; diff --git a/code/renderer/tr_init.cc b/code/renderer/tr_init.cc index c45514d..c11cd55 100644 --- a/code/renderer/tr_init.cc +++ b/code/renderer/tr_init.cc @@ -1416,8 +1416,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA r_compressDiffuseMaps = ri.Cvar_Get( "r_compressDiffuseMaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_compressSpecularMaps = ri.Cvar_Get( "r_compressSpecularMaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_compressNormalMaps = ri.Cvar_Get( "r_compressNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_heatHaze = ri.Cvar_Get( "r_heatHaze", "0", CVAR_ARCHIVE ); - r_heatHazeFix = ri.Cvar_Get( "r_heatHazeFix", "0", CVAR_CHEAT | CVAR_SHADER ); + r_heatHaze = ri.Cvar_Get( "r_heatHaze", "0", CVAR_ROM | CVAR_ARCHIVE ); //hypov8 disable for beta. crashing + r_heatHazeFix = ri.Cvar_Get( "r_heatHazeFix", "0", CVAR_ROM | CVAR_SHADER ); //CVAR_CHEAT r_noMarksOnTrisurfs = ri.Cvar_Get( "r_noMarksOnTrisurfs", "1", CVAR_CHEAT ); r_recompileShaders = ri.Cvar_Get( "r_recompileShaders", "0", CVAR_ARCHIVE ); r_lazyShaders = ri.Cvar_Get( "r_lazyShaders", "0", CVAR_ARCHIVE ); diff --git a/code/renderer/tr_model_md3.cc b/code/renderer/tr_model_md3.cc index d681952..53824fd 100644 --- a/code/renderer/tr_model_md3.cc +++ b/code/renderer/tr_model_md3.cc @@ -86,6 +86,11 @@ qboolean R_LoadMD3( model_t *mod, int lod, void *buffer, int bufferSize, const c int version; int size; +#if defined(COMPAT_KPQ3) + //use frame dimensions for scale(reduce wobbles) + qboolean isHd = qfalse; +#endif + md3Model = ( md3Header_t * ) buffer; version = LittleLong( md3Model->version ); @@ -95,7 +100,14 @@ qboolean R_LoadMD3( model_t *mod, int lod, void *buffer, int bufferSize, const c ri.Printf( PRINT_WARNING, "R_LoadMD3: %s has wrong version (%i should be %i)\n", modName, version, MD3_VERSION ); return qfalse; } - +#if defined(COMPAT_KPQ3) + //use frame dimensions for scale(reduce wobbles) + //memcompare + if (md3Model->name[59] == 'K' && md3Model->name[60] == 'P' && + md3Model->name[61] == 'Q' && md3Model->name[62] == '3' + ) //0x00 4b 50 51 33 00 'KPQ3' + isHd = qtrue; +#endif mod->type = MOD_MESH; size = LittleLong( md3Model->ofsEnd ); mod->dataSize += size; @@ -242,7 +254,8 @@ qboolean R_LoadMD3( model_t *mod, int lod, void *buffer, int bufferSize, const c // only consider the first shader md3Shader = ( md3Shader_t * )( ( byte * ) md3Surf + md3Surf->ofsShaders ); surf->shader = R_FindShader( md3Shader->name, SHADER_3D_DYNAMIC, RSF_DEFAULT ); -#if HYPODEBUG + +#if HYPODEBUG //default for debug/developer? if (surf->shader->defaultShader) //hypov8 add. show the model with invalid textures { surf->shader = R_FindShader("_white", SHADER_3D_DYNAMIC, RSF_DEFAULT); @@ -268,11 +281,46 @@ qboolean R_LoadMD3( model_t *mod, int lod, void *buffer, int bufferSize, const c md3xyz = ( md3XyzNormal_t * )( ( byte * ) md3Surf + md3Surf->ofsXyzNormals ); + frame = mdvModel->frames; for ( j = 0; j < md3Surf->numVerts * md3Surf->numFrames; j++, md3xyz++, v++ ) { - v->xyz[ 0 ] = LittleShort( md3xyz->xyz[ 0 ] ) * MD3_XYZ_SCALE; - v->xyz[ 1 ] = LittleShort( md3xyz->xyz[ 1 ] ) * MD3_XYZ_SCALE; - v->xyz[ 2 ] = LittleShort( md3xyz->xyz[ 2 ] ) * MD3_XYZ_SCALE; +#if defined(COMPAT_KPQ3) + if (isHd) + { + double scH = 32768.0; + //calculate scale. not stored in model like md2. + double scale[3] = { //todo move this. not needed every vert + (frame->bounds[1][0] - frame->bounds[0][0]) / 65535.0, + (frame->bounds[1][1] - frame->bounds[0][1]) / 65535.0, + (frame->bounds[1][2] - frame->bounds[0][2]) / 65535.0 + }; + + //get vert locations. convert to unsigned int for +scale + v->xyz[0] = LittleShort(md3xyz->xyz[0]) + scH; + v->xyz[1] = LittleShort(md3xyz->xyz[1]) + scH; + v->xyz[2] = LittleShort(md3xyz->xyz[2]) + scH; + + //add scale. + v->xyz[0] *= scale[0]; + v->xyz[1] *= scale[1]; + v->xyz[2] *= scale[2]; + + //relocate to objects origin + v->xyz[0] += frame->bounds[0][0]; + v->xyz[1] += frame->bounds[0][1]; + v->xyz[2] += frame->bounds[0][2]; + + //next frame + if (((j+1) % md3Surf->numVerts) == 0) + frame++; + } + else +#endif + { + v->xyz[0] = LittleShort(md3xyz->xyz[0]) * MD3_XYZ_SCALE; + v->xyz[1] = LittleShort(md3xyz->xyz[1]) * MD3_XYZ_SCALE; + v->xyz[2] = LittleShort(md3xyz->xyz[2]) * MD3_XYZ_SCALE; + } } // swap all the ST diff --git a/kmap2/common/qfiles.h b/kmap2/common/qfiles.h index 93eb584..6196375 100644 --- a/kmap2/common/qfiles.h +++ b/kmap2/common/qfiles.h @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // // surface geometry should not exceed these limits -#define SHADER_MAX_VERTEXES 100000 +#define SHADER_MAX_VERTEXES 10000 //0 //hypov8 match engine #define SHADER_MAX_INDEXES (SHADER_MAX_VERTEXES * 6) #define SHADER_MAX_TRIANGLES (SHADER_MAX_INDEXES / 3)