From 62029a8ea9a5c637de6fef9d5eba2a1069be9e59 Mon Sep 17 00:00:00 2001 From: zwwooooo Date: Wed, 11 Jan 2023 14:31:08 +0800 Subject: [PATCH 001/120] Chinese translation update(by TBS) --- Utils/_ChineseText.cpp | 8 ++++---- Utils/_Ja25ChineseText.cpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Utils/_ChineseText.cpp b/Utils/_ChineseText.cpp index bf3a913f..8ab30522 100644 --- a/Utils/_ChineseText.cpp +++ b/Utils/_ChineseText.cpp @@ -3226,11 +3226,11 @@ STR16 gzMercSkillTextNew[] = // new minor traits L"无线电操作员", // 21 L"告发", // 22 - L"生还者", //L"Survival" + L"向导", //L"Survival" // second names for major skills L"机枪手", // 24 - L"掷弹兵", + L"枪炮专家", //L"Bombardier", L"狙击手", L"游骑兵", L"枪斗术", @@ -3252,7 +3252,7 @@ STR16 gzMercSkillTextNew[] = L"间谍", // 43 L"Placeholder", // for radio operator (minor trait) L"Placeholder", // for snitch (minor trait) - L"生还者", // for survival (minor trait) + L"向导", // for survival (minor trait) L"更多...", // 47 L"情报", //L"Intel", for INTEL L"伪装", //L"Disguise", for DISGUISE @@ -7826,7 +7826,7 @@ STR16 MissingIMPSkillsDescriptions[] = // Radio Operator L"无线电操作员:你通过使用通讯设备让队伍的战略和战术水平得到了提升。 ± ", //L"Radio Operator: Your usage of communication devices broaden your team's tactical and strategic skills. ± ", // Survival - L"生还者: 大自然是你第二个家。 ± ", //L"Survival: Nature is a second home to you. ± ", + L"向导: 大自然是你第二个家。 ± ", //L"Survival: Nature is a second home to you. ± ", }; STR16 NewInvMessage[] = diff --git a/Utils/_Ja25ChineseText.cpp b/Utils/_Ja25ChineseText.cpp index 6c60c972..bfa02af4 100644 --- a/Utils/_Ja25ChineseText.cpp +++ b/Utils/_Ja25ChineseText.cpp @@ -59,7 +59,7 @@ STR16 gzIMPSkillTraitsTextNewMajor[]= L"I.M.P 主要特殊技能",// L"I.M.P. Major Traits", // second names L"机枪手",// L"Machinegunner", - L"掷弹兵",// L"Bombardier", + L"枪炮专家",// L"Bombardier", L"狙击手",// L"Sniper", L"游骑兵",// L"Ranger", L"枪斗术",// L"Gunfighter", @@ -74,7 +74,7 @@ STR16 gzIMPSkillTraitsTextNewMajor[]= STR16 gzIMPSkillTraitsTextNewMinor[]= { L"双持",// L"Ambidextrous", - L"格斗",// L"Melee", + L"近战",// L"Melee", L"投掷",// L"Throwing", L"夜战",// L"Night Ops", L"潜行",// L"Stealthy", @@ -84,7 +84,7 @@ STR16 gzIMPSkillTraitsTextNewMinor[]= L"教学",// L"Teaching", L"侦察",// L"Scouting", L"无线电操作员", //L"Radio Operator", - L"生还者", //L"Survival", + L"向导", //L"Survival", L"无",// L"None", L"I.M.P 副技能",// L"I.M.P. Minor Traits", @@ -450,18 +450,18 @@ STR16 gzIMPOldSkillTraitsHelpTexts[]= STR16 gzIMPNewCharacterTraitsHelpTexts[]= { L"优点:无。\n缺点:无。",// L"A: No advantage.\nD: No disadvantage.", - L"优点:身边有多个雇佣兵时表现最佳。\n缺点:孤单一人时士气不会上升。",// L"A: Has better performance when couple of mercs are nearby.\nD: Gains no morale when no other merc is nearby.", + L"优点:身边有多个佣兵时表现最佳。\n缺点:孤单一人时士气不会上升。",// L"A: Has better performance when couple of mercs are nearby.\nD: Gains no morale when no other merc is nearby.", L"优点:独自行动时表现最好。\n缺点:在团队中士气不会上升。",// L"A: Has better performance when no other merc is nearby.\nD: Gains no morale when in a group.", L"优点:士气上升得快,下降得慢。\n缺点:发现地雷和陷阱的几率降低了。",// L"A: His morale sinks a little slower and grows faster than normal.\nD: Has lesser chance to detect traps and mines.", L"优点:更善于训练民兵和跟别人交流。\n缺点:士气不会因为其他队员的行为而上升。",// L"A: Has bonus on training militia and is better at communication with people.\nD: Gains no morale for actions of other mercs.", - L"优点:自我锻炼或学习效率略高。\n缺点:减少对恐惧和火力压制的承受力。",// L"A: Slightly faster learning when assigned on practicing or as a student.\nD: Has lesser suppression and fear resistance.", + L"优点:自我锻炼或学习效率略微提高。\n缺点:减少对恐惧和火力压制的承受力。",// L"A: Slightly faster learning when assigned on practicing or as a student.\nD: Has lesser suppression and fear resistance.", L"优点:减少一切行动的体能消耗(除了医疗、修理、训练民兵和学习某种技能)。\n缺点:智力、领导能力、爆破、修理和医疗技术提高得慢一些。",// L"A: His energy goes down a bit slower except on assignments as doctor, repairman, militia trainer or if learning certain skills.\nD: His wisdom, leadership, explosives, mechanical and medical skills improve slightly slower.", - L"优点:点射/自动模式下命中率,近战杀伤力和消灭敌人所得的时期更高。\n缺点:需要耐心的行为会得到效率惩罚,比如修理、开锁、解除陷阱、医治和训练民兵。",// L"A: Has slightly better chance to hit on burst/autofire and inflicts slightly bigger damage in close combat\n Gains a little more morale for killing.\nD: Has penalty for actions which needs patience like repairing items, picking locks, removing traps, doctoring, training militia.", + L"优点:点射/自动模式下命中率,近战杀伤力和消灭敌人所得的期望更高。\n缺点:需要耐心的行为会得到效率惩罚,比如修理、开锁、解除陷阱、医治和训练民兵。",// L"A: Has slightly better chance to hit on burst/autofire and inflicts slightly bigger damage in close combat\n Gains a little more morale for killing.\nD: Has penalty for actions which needs patience like repairing items, picking locks, removing traps, doctoring, training militia.", L"优点:需要耐心的工作会得到效率奖励,比如修理、撬锁、解除陷阱、医治和训练民兵。\n缺点:略微降低中断率。",// L"A: Has bonus for actions which needs patience like repairing items, picking locks, removing traps, doctoring and training militia.\nD: His interrupts chance is slightly lowered.", - L"优点:增加对火力压制和恐惧的承受力,\n负伤其他雇佣兵阵亡对他的士气影响的也比较小。\n缺点:容易成为敌人的移动靶。",// L"A: Incresed resistance to suppression and fear.\n Morale loss for taking damage and companions deaths is lower for him.\nD: Can be hit easier and enemy penalty for moving target is lesser in his case.", + L"优点:增加对火力压制和恐惧的承受力。\n负伤其他佣兵阵亡对他的士气影响的也比较小。\n缺点:容易成为敌人的移动靶。",// L"A: Incresed resistance to suppression and fear.\n Morale loss for taking damage and companions deaths is lower for him.\nD: Can be hit easier and enemy penalty for moving target is lesser in his case.", L"优点:进行非战斗任务时士气会提升(除了训练民兵)。\n缺点:杀人不增加士气。",// L"A: He gains morale when on non-combat assignments (except training militia).\nD: Gains no morale for killing.", L"优点:攻击有更高的几率能造成受害者属性值降低,和更严重的创伤,同时提高自己的士气。\n缺点:与其他人交流是个问题,脱离战斗后士气也会快速下沉。",// L"A: Has bigger chance for inflicting stat loss and can inflict special painful wounds when able to\n Gains bonus morale for inflicting stat loss.\nD: Has penalty for communication with people and his morale sinks faster if not fighting.", - L"优点:附近有异性雇佣兵时表现更佳。\n缺点:附近所有同性雇佣兵士气提升得慢。",// L"A: Has better performance when there are some mercs of opposite gender nearby.\nD: Morale of other mercs of the same gender grows slower if nearby.", + L"优点:附近有异性佣兵时表现更佳。\n缺点:附近所有同性佣兵士气提升得慢。",// L"A: Has better performance when there are some mercs of opposite gender nearby.\nD: Morale of other mercs of the same gender grows slower if nearby.", L"优点:撤退时士气增加。\n缺点:敌众我寡时,会降低士气。", //L"A: Gains morale when retreating.\nD: Loses morale when encountering numerically superior enemy forces.", }; From 0ac6c3eb2ded7b1dbf9ba460a0bd8d7687edc1ef Mon Sep 17 00:00:00 2001 From: zwwooooo Date: Wed, 12 Apr 2023 13:54:16 +0800 Subject: [PATCH 002/120] Chinese translation update(by TBS) --- Utils/_ChineseText.cpp | 30 +++++++++++++++--------------- Utils/_Ja25ChineseText.cpp | 20 ++++++++++---------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Utils/_ChineseText.cpp b/Utils/_ChineseText.cpp index 695fc592..68d32c8b 100644 --- a/Utils/_ChineseText.cpp +++ b/Utils/_ChineseText.cpp @@ -6213,7 +6213,7 @@ STR16 zOptionsText[] = STR16 z113FeaturesScreenText[] = { L"1.13 特征功能", //L"1.13 FEATURE TOGGLES", - L"在游戏中更改这些选项将影响您的游戏体验。", //L"Changing these settings during a campaign will affect your experience.", + L"在游戏中更改这些选项将影响您的游戏体验。(更改后必须重新开始新游戏)", //L"Changing these settings during a campaign will affect your experience.", L"将鼠标悬停在功能按钮上以获得更多信息。某些功能需要在JA2_Options.ini(或其他文件)中设置。", //L"Hover over a feature to display more information. Some features may be configurable in JA2_Options.ini (or other specified file).", }; @@ -6532,7 +6532,7 @@ STR16 zOptionsToggleText[] = L"实时确认", //"Real Time Confirmation", L"显示睡觉/醒来时的提示", //"Display sleep/wake notifications", L"使用公制系统", //"Use Metric System", - L"佣兵假光", //"Highlight Mercs", + L"高亮显示佣兵", //"Highlight Mercs", L"锁定佣兵", //"Snap Cursor to Mercs", L"锁定门", //"Snap Cursor to Doors", L"物品闪亮", //"Make Items Glow", @@ -6574,8 +6574,8 @@ STR16 zOptionsToggleText[] = L"反转鼠标滚轮", //L"Invert mouse wheel", L"保持佣兵间距", // when multiple mercs are selected, they will try to keep their relative distances L"显示已知敌人位置", //L"Show enemy location", show locator on last known enemy location - L"Start at maximum aim", - L"Alternative pathfinding", + L"准心开始时为最大", // L"Start at maximum aim", + L"替换新的寻路方式", // L"Alternative pathfinding", L"--作弊模式选项--", // TOPTION_CHEAT_MODE_OPTIONS_HEADER, L"强制 Bobby Ray 送货", // force all pending Bobby Ray shipments L"-----------------", // TOPTION_CHEAT_MODE_OPTIONS_END @@ -6637,7 +6637,7 @@ STR16 zOptionsScreenHelpText[] = L"打开时,使用公制系统,否则使用英制系统。", //Highlight Mercs - L"打开时,切换虚拟佣兵照明。(|G)", + L"打开时,虚拟灯光会照亮佣兵周围。(|G)", //L"When ON, highlights the mercenary (Not visible to enemies).\nToggle in-game with (|G)", //Smart cursor L"打开时,光标移动到佣兵身上时会高亮显示佣兵。", @@ -6693,10 +6693,10 @@ STR16 zOptionsScreenHelpText[] = L"打开时,会直接显示该区域最后一个敌人的大致位置。", L"打开时,在区域物品栏界面,右键点击装有物品的携行具时可直接显示包含的物品。", L"打开时,反转鼠标滚轮方向。", - L"打开时,当选择多个佣兵,在前进时会保持彼此的间距。|C|t|r|l+|A|l|t+|G \n(按|S|h|i|f|t+点击人物头像可以加入或移出队伍)", //L"When ON and multiple mercs are selected, they will try to keep their relative distances while moving.\n(press |C|t|r|l+|A|l|t+|G to toggle mode or |S|h|i|f|t + click to move in formation)", TODO.Translate + L"打开时,当选择多个佣兵,在前进时会保持彼此的间距。|C|t|r|l+|A|l|t+|G \n(按|S|h|i|f|t+点击人物头像可以加入或移出队伍)", //L"When ON and multiple mercs are selected, they will try to keep their relative distances while moving.\n(press |C|t|r|l+|A|l|t+|G to toggle mode or |S|h|i|f|t + click to move in formation)", L"打开时,会显示已知敌人最后移动的位置。", //L"When ON, shows last known enemy location.", - L"When ON, aiming at enemy will start at maximum aiming instead of default no aim", - L"When ON, Use A* pathfinding algorithm, instead of original", + L"打开时,默认瞄准值为最大,而不是无。", //L"When ON, aiming at enemy will start at maximum aiming instead of default no aim", + L"打开时,使用A*寻路算法,而不是原始算法。", //L"When ON, Use A* pathfinding algorithm, instead of original", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_HEADER", L"强制 Bobby Ray 出货", L"(text not rendered)TOPTION_CHEAT_MODE_OPTIONS_END", @@ -7032,7 +7032,7 @@ STR16 pMessageStrings[] = L"磁盘空间不足。只有%sMB可用空间,《铁血联盟2》需要%sMB。", L"从AIM雇佣了%s。", //"Hired %s from AIM", L"%s抓住了%s。", //"%s has caught %s.", //'Merc name' has caught 'item' -- let SirTech know if name comes after item. - L"%s使用了(拾取)%s。", //L"%s has taken %s。", + L"%s(使用了、拾取了、中了)%s。", //L"%s has taken %s。", L"%s没有医疗技能", //"%s has no medical skill",//'Merc name' has no medical skill. //CDRom errors (such as ejecting CD while attempting to read the CD) @@ -7131,7 +7131,7 @@ STR16 pMessageStrings[] = L"虚拟佣兵光照开启", L"虚拟佣兵光照关闭", L"军队%s活动。", //L"Squad %s active.", - L"%s作弊者%s。", //L"%s smoked %s.", + L"%s抽了只%s。", //L"%s smoked %s.", L"激活作弊?", //L"Activate cheats?", L"关闭作弊?", //L"Deactivate cheats?", }; @@ -8133,7 +8133,7 @@ STR16 gzIMPDisabilityTraitText[]= L"身心健全", L"怕热", L"神经质", - L"幽闭恐慌症", + L"幽闭恐惧症", L"旱鸭子", L"怕虫", L"健忘", @@ -9198,8 +9198,8 @@ STR16 szPrisonerTextStr[]= L"一个高阶军官%s被发现!", //L"A high-ranking army officer in %s has been revealed!", L"敌方领袖拒绝考虑投降!", //L"The enemy leader refuses to even consider surrender!", L"%d名囚犯自愿加入我军。", //L"%d prisoners volunteered to join our forces.", - L"Some of your mercs managed to escape the enemy capture!", - L"No possible escape is seen, it's a fight to the death!" + L"你的佣兵成功逃脱了敌人的追捕。", //L"Some of your mercs managed to escape the enemy capture!", + L"没有逃跑与投降,只有死战到底!", //L"No possible escape is seen, it's a fight to the death!", }; STR16 szMTATextStr[]= @@ -11997,7 +11997,7 @@ STR16 szRebelCommandHelpText[] = L"|指|挥|部\n \n指挥部一旦部署,就会负责处理\n该区域内的日常事务。包括支持当地人,制造\n反抗宣传,制定地区政策等等。", //L"|A|d|m|i|n|i|s|t|r|a|t|i|o|n |T|e|a|m\n \nOnce deployed, an admin team is responsible for handling the\nday-to-day affairs of the region. This includes supporting\nlocals, creating rebel propaganda, establishing regional\npolicies, and more.", L"|忠|诚|度\n \n许多行政命令的有效性取决于\n该地区的忠诚度,提高忠诚度\n能得到最大利益化。", //L"|L|o|y|a|l|t|y\n \nThe effectiveness of many Administrative Actions depends on\nthe region's loyalty to your cause. It is in your best interest\nto raise loyalty as high as possible.", L"|最|高|忠|诚|度\n \n你需要说服当地人完全信任你。这可以\n通过为他们建立物资供应来实现,表明\n你打算改善他们的生活质量。", //L"|M|a|x|i|m|u|m |L|o|y|a|l|t|y\n \nYou will need to convince the locals to fully trust you. This\ncan be done by creating a supply line to them, showing that\nyou intend to improve their quality of life.", - L"该管理行动只会作用到城镇区域。", //L"This Admin Action applies its bonus to town sectors only.", TODO.Translate + L"该管理行动只会作用到城镇区域。", //L"This Admin Action applies its bonus to town sectors only.", L"该管理行动会作用到城镇区域。\n和直接相邻的区域。", //L"This Admin Action applies its bonus to town sectors, and\nsectors immediately adjacent to them.", L"该管理行动会作用到城镇区域。\n1级覆盖周边1个区域。\n2级覆盖周边2个区域。", //L"This Admin Action applies its bonus to town sectors, one\nsector away at Tier 1, and up to two sectors away at Tier 2.", L"该管理行动会作用到城镇区域。\n1级覆盖周边2个区域。\n2级覆盖周边3个区域。", //L"This Admin Action applies its bonus to town sectors, up to\ntwo sectors away at Tier 1, and up to three sectors away at Tier 2.", @@ -12111,7 +12111,7 @@ STR16 szRebelCommandAgentMissionsText[] = L"临时增加对这个城镇的直接援助。城镇忠诚度会在任务期间被动提升。", //L"Temporarily increase direct support to this town. Town loyalty passively increases for the duration of the mission.", L"士兵悬赏(Kingpin)", //L"Soldier Bounties (Kingpin)", L"杀敌以获得资金奖励。和Kingpin谈谈,他感觉可以利用你的存在来削弱女王的权威。奖金会在午夜存入你的账户,每天最多$%d。", //L"Get a payout for enemy kills. Negotiate with Kingpin, who feels he can use your presence here to indirectly weaken the Queen's power. Bounties are deposited into your account at midnight and are limited to $%d per day.", - L"在任意地方训练民兵", //L"Train Militia Anywhere", + L"在城镇外任意地区训练民兵", //L"Train Militia Anywhere", L"野外训练区是可以快速设立和拆毁的。民兵可以在城镇外的非交战区接受训练。", //L"Create training areas in the wilderness that can be quickly set up and torn down. Militia can be trained in uncontested sectors outside of town.", }; diff --git a/Utils/_Ja25ChineseText.cpp b/Utils/_Ja25ChineseText.cpp index bfa02af4..1a6feedd 100644 --- a/Utils/_Ja25ChineseText.cpp +++ b/Utils/_Ja25ChineseText.cpp @@ -467,18 +467,18 @@ STR16 gzIMPNewCharacterTraitsHelpTexts[]= STR16 gzIMPDisabilitiesHelpTexts[]= { - L"没有其他附加效果。",// L"No effects.", - L"可能会在热带和沙漠地区呼吸困难,降低综合表现。",// L"Has problems with breathing and reduced overall performance if in tropical or desert sectors.", - L"可能会孤单一人在某些情况下感到恐慌。",// L"Can suffer panic attack if left alone in certain situations.", - L"可能会进入地下后降低综合表现。",// L"His overall performance is reduced if underground.", - L"可能会在游泳时轻易的溺水。",// L"If trying to swim he can easily drown.", - L"可能会在看到大虫子后六神无主,也会在热带地区降低综合表现。",// L"A look at large insects can make a big problems\nand being in tropical sectors also reduce his performance a bit.", - L"可能会偶尔忘记手头的任务,也会在战斗中损失行动点。",// L"Sometimes forgets what orders he got and therefore loses some APs if in combat.", - L"可能会偶尔发疯并把手里武器设在自动后乱喷。\n如果武器不能自动射击将会打击自身士气。",// L"He can go psycho and shoot like mad once per a while\nand can lose morale if unable to do that with given weapon.", + L"没有其它附加效果。",// L"No effects.", + L"在热带或沙漠区域,会出现呼吸问题降低综合表现。",// L"Has problems with breathing and reduced overall performance if in tropical or desert sectors.", + L"独自一人时可能会感到恐慌。",// L"Can suffer panic attack if left alone in certain situations.", + L"在封闭空间或地下时会降低综合表现。",// L"His overall performance is reduced if underground.", + L"在游泳时会轻易的溺水。",// L"If trying to swim he can easily drown.", + L"看到大虫子后会六神无主,也会在热带地区降低综合表现。",// L"A look at large insects can make a big problems\nand being in tropical sectors also reduce his performance a bit.", + L"偶尔会忘记手头的任务,也会在战斗中损失些行动点。",// L"Sometimes forgets what orders he got and therefore loses some APs if in combat.", + L"偶尔会发疯并把手里的武器设为自动乱喷。\n如果武器不能自动射击将会打击自身士气。",// L"He can go psycho and shoot like mad once per a while\nand can lose morale if unable to do that with given weapon.", L"大大减少听力范围。", // L"Drastically reduced hearing.", L"减少视力范围。", // L"Reduced sight range.", - L"大大增加的流血速度。", //L"Drastically increased bleeding.", - L"在房顶上会降低战斗力。", //L"Performance suffers while on a rooftop.", + L"大大增加流血速度。", //L"Drastically increased bleeding.", + L"在房顶作战时会降低战斗力。", //L"Performance suffers while on a rooftop.", L"时不时自残。", //L"Occasionally harms self.", }; From c8c7066969686a08318a8b9d63b091925ec3af34 Mon Sep 17 00:00:00 2001 From: majcosta <34732933+majcosta@users.noreply.github.com> Date: Fri, 28 Jul 2023 12:07:25 -0300 Subject: [PATCH 003/120] Refactor merc backpack checking in `FindBestPath` (#162) * remove unused fNonFenceJumper from AstarPathfinder::GetPath * Extract backpack check into function and flip logic Avoiding double negatives is nice --- Tactical/PATHAI.H | 1 - Tactical/PATHAI.cpp | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Tactical/PATHAI.H b/Tactical/PATHAI.H index c48a06a3..cf80a125 100644 --- a/Tactical/PATHAI.H +++ b/Tactical/PATHAI.H @@ -76,7 +76,6 @@ private: SOLDIERTYPE* pSoldier; INT8 onRooftop;//aka ubLevel, not sure if this bool is logically reversed yet - bool fNonFenceJumper; bool fNonSwimmer; bool fPathingForPlayer; bool fPathAroundPeople; diff --git a/Tactical/PATHAI.cpp b/Tactical/PATHAI.cpp index 45c76ca8..c8543b59 100644 --- a/Tactical/PATHAI.cpp +++ b/Tactical/PATHAI.cpp @@ -454,6 +454,11 @@ UINT32 guiFailedPathChecks = 0; UINT32 guiUnsuccessfulPathChecks = 0; #endif + +static auto canJumpFences(SOLDIERTYPE* pSoldier) -> bool { + return IS_MERC_BODY_TYPE(pSoldier) && pSoldier->CanClimbWithCurrentBackpack(); +} + //ADB the extra cover feature is supposed to pick a path of the same distance as one calculated with the feature off, //but a safer path, usually farther away from an enemy or following behind some cover. //however it has not been tested and it may need some work, I haven't touched it in a while @@ -638,7 +643,6 @@ int AStarPathfinder::GetPath(SOLDIERTYPE *s , fTurnBased = ( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT) ); fPathingForPlayer = ( (pSoldier->bTeam == gbPlayerNum) && (!gTacticalStatus.fAutoBandageMode) && !(pSoldier->flags.uiStatusFlags & SOLDIER_PCUNDERAICONTROL) ); - fNonFenceJumper = !( IS_MERC_BODY_TYPE( pSoldier ) ); fNonSwimmer = !( IS_MERC_BODY_TYPE( pSoldier ) ); fPathAroundPeople = ( (fFlags & PATH_THROUGH_PEOPLE) == 0 ); fCloseGoodEnough = ( (fFlags & PATH_CLOSE_GOOD_ENOUGH) != 0); @@ -2244,7 +2248,6 @@ INT32 FindBestPath(SOLDIERTYPE *s , INT32 sDestination, INT8 bLevel, INT16 usMov DOOR * pDoor; STRUCTURE * pDoorStructure; BOOLEAN fDoorIsOpen = FALSE; - BOOLEAN fNonFenceJumper; BOOLEAN fNonSwimmer; BOOLEAN fPathAroundPeople; BOOLEAN fConsiderPersonAtDestAsObstacle; @@ -2316,7 +2319,6 @@ if(!GridNoOnVisibleWorldTile(iDestination)) fTurnBased = ( (gTacticalStatus.uiFlags & TURNBASED) && (gTacticalStatus.uiFlags & INCOMBAT) ); fPathingForPlayer = ( (s->bTeam == gbPlayerNum) && (!gTacticalStatus.fAutoBandageMode) && !(s->flags.uiStatusFlags & SOLDIER_PCUNDERAICONTROL) ); - fNonFenceJumper = !( IS_MERC_BODY_TYPE( s ) ) || (!s->CanClimbWithCurrentBackpack());//Moa: added backpack check // Flugente: nonswimmers are those who are not mercs and not boats fNonSwimmer = !(IS_MERC_BODY_TYPE( s ) ); @@ -2930,7 +2932,7 @@ if(!GridNoOnVisibleWorldTile(iDestination)) nextCost = gTileTypeMovementCost[ gpWorldLevelData[ newLoc ].ubTerrainID ]; } } - else if ( nextCost == TRAVELCOST_FENCE && fNonFenceJumper ) + else if ( nextCost == TRAVELCOST_FENCE && !canJumpFences(s)) { goto NEXTDIR; } From f16f137f2b53411945ba339cce9fa149af150b38 Mon Sep 17 00:00:00 2001 From: CptMoore <39010654+CptMoore@users.noreply.github.com> Date: Sun, 30 Jul 2023 09:48:11 +0200 Subject: [PATCH 004/120] Create latest tag explicitly Apparently the github API does too much magic, lets hope removing a step will make it behave --- .github/workflows/build.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5529cd97..4ce3003e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -190,22 +190,28 @@ jobs: mkdir dist/ mv artifacts/*_release/* dist/ - - name: Delete Latest - if: startsWith(github.ref, 'refs/tags/v') == false + - name: Delete Latest Release and Tag + if: github.ref == 'refs/heads/master' uses: dev-drprasad/delete-tag-and-release@v1.0 with: + delete_release: true tag_name: "latest" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create Latest Tag + if: github.ref == 'refs/heads/master' + working-directory: ${{ inputs.checkout-directory }} + run: | + git tag -d latest || true + git tag latest + git push origin latest - id: release_latest name: Release Latest - if: startsWith(github.ref, 'refs/tags/v') == false + if: github.ref == 'refs/heads/master' uses: ncipollo/release-action@v1 with: - allowUpdates: false artifactErrorsFailBuild: true artifacts: dist/* - draft: false generateReleaseNotes: true makeLatest: true name: "Latest (unstable)" From 2345dd0ae6d2dbfbec0d919c12354a2aa2f732c6 Mon Sep 17 00:00:00 2001 From: CptMoore <39010654+CptMoore@users.noreply.github.com> Date: Sun, 30 Jul 2023 19:22:23 +0200 Subject: [PATCH 005/120] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ce3003e..0151d820 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -200,7 +200,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create Latest Tag if: github.ref == 'refs/heads/master' - working-directory: ${{ inputs.checkout-directory }} + working-directory: source run: | git tag -d latest || true git tag latest From 32e49784a022f93d90d5f83a4f26bc7769aef45a Mon Sep 17 00:00:00 2001 From: CptMoore <39010654+CptMoore@users.noreply.github.com> Date: Sun, 30 Jul 2023 23:33:28 +0200 Subject: [PATCH 006/120] Update build.yml --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0151d820..eef17f2e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -200,8 +200,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create Latest Tag if: github.ref == 'refs/heads/master' - working-directory: source run: | + # filter tree is what makes this fast + git clone --config transfer.fsckobjects=false --tags --no-checkout --filter=tree:0 \ + "https://github.com/$GITHUB_REPOSITORY" \ + source + cd source git tag -d latest || true git tag latest git push origin latest From 1bb8a214c9ffd2a794dc4e87cb147bfdd7df430c Mon Sep 17 00:00:00 2001 From: CptMoore <39010654+CptMoore@users.noreply.github.com> Date: Mon, 31 Jul 2023 00:28:42 +0200 Subject: [PATCH 007/120] Update build.yml --- .github/workflows/build.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eef17f2e..d05169d9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -198,14 +198,17 @@ jobs: tag_name: "latest" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Checkout Repo + if: github.ref == 'refs/heads/master' + uses: actions/checkout@v3 + with: + path: source + fetch-depth: 1 + sparse-checkout: 'README.md' - name: Create Latest Tag if: github.ref == 'refs/heads/master' + working-directory: source run: | - # filter tree is what makes this fast - git clone --config transfer.fsckobjects=false --tags --no-checkout --filter=tree:0 \ - "https://github.com/$GITHUB_REPOSITORY" \ - source - cd source git tag -d latest || true git tag latest git push origin latest From 52ccc7cc3ccc3fb17f6aef44606e58b0a26aeead Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Fri, 4 Aug 2023 13:45:54 +0300 Subject: [PATCH 008/120] Fix widescreen UI militia popup box y-coordinate (#196) --- Strategic/Map Screen Interface Map.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Strategic/Map Screen Interface Map.cpp b/Strategic/Map Screen Interface Map.cpp index b709c3a0..0ec76fd7 100644 --- a/Strategic/Map Screen Interface Map.cpp +++ b/Strategic/Map Screen Interface Map.cpp @@ -1792,11 +1792,16 @@ void InitializeMilitiaPopup(void) const UINT16 xVal = 330 + xResOffset; const UINT16 yVal = 25 + yResOffset; - if (isWidescreenUI() || iResolution >= _1024x768) + if (iResolution >= _1024x768) { MAP_MILITIA_BOX_POS_X = xVal + 190; MAP_MILITIA_BOX_POS_Y = yVal + 285; } + else if (isWidescreenUI()) + { + MAP_MILITIA_BOX_POS_X = xVal + 190; + MAP_MILITIA_BOX_POS_Y = yVal + 116; + } else if (iResolution >= _800x600) { MAP_MILITIA_BOX_POS_X = xVal + 77; From 43c6943399b13c730a86fac83182999d44405365 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Fri, 4 Aug 2023 14:25:35 +0300 Subject: [PATCH 009/120] Don't modify gMAXITEM_READ when reading localized file (#198) --- Utils/XML_Items.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Utils/XML_Items.cpp b/Utils/XML_Items.cpp index c48b2cb2..5c1c37ae 100644 --- a/Utils/XML_Items.cpp +++ b/Utils/XML_Items.cpp @@ -1600,9 +1600,12 @@ BOOLEAN ReadInItemStats(STR fileName, BOOLEAN localizedVersion ) MemFree(lpcBuffer); return FALSE; } - - // item read was x -> x+1 items - ++gMAXITEMS_READ; + + if (localizedTextOnly == false) + { + // item read was x -> x+1 items + ++gMAXITEMS_READ; + } MemFree(lpcBuffer); From aaeea9aac8d5009c7f6f1a172f6e64248012aa51 Mon Sep 17 00:00:00 2001 From: rftrdev <102184004+rftrdev@users.noreply.github.com> Date: Wed, 9 Aug 2023 18:36:44 -0700 Subject: [PATCH 010/120] Replace evolution with growth rates (#201) --- GameSettings.cpp | 5 +- GameSettings.h | 7 +- GameVersion.h | 3 +- Laptop/personnel.cpp | 194 ++++++++++++++++++++++++++++++-- SaveLoadGame.cpp | 121 +++++++++++++++++++- Strategic/mapscreen.cpp | 20 ++-- Tactical/Campaign.cpp | 70 ++++++------ Tactical/Campaign.h | 4 +- Tactical/Interface Panels.cpp | 20 ++-- Tactical/Soldier Control.cpp | 2 +- Tactical/Soldier Profile.cpp | 47 +++++++- Tactical/Soldier Profile.h | 13 ++- Tactical/XML_Profiles.cpp | 94 +++++++++++++++- Tactical/soldier profile type.h | 28 ++--- TacticalAI/NPC.cpp | 12 +- Utils/Text.h | 30 +++++ Utils/_ChineseText.cpp | 22 ++-- Utils/_DutchText.cpp | 22 ++-- Utils/_EnglishText.cpp | 22 ++-- Utils/_FrenchText.cpp | 22 ++-- Utils/_GermanText.cpp | 22 ++-- Utils/_ItalianText.cpp | 22 ++-- Utils/_PolishText.cpp | 22 ++-- Utils/_RussianText.cpp | 22 ++-- 24 files changed, 685 insertions(+), 161 deletions(-) diff --git a/GameSettings.cpp b/GameSettings.cpp index 3791ae0c..28bf1151 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -1079,6 +1079,9 @@ void LoadGameExternalOptions() gGameExternalOptions.ubMercRandomExpRange = iniReader.ReadInteger("Recruitment Settings", "MERCS_RANDOM_EXP_RANGE", 1, 0, 4); gGameExternalOptions.fMercRandomStartSalary = iniReader.ReadBoolean("Recruitment Settings", "MERCS_RANDOM_START_SALARY", FALSE); gGameExternalOptions.ubMercRandomStartSalaryPercentMod = iniReader.ReadInteger("Recruitment Settings", "MERCS_RANDOM_START_SALARY_PERCENTAGE_MAX_MODIFIER", 30, 0, 100); + gGameExternalOptions.fMercGrowthModifiersEnabled = iniReader.ReadBoolean("Recruitment Settings", "MERCS_GROWTH_MODIFIERS_ENABLED", FALSE); + gGameExternalOptions.fMercRandomGrowthModifiers = iniReader.ReadBoolean("Recruitment Settings", "MERCS_RANDOM_GROWTH_MODIFIERS", FALSE); + gGameExternalOptions.iMercRandomGrowthModifiersRange = iniReader.ReadInteger("Recruitment Settings", "MERCS_RANDOM_GROWTH_MODIFIERS_RANGE", 5, -50, 50); //################# Financial Settings ################# @@ -2480,8 +2483,6 @@ void LoadGameExternalOptions() gGameExternalOptions.ubTeachBonusToTrain = iniReader.ReadInteger("Strategic Assignment Settings","TEACHER_TRAIT_BONUS_TO_TRAINING_EFFICIENCY",30, 0, 100); gGameExternalOptions.ubMinSkillToTeach = iniReader.ReadInteger("Strategic Assignment Settings","MIN_SKILL_REQUIRED_TO_TEACH_OTHER",25, 0, 100); - gGameExternalOptions.bDisableEvolution = iniReader.ReadBoolean("Strategic Assignment Settings", "DISABLE_EVOLUTION", TRUE ); - // HEADROCK HAM B2.8: New Trainer Relations: 2 = Trainees will go to sleep when their trainer goes to sleep. 3 = Trainer will go to sleep if all trainees are asleep. 1 = Both. 0 = Neither. gGameExternalOptions.ubSmartTrainingSleep = iniReader.ReadInteger("Strategic Assignment Settings","SYNCHRONIZED_SLEEPING_HOURS_WHEN_TRAINING_TOGETHER", 0, 0, 3); diff --git a/GameSettings.h b/GameSettings.h index 5bdeb6dc..735538f3 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -816,9 +816,6 @@ typedef struct INT32 ubRpcBonusToTrainMilitia; INT32 ubMinSkillToTeach; - // Flugente: disable evolution setting in MercProfiles.xml - BOOLEAN bDisableEvolution; - INT32 ubLowActivityLevel; INT32 ubMediumActivityLevel; INT32 ubHighActivityLevel; @@ -1440,6 +1437,10 @@ typedef struct UINT8 ubMercRandomStartSalaryPercentMod; + BOOLEAN fMercGrowthModifiersEnabled; + BOOLEAN fMercRandomGrowthModifiers; + INT16 iMercRandomGrowthModifiersRange; + BOOLEAN fBobbyRayFastShipments; BOOLEAN fGridExitInTurnBased; diff --git a/GameVersion.h b/GameVersion.h index d322980c..b516b225 100644 --- a/GameVersion.h +++ b/GameVersion.h @@ -23,6 +23,7 @@ extern CHAR16 zBuildInformation[256]; // Keeps track of the saved game version. Increment the saved game version whenever // you will invalidate the saved game file +#define GROWTH_MODIFIERS 184 #define REBELCOMMAND 183 #define DRAGSTRUCTURE 182 // Flugente: we can drag structures behind us #define DISABILITYFLAGMASK 181 // Flugente: disabilities get a flagmask @@ -104,7 +105,7 @@ extern CHAR16 zBuildInformation[256]; #define AP100_SAVEGAME_DATATYPE_CHANGE 105 // Before this, we didn't have the 100AP structure changes #define NIV_SAVEGAME_DATATYPE_CHANGE 102 // Before this, we used the old structure system -#define SAVE_GAME_VERSION REBELCOMMAND +#define SAVE_GAME_VERSION GROWTH_MODIFIERS //#define RUSSIANGOLD #ifdef __cplusplus diff --git a/Laptop/personnel.cpp b/Laptop/personnel.cpp index beb0e873..e2576e33 100644 --- a/Laptop/personnel.cpp +++ b/Laptop/personnel.cpp @@ -2170,7 +2170,7 @@ void DisplayCharPersonality(INT32 iId, INT32 iSlot) for ( int i = APPROACH_FRIENDLY; i <= APPROACH_RECRUIT; ++i ) { - mprintf( (INT16)(pPersonnelScreenPoints[loc].x + (iSlot*TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + 15), szLaptopStatText[7 + i] ); + mprintf( (INT16)(pPersonnelScreenPoints[loc].x + (iSlot*TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + 15), szLaptopStatText[LAPTOP_STAT_TEXT_FRIENDLY_APPROACH-1 + i] ); // APPROACH_FRIENDLY is 1 so fix the offset CHAR16 sStr[200]; swprintf( sStr, L"" ); @@ -2180,7 +2180,7 @@ void DisplayCharPersonality(INT32 iId, INT32 iSlot) swprintf( sStr, L"%d", val ); - FindFontRightCoordinates( (INT16)(pPersonnelScreenPoints[loc].x + (iSlot*TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH - 20, 0, sStr, PERS_FONT, &sX, &sY ); + FindFontRightCoordinates( (INT16)(pPersonnelScreenPoints[loc].x + (iSlot*TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, sStr, PERS_FONT, &sX, &sY ); mprintf( sX, (pPersonnelScreenPoints[loc].y + 15), sStr ); // Add specific region for fast help window @@ -2205,10 +2205,10 @@ void DisplayCharPersonality(INT32 iId, INT32 iSlot) if ( (gMercProfiles[pSoldier->ubProfile].ubMiscFlags3 & PROFILE_MISC_FLAG3_GOODGUY) ) { CHAR16 sStr1[200]; - swprintf( sStr1, szLaptopStatText[6] ); + swprintf( sStr1, szLaptopStatText[LAPTOP_STAT_TEXT_GOOD_GUY] ); CHAR16 sStr2[200]; - swprintf( sStr2, szLaptopStatText[7], pSoldier->GetName( ) ); + swprintf( sStr2, szLaptopStatText[LAPTOP_STAT_TEXT_REFUSES_TO_ATTACK_NON_HOSTILES], pSoldier->GetName( ) ); sX = pPersonnelScreenPoints[loc].x + (iSlot*TEXT_BOX_WIDTH); @@ -2233,15 +2233,189 @@ void DisplayCharPersonality(INT32 iId, INT32 iSlot) ++region; } - if ( !gGameExternalOptions.bDisableEvolution ) + if (gGameExternalOptions.fMercGrowthModifiersEnabled) { - CHAR16 sStr2[200]; - swprintf( sStr2, szLaptopStatText[12 + gMercProfiles[pSoldier->ubProfile].bEvolution], pSoldier->GetName() ); + if (gMercProfiles[pSoldier->ubProfile].fRegresses) + { + CHAR16 sStr2[200]; + swprintf(sStr2, szLaptopStatText[LAPTOP_STAT_TEXT_MERC_REGRESSES]); - mprintf( (INT16)( pPersonnelScreenPoints[loc].x + ( iSlot*TEXT_BOX_WIDTH ) ), ( pPersonnelScreenPoints[loc].y + 15 ), sStr2 ); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + 15), sStr2); - ++loc; - ++region; + ++loc; + ++region; + } + else + { + const int THRESHOLD_FAST = -3; // this value and below: "fast" + const int THRESHOLD_SLOW = 3; // this value and above: "slow" + int yOffset = 15; + CHAR16 statTxt[200]; + // health + { + swprintf(statTxt, szLaptopStatText[LAPTOP_STAT_TEXT_HEALTH_SPEED]); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + + if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierLife <= THRESHOLD_FAST) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_FAST]); + else if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierLife >= THRESHOLD_SLOW) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_SLOW]); + else + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_AVERAGE]); + FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, statTxt, PERS_FONT, &sX, &sY); + mprintf(sX, (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + yOffset += 10; + } + // strength + { + swprintf(statTxt, szLaptopStatText[LAPTOP_STAT_TEXT_STRENGTH_SPEED]); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + + if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierStrength <= THRESHOLD_FAST) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_FAST]); + else if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierStrength >= THRESHOLD_SLOW) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_SLOW]); + else + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_AVERAGE]); + FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, statTxt, PERS_FONT, &sX, &sY); + mprintf(sX, (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + yOffset += 10; + } + // agility + { + swprintf(statTxt, szLaptopStatText[LAPTOP_STAT_TEXT_AGILITY_SPEED]); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + + if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierAgility <= THRESHOLD_FAST) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_FAST]); + else if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierAgility >= THRESHOLD_SLOW) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_SLOW]); + else + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_AVERAGE]); + FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, statTxt, PERS_FONT, &sX, &sY); + mprintf(sX, (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + yOffset += 10; + } + // dexterity + { + swprintf(statTxt, szLaptopStatText[LAPTOP_STAT_TEXT_DEXTERITY_SPEED]); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + + if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierDexterity <= THRESHOLD_FAST) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_FAST]); + else if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierDexterity >= THRESHOLD_SLOW) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_SLOW]); + else + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_AVERAGE]); + FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, statTxt, PERS_FONT, &sX, &sY); + mprintf(sX, (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + yOffset += 10; + } + // wisdom + { + swprintf(statTxt, szLaptopStatText[LAPTOP_STAT_TEXT_WISDOM_SPEED]); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + + if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierWisdom <= THRESHOLD_FAST) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_FAST]); + else if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierWisdom >= THRESHOLD_SLOW) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_SLOW]); + else + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_AVERAGE]); + FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, statTxt, PERS_FONT, &sX, &sY); + mprintf(sX, (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + yOffset += 10; + } + // marksmanship + { + swprintf(statTxt, szLaptopStatText[LAPTOP_STAT_TEXT_MARKSMANSHIP_SPEED]); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + + if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierMarksmanship <= THRESHOLD_FAST) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_FAST]); + else if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierMarksmanship >= THRESHOLD_SLOW) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_SLOW]); + else + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_AVERAGE]); + FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, statTxt, PERS_FONT, &sX, &sY); + mprintf(sX, (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + yOffset += 10; + } + // explosives + { + swprintf(statTxt, szLaptopStatText[LAPTOP_STAT_TEXT_EXPLOSIVES_SPEED]); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + + if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierExplosive <= THRESHOLD_FAST) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_FAST]); + else if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierExplosive >= THRESHOLD_SLOW) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_SLOW]); + else + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_AVERAGE]); + FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, statTxt, PERS_FONT, &sX, &sY); + mprintf(sX, (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + yOffset += 10; + } + // leadership + { + swprintf(statTxt, szLaptopStatText[LAPTOP_STAT_TEXT_LEADERSHIP_SPEED]); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + + if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierLeadership <= THRESHOLD_FAST) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_FAST]); + else if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierLeadership >= THRESHOLD_SLOW) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_SLOW]); + else + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_AVERAGE]); + FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, statTxt, PERS_FONT, &sX, &sY); + mprintf(sX, (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + yOffset += 10; + } + // medical + { + swprintf(statTxt, szLaptopStatText[LAPTOP_STAT_TEXT_MEDICAL_SPEED]); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + + if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierMedical <= THRESHOLD_FAST) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_FAST]); + else if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierMedical >= THRESHOLD_SLOW) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_SLOW]); + else + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_AVERAGE]); + FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, statTxt, PERS_FONT, &sX, &sY); + mprintf(sX, (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + yOffset += 10; + } + // mechanical + { + swprintf(statTxt, szLaptopStatText[LAPTOP_STAT_TEXT_MECHANICAL_SPEED]); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + + if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierMechanical <= THRESHOLD_FAST) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_FAST]); + else if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierMechanical >= THRESHOLD_SLOW) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_SLOW]); + else + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_AVERAGE]); + FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, statTxt, PERS_FONT, &sX, &sY); + mprintf(sX, (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + yOffset += 10; + } + // exp level + { + swprintf(statTxt, szLaptopStatText[LAPTOP_STAT_TEXT_EXPERIENCE_SPEED]); + mprintf((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + + if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierExpLevel <= THRESHOLD_FAST) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_FAST]); + else if (gMercProfiles[pSoldier->ubProfile].bGrowthModifierExpLevel >= THRESHOLD_SLOW) + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_SLOW]); + else + swprintf(statTxt, L"%s", szLaptopStatText[LAPTOP_STAT_TEXT_AVERAGE]); + FindFontRightCoordinates((INT16)(pPersonnelScreenPoints[loc].x + (iSlot * TEXT_BOX_WIDTH)), 0, TEXT_BOX_WIDTH, 0, statTxt, PERS_FONT, &sX, &sY); + mprintf(sX, (pPersonnelScreenPoints[loc].y + yOffset), statTxt); + } + } } } diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index 5c245e84..37eca4c5 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -1294,7 +1294,16 @@ BOOLEAN MERCPROFILESTRUCT::Load(HWFILE hFile, bool forceLoadOldVersion, bool for numBytesRead = ReadFieldByField( hFile, &this->bSex, sizeof(this->bSex), sizeof(INT8), numBytesRead); numBytesRead = ReadFieldByField( hFile, &this->bArmourAttractiveness, sizeof(this->bArmourAttractiveness), sizeof(INT8), numBytesRead); numBytesRead = ReadFieldByField( hFile, &this->ubMiscFlags2, sizeof(this->ubMiscFlags2), sizeof(UINT8), numBytesRead); - numBytesRead = ReadFieldByField( hFile, &this->bEvolution, sizeof(this->bEvolution), sizeof(INT8), numBytesRead); + if (guiCurrentSaveGameVersion < GROWTH_MODIFIERS) + { + numBytesRead = ReadFieldByField( hFile, &this->fRegresses, sizeof(this->fRegresses), sizeof(INT8), numBytesRead); + // convert old evolution to regresses boolean + this->fRegresses = this->fRegresses == 2 ? TRUE : FALSE; // 2 == CharacterEvolution::DEVOLVES + } + else + { + numBytesRead = ReadFieldByField( hFile, &this->fRegresses, sizeof(this->fRegresses), sizeof(INT8), numBytesRead); + } numBytesRead = ReadFieldByField( hFile, &this->ubMiscFlags, sizeof(this->ubMiscFlags), sizeof(UINT8), numBytesRead); numBytesRead = ReadFieldByField( hFile, &this->bSexist, sizeof(this->bSexist), sizeof(UINT8), numBytesRead); numBytesRead = ReadFieldByField( hFile, &this->bLearnToHate, sizeof(this->bLearnToHate), sizeof(UINT8), numBytesRead); @@ -1637,6 +1646,70 @@ BOOLEAN MERCPROFILESTRUCT::Load(HWFILE hFile, bool forceLoadOldVersion, bool for return( FALSE ); } } + + // rftr: growth modifiers + if (guiCurrentSaveGameVersion >= GROWTH_MODIFIERS) + { + if (!FileRead(hFile, &this->bGrowthModifierLife, sizeof(INT8), &uiNumBytesRead)) + { + return(FALSE); + } + if ( !FileRead( hFile, &this->bGrowthModifierStrength, sizeof(INT8), &uiNumBytesRead) ) + { + return( FALSE ); + } + if ( !FileRead( hFile, &this->bGrowthModifierAgility, sizeof(INT8), &uiNumBytesRead) ) + { + return( FALSE ); + } + if ( !FileRead( hFile, &this->bGrowthModifierDexterity, sizeof(INT8), &uiNumBytesRead) ) + { + return( FALSE ); + } + if ( !FileRead( hFile, &this->bGrowthModifierWisdom, sizeof(INT8), &uiNumBytesRead) ) + { + return( FALSE ); + } + if ( !FileRead( hFile, &this->bGrowthModifierMarksmanship, sizeof(INT8), &uiNumBytesRead) ) + { + return( FALSE ); + } + if ( !FileRead( hFile, &this->bGrowthModifierExplosive, sizeof(INT8), &uiNumBytesRead) ) + { + return( FALSE ); + } + if ( !FileRead( hFile, &this->bGrowthModifierLeadership, sizeof(INT8), &uiNumBytesRead) ) + { + return( FALSE ); + } + if ( !FileRead( hFile, &this->bGrowthModifierMedical, sizeof(INT8), &uiNumBytesRead) ) + { + return( FALSE ); + } + if ( !FileRead( hFile, &this->bGrowthModifierMechanical, sizeof(INT8), &uiNumBytesRead) ) + { + return( FALSE ); + } + if ( !FileRead( hFile, &this->bGrowthModifierExpLevel, sizeof(INT8), &uiNumBytesRead) ) + { + return( FALSE ); + } + } + else + { + // zero out growth modifiers for upgrading savegames + this->bGrowthModifierLife = 0; + this->bGrowthModifierStrength = 0; + this->bGrowthModifierAgility = 0; + this->bGrowthModifierDexterity = 0; + this->bGrowthModifierWisdom = 0; + this->bGrowthModifierMarksmanship = 0; + this->bGrowthModifierExplosive = 0; + this->bGrowthModifierLeadership = 0; + this->bGrowthModifierMedical = 0; + this->bGrowthModifierMechanical = 0; + this->bGrowthModifierExpLevel = 0; + } } if ( this->uiProfileChecksum != this->GetChecksum() ) @@ -1753,6 +1826,52 @@ BOOLEAN MERCPROFILESTRUCT::Save(HWFILE hFile) { return( FALSE ); } + + // rftr: growth modifiers + if (!FileWrite(hFile, &this->bGrowthModifierLife, sizeof(INT8), &uiNumBytesWritten)) + { + return(FALSE); + } + if ( !FileWrite( hFile, &this->bGrowthModifierStrength, sizeof(INT8), &uiNumBytesWritten) ) + { + return( FALSE ); + } + if ( !FileWrite( hFile, &this->bGrowthModifierAgility, sizeof(INT8), &uiNumBytesWritten) ) + { + return( FALSE ); + } + if ( !FileWrite( hFile, &this->bGrowthModifierDexterity, sizeof(INT8), &uiNumBytesWritten) ) + { + return( FALSE ); + } + if ( !FileWrite( hFile, &this->bGrowthModifierWisdom, sizeof(INT8), &uiNumBytesWritten) ) + { + return( FALSE ); + } + if ( !FileWrite( hFile, &this->bGrowthModifierMarksmanship, sizeof(INT8), &uiNumBytesWritten) ) + { + return( FALSE ); + } + if ( !FileWrite( hFile, &this->bGrowthModifierExplosive, sizeof(INT8), &uiNumBytesWritten) ) + { + return( FALSE ); + } + if ( !FileWrite( hFile, &this->bGrowthModifierLeadership, sizeof(INT8), &uiNumBytesWritten) ) + { + return( FALSE ); + } + if ( !FileWrite( hFile, &this->bGrowthModifierMedical, sizeof(INT8), &uiNumBytesWritten) ) + { + return( FALSE ); + } + if ( !FileWrite( hFile, &this->bGrowthModifierMechanical, sizeof(INT8), &uiNumBytesWritten) ) + { + return( FALSE ); + } + if ( !FileWrite( hFile, &this->bGrowthModifierExpLevel, sizeof(INT8), &uiNumBytesWritten) ) + { + return( FALSE ); + } return TRUE; } diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 11c39563..4d387161 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -3372,7 +3372,7 @@ void DisplayCharacterInfo( void ) const auto x = UI_CHARPANEL.Attr.AGL.iX; const auto y = UI_CHARPANEL.Attr.AGL.iY; - ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sAgilityGain+1)) / SubpointsPerPoint(AGILAMT,0); + ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sAgilityGain+1)) / SubpointsPerPoint(AGILAMT, &gMercProfiles[pSoldier->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, STAT_WIDTH)); ClipRect.iTop = (y-1); ClipRect.iBottom = (y-1) + STAT_HEIGHT; @@ -3387,7 +3387,7 @@ void DisplayCharacterInfo( void ) const auto x = UI_CHARPANEL.Attr.DEX.iX; const auto y = UI_CHARPANEL.Attr.DEX.iY; - ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sDexterityGain+1)) / SubpointsPerPoint(DEXTAMT,0); + ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sDexterityGain+1)) / SubpointsPerPoint(DEXTAMT, &gMercProfiles[pSoldier->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, STAT_WIDTH)); ClipRect.iTop = (y-1); ClipRect.iBottom = (y-1) + STAT_HEIGHT; @@ -3402,7 +3402,7 @@ void DisplayCharacterInfo( void ) const auto x = UI_CHARPANEL.Attr.STR.iX; const auto y = UI_CHARPANEL.Attr.STR.iY; - ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sStrengthGain+1)) / SubpointsPerPoint(STRAMT,0); + ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sStrengthGain+1)) / SubpointsPerPoint(STRAMT, &gMercProfiles[pSoldier->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, STAT_WIDTH)); ClipRect.iTop = (y-1); ClipRect.iBottom = (y-1) + STAT_HEIGHT; @@ -3417,7 +3417,7 @@ void DisplayCharacterInfo( void ) const auto x = UI_CHARPANEL.Attr.WIS.iX; const auto y = UI_CHARPANEL.Attr.WIS.iY; - ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sWisdomGain+1)) / SubpointsPerPoint(WISDOMAMT,0); + ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sWisdomGain+1)) / SubpointsPerPoint(WISDOMAMT, &gMercProfiles[pSoldier->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, STAT_WIDTH)); ClipRect.iTop = (y-1); ClipRect.iBottom = (y-1) + STAT_HEIGHT; @@ -3432,7 +3432,7 @@ void DisplayCharacterInfo( void ) const auto x = UI_CHARPANEL.Attr.MRK.iX; const auto y = UI_CHARPANEL.Attr.MRK.iY; - ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sMarksmanshipGain+1)) / SubpointsPerPoint(MARKAMT,0); + ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sMarksmanshipGain+1)) / SubpointsPerPoint(MARKAMT, &gMercProfiles[pSoldier->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, STAT_WIDTH)); ClipRect.iTop = (y-1); ClipRect.iBottom = (y-1) + STAT_HEIGHT; @@ -3447,7 +3447,7 @@ void DisplayCharacterInfo( void ) const auto x = UI_CHARPANEL.Attr.LDR.iX; const auto y = UI_CHARPANEL.Attr.LDR.iY; - ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sLeadershipGain+1)) / SubpointsPerPoint(LDRAMT,0); + ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sLeadershipGain+1)) / SubpointsPerPoint(LDRAMT, &gMercProfiles[pSoldier->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, STAT_WIDTH)); ClipRect.iTop = (y-1); ClipRect.iBottom = (y-1) + STAT_HEIGHT; @@ -3462,7 +3462,7 @@ void DisplayCharacterInfo( void ) const auto x = UI_CHARPANEL.Attr.MEC.iX; const auto y = UI_CHARPANEL.Attr.MEC.iY; - ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sMechanicGain+1)) / SubpointsPerPoint(MECHANAMT,0); + ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sMechanicGain+1)) / SubpointsPerPoint(MECHANAMT, &gMercProfiles[pSoldier->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, STAT_WIDTH)); ClipRect.iTop = (y-1); ClipRect.iBottom = (y-1) + STAT_HEIGHT; @@ -3477,7 +3477,7 @@ void DisplayCharacterInfo( void ) const auto x = UI_CHARPANEL.Attr.EXP.iX; const auto y = UI_CHARPANEL.Attr.EXP.iY; - ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sExplosivesGain+1)) / SubpointsPerPoint(EXPLODEAMT,0); + ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sExplosivesGain+1)) / SubpointsPerPoint(EXPLODEAMT, &gMercProfiles[pSoldier->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, STAT_WIDTH)); ClipRect.iTop = (y-1); ClipRect.iBottom = (y-1) + STAT_HEIGHT; @@ -3492,7 +3492,7 @@ void DisplayCharacterInfo( void ) const auto x = UI_CHARPANEL.Attr.MED.iX; const auto y = UI_CHARPANEL.Attr.MED.iY; - ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sMedicalGain+1)) / SubpointsPerPoint(MEDICALAMT,0); + ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sMedicalGain+1)) / SubpointsPerPoint(MEDICALAMT, &gMercProfiles[pSoldier->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, STAT_WIDTH)); ClipRect.iTop = (y-1); ClipRect.iBottom = (y-1) + STAT_HEIGHT; @@ -3507,7 +3507,7 @@ void DisplayCharacterInfo( void ) const auto x = UI_CHARPANEL.Attr.LVL.iX; const auto y = UI_CHARPANEL.Attr.LVL.iY; - ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sExpLevelGain+1)) / SubpointsPerPoint(EXPERAMT, pSoldier->stats.bExpLevel); + ubBarWidth = (STAT_WIDTH * (gMercProfiles[ pSoldier->ubProfile ].sExpLevelGain+1)) / SubpointsPerPoint(EXPERAMT, &gMercProfiles[pSoldier->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, STAT_WIDTH)); ClipRect.iTop = (y-1); ClipRect.iBottom = (y-1) + STAT_HEIGHT; diff --git a/Tactical/Campaign.cpp b/Tactical/Campaign.cpp index d128fb75..54d1c78c 100644 --- a/Tactical/Campaign.cpp +++ b/Tactical/Campaign.cpp @@ -167,25 +167,14 @@ void ProcessStatChange(MERCPROFILESTRUCT *pProfile, UINT8 ubStat, UINT16 usNumCh INT8 bCurrentRating; UINT16 *psStatGainPtr; BOOLEAN fAffectedByWisdom = TRUE; - INT8 evolution = NORMAL_EVOLUTION; Assert(pProfile != NULL); - if ( !gGameExternalOptions.bDisableEvolution ) - evolution = pProfile->bEvolution; - - if ( evolution == NO_EVOLUTION ) - return; // No change possible, quit right away - - // if this is a Reverse-Evolving merc who attempting to train - if ( ( ubReason == FROM_TRAINING ) && ( evolution == DEVOLVE ) ) - return; // he doesn't get any benefit, but isn't penalized either - if (usNumChances == 0) return; - usSubpointsPerPoint = SubpointsPerPoint(ubStat, pProfile->bExpLevel); - usSubpointsPerLevel = SubpointsPerPoint(EXPERAMT, pProfile->bExpLevel); + usSubpointsPerPoint = SubpointsPerPoint(ubStat, pProfile); + usSubpointsPerLevel = SubpointsPerPoint(EXPERAMT, pProfile); switch (ubStat) { @@ -255,7 +244,6 @@ void ProcessStatChange(MERCPROFILESTRUCT *pProfile, UINT8 ubStat, UINT16 usNumCh return; } - if (ubReason == FROM_TRAINING) { // training always affected by wisdom @@ -271,7 +259,7 @@ void ProcessStatChange(MERCPROFILESTRUCT *pProfile, UINT8 ubStat, UINT16 usNumCh // loop once for each chance to improve for (uiCnt = 0; uiCnt < usNumChances; ++uiCnt) { - if ( evolution != DEVOLVE) // Evolves! + if (pProfile->fRegresses == FALSE) // Evolves! { // if this is improving from a failure, and a successful roll would give us enough to go up a point if ((ubReason == FROM_FAILURE) && ((*psStatGainPtr + 1) >= usSubpointsPerPoint)) @@ -302,7 +290,7 @@ void ProcessStatChange(MERCPROFILESTRUCT *pProfile, UINT8 ubStat, UINT16 usNumCh // if there IS a usChance, adjust it for high or low wisdom (50 is avg) if (usChance > 0 && fAffectedByWisdom) { - usChance += (usChance * (pProfile->bWisdom + (pProfile->sWisdomGain / SubpointsPerPoint(WISDOMAMT, pProfile->bExpLevel)) - 50)) / 100; + usChance += (usChance * (pProfile->bWisdom + (pProfile->sWisdomGain / SubpointsPerPoint(WISDOMAMT, pProfile)) - 50)) / 100; } // rftr: reduced growth rates at 80+ and 90+ (to make mercs with higher base stats more valuable) @@ -315,14 +303,6 @@ void ProcessStatChange(MERCPROFILESTRUCT *pProfile, UINT8 ubStat, UINT16 usNumCh usChance = min(gGameExternalOptions.ubMaxGrowthChanceAt80, usChance); } -/* - // if the stat is Marksmanship, and the guy is a hopeless shot - if ((ubStat == MARKAMT) && (pProfile->bSpecialTrait == HOPELESS_SHOT)) - { - usChance /= 5; // MUCH slower to improve, divide usChance by 5 - } -*/ - // SANDRO - penalty for primitive people, they get lesser chance to gain point for certain skills if ( gGameOptions.fNewTraitSystem && (usChance > 10) && (ubStat != EXPERAMT) && (pProfile->bCharacterTrait == CHAR_TRAIT_PRIMITIVE) ) { @@ -338,14 +318,6 @@ void ProcessStatChange(MERCPROFILESTRUCT *pProfile, UINT8 ubStat, UINT16 usNumCh } } - // Buggler: more evolution rate choices - if ( evolution == THREEQUARTER_EVOLUTION) - usChance = max(1, usChance * 0.75); - else if ( evolution == HALF_EVOLUTION) - usChance = max(1, usChance * 0.5); - else if ( evolution == ONEQUARTER_EVOLUTION) - usChance = max(1, usChance * 0.25); - // maximum possible usChance is 99% if (usChance > 99) { @@ -413,7 +385,7 @@ void ProcessStatChange(MERCPROFILESTRUCT *pProfile, UINT8 ubStat, UINT16 usNumCh // if there IS a usChance, adjust it for high or low wisdom (50 is avg) if (usChance > 0 && fAffectedByWisdom) { - usChance -= (usChance * (pProfile->bWisdom + (pProfile->sWisdomGain / SubpointsPerPoint(WISDOMAMT, pProfile->bExpLevel)) - 50)) / 100; + usChance -= (usChance * (pProfile->bWisdom + (pProfile->sWisdomGain / SubpointsPerPoint(WISDOMAMT, pProfile)) - 50)) / 100; } // if there's ANY usChance, minimum usChance is 1% regardless of wisdom @@ -497,7 +469,7 @@ void ChangeStat( MERCPROFILESTRUCT *pProfile, SOLDIERTYPE *pSoldier, UINT8 ubSta UINT16 usSubpointsPerPoint; INT8 bDamagedStatToRaise = -1; // added by SANDRO - usSubpointsPerPoint = SubpointsPerPoint(ubStat, pProfile->bExpLevel ); + usSubpointsPerPoint = SubpointsPerPoint(ubStat, pProfile ); // build ptrs to appropriate profiletype stat fields switch( ubStat ) @@ -923,7 +895,7 @@ void ProcessUpdateStats( MERCPROFILESTRUCT *pProfile, SOLDIERTYPE *pSoldier, UIN // set default min & max, subpoints/pt. bMinStatValue = 1; bMaxStatValue = MAX_STAT_VALUE; - usSubpointsPerPoint = SubpointsPerPoint(ubStat, pProfile->bExpLevel); + usSubpointsPerPoint = SubpointsPerPoint(ubStat, pProfile); // build ptrs to appropriate profiletype stat fields switch( ubStat ) @@ -1166,7 +1138,7 @@ UINT32 RoundOffSalary(UINT32 uiSalary) } -UINT16 SubpointsPerPoint(UINT8 ubStat, INT8 bExpLevel) +UINT16 SubpointsPerPoint(UINT8 ubStat, MERCPROFILESTRUCT* pProfile) { UINT16 usSubpointsPerPoint; @@ -1187,40 +1159,62 @@ UINT16 SubpointsPerPoint(UINT8 ubStat, INT8 bExpLevel) // Attributes case HEALTHAMT: usSubpointsPerPoint = HEALTH_SUBPOINTS_TO_IMPROVE; + if (gGameExternalOptions.fMercGrowthModifiersEnabled) usSubpointsPerPoint += pProfile->bGrowthModifierLife; + usSubpointsPerPoint = max(usSubpointsPerPoint, HEALTH_SUBPOINTS_TO_IMPROVE/2); break; case AGILAMT: usSubpointsPerPoint = AGILITY_SUBPOINTS_TO_IMPROVE; + if (gGameExternalOptions.fMercGrowthModifiersEnabled) usSubpointsPerPoint += pProfile->bGrowthModifierAgility; + usSubpointsPerPoint = max(usSubpointsPerPoint, AGILITY_SUBPOINTS_TO_IMPROVE/2); break; case DEXTAMT: usSubpointsPerPoint = DEXTERITY_SUBPOINTS_TO_IMPROVE; + if (gGameExternalOptions.fMercGrowthModifiersEnabled) usSubpointsPerPoint += pProfile->bGrowthModifierDexterity; + usSubpointsPerPoint = max(usSubpointsPerPoint, DEXTERITY_SUBPOINTS_TO_IMPROVE/2); break; case WISDOMAMT: usSubpointsPerPoint = WISDOM_SUBPOINTS_TO_IMPROVE; + if (gGameExternalOptions.fMercGrowthModifiersEnabled) usSubpointsPerPoint += pProfile->bGrowthModifierWisdom; + usSubpointsPerPoint = max(usSubpointsPerPoint, WISDOM_SUBPOINTS_TO_IMPROVE/2); break; case STRAMT: usSubpointsPerPoint = STRENGTH_SUBPOINTS_TO_IMPROVE; + if (gGameExternalOptions.fMercGrowthModifiersEnabled) usSubpointsPerPoint += pProfile->bGrowthModifierStrength; + usSubpointsPerPoint = max(usSubpointsPerPoint, STRENGTH_SUBPOINTS_TO_IMPROVE/2); break; // Skills case MEDICALAMT: usSubpointsPerPoint = MEDICAL_SUBPOINTS_TO_IMPROVE; + if (gGameExternalOptions.fMercGrowthModifiersEnabled) usSubpointsPerPoint += pProfile->bGrowthModifierMedical; + usSubpointsPerPoint = max(usSubpointsPerPoint, MEDICAL_SUBPOINTS_TO_IMPROVE/2); break; case EXPLODEAMT: usSubpointsPerPoint = EXPLOSIVES_SUBPOINTS_TO_IMPROVE; + if (gGameExternalOptions.fMercGrowthModifiersEnabled) usSubpointsPerPoint += pProfile->bGrowthModifierExplosive; + usSubpointsPerPoint = max(usSubpointsPerPoint, EXPLOSIVES_SUBPOINTS_TO_IMPROVE/2); break; case MECHANAMT: usSubpointsPerPoint = MECHANICAL_SUBPOINTS_TO_IMPROVE; + if (gGameExternalOptions.fMercGrowthModifiersEnabled) usSubpointsPerPoint += pProfile->bGrowthModifierMechanical; + usSubpointsPerPoint = max(usSubpointsPerPoint, MECHANICAL_SUBPOINTS_TO_IMPROVE/2); break; case MARKAMT: usSubpointsPerPoint = MARKSMANSHIP_SUBPOINTS_TO_IMPROVE; + if (gGameExternalOptions.fMercGrowthModifiersEnabled) usSubpointsPerPoint += pProfile->bGrowthModifierMarksmanship; + usSubpointsPerPoint = max(usSubpointsPerPoint, MARKSMANSHIP_SUBPOINTS_TO_IMPROVE/2); break; case LDRAMT: usSubpointsPerPoint = LEADERSHIP_SUBPOINTS_TO_IMPROVE; + if (gGameExternalOptions.fMercGrowthModifiersEnabled) usSubpointsPerPoint += pProfile->bGrowthModifierLeadership; + usSubpointsPerPoint = max(usSubpointsPerPoint, LEADERSHIP_SUBPOINTS_TO_IMPROVE/2); break; // Experience case EXPERAMT: - usSubpointsPerPoint = LEVEL_SUBPOINTS_TO_IMPROVE * bExpLevel; + usSubpointsPerPoint = LEVEL_SUBPOINTS_TO_IMPROVE * pProfile->bExpLevel; + if (gGameExternalOptions.fMercGrowthModifiersEnabled) usSubpointsPerPoint += pProfile->bGrowthModifierExpLevel; + usSubpointsPerPoint = max(usSubpointsPerPoint, LEVEL_SUBPOINTS_TO_IMPROVE * pProfile->bExpLevel / 2); break; default: @@ -1797,7 +1791,7 @@ void TestDumpStatChanges(void) // print days served fprintf(FDump, "%3d ", pProfile->usTotalDaysServed); // print evolution type - fprintf(FDump, "%c ", cEvolutionChars[ pProfile->bEvolution ]); + fprintf(FDump, "%c ", cEvolutionChars[ pProfile->fRegresses ]); // now print all non-zero stats for( ubStat = FIRST_CHANGEABLE_STAT; ubStat <= LAST_CHANGEABLE_STAT; ubStat++ ) diff --git a/Tactical/Campaign.h b/Tactical/Campaign.h index a5f54276..7523fb11 100644 --- a/Tactical/Campaign.h +++ b/Tactical/Campaign.h @@ -73,7 +73,7 @@ void ProcessUpdateStats( MERCPROFILESTRUCT *pProfile, SOLDIERTYPE *pSoldier, UIN UINT32 CalcNewSalary(UINT32 uiOldSalary, BOOLEAN fIncrease, UINT32 uiMaxLimit, UINT32 uiIncreaseCap); UINT32 RoundOffSalary(UINT32 uiSalary); -UINT16 SubpointsPerPoint(UINT8 ubStat, INT8 bExpLevel); +UINT16 SubpointsPerPoint(UINT8 ubStat, MERCPROFILESTRUCT* pProfile); void HandleUnhiredMercImprovement( MERCPROFILESTRUCT *pProfile ); void HandleUnhiredMercDeaths( INT32 iProfileID ); @@ -92,4 +92,4 @@ void BuildStatChangeString( STR16 wString, STR16 wName, BOOLEAN fIncrease, INT16 void MERCMercWentUpALevelSendEmail( UINT8 ubMercMercIdValue ); -#endif \ No newline at end of file +#endif diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index e3757a03..4bbbeebd 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -2598,7 +2598,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) // AGI if (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sAgilityGain) { - ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sAgilityGain+1)) / SubpointsPerPoint(AGILAMT,0); + ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sAgilityGain+1)) / SubpointsPerPoint(AGILAMT, &gMercProfiles[gpSMCurrentMerc->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, SM_STATS_WIDTH)); ClipRect.iTop = (SM_AGI_Y-1); ClipRect.iBottom = (SM_AGI_Y-1) + SM_STATS_HEIGHT; @@ -2610,7 +2610,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) // DEX if (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sDexterityGain) { - ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sDexterityGain+1)) / SubpointsPerPoint(DEXTAMT,0); + ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sDexterityGain+1)) / SubpointsPerPoint(DEXTAMT, &gMercProfiles[gpSMCurrentMerc->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, SM_STATS_WIDTH)); ClipRect.iTop = (SM_DEX_Y-1); ClipRect.iBottom = (SM_DEX_Y-1) + SM_STATS_HEIGHT; @@ -2622,7 +2622,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) // STR if (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sStrengthGain) { - ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sStrengthGain+1)) / SubpointsPerPoint(STRAMT,0); + ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sStrengthGain+1)) / SubpointsPerPoint(STRAMT, &gMercProfiles[gpSMCurrentMerc->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, SM_STATS_WIDTH)); ClipRect.iTop = (SM_STR_Y-1); ClipRect.iBottom = (SM_STR_Y-1) + SM_STATS_HEIGHT; @@ -2634,7 +2634,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) // WIS if (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sWisdomGain) { - ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sWisdomGain+1)) / SubpointsPerPoint(WISDOMAMT,0); + ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sWisdomGain+1)) / SubpointsPerPoint(WISDOMAMT, &gMercProfiles[gpSMCurrentMerc->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, SM_STATS_WIDTH)); ClipRect.iTop = (SM_WIS_Y-1); ClipRect.iBottom = (SM_WIS_Y-1) + SM_STATS_HEIGHT; @@ -2646,7 +2646,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) // MRK if (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sMarksmanshipGain) { - ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sMarksmanshipGain+1)) / SubpointsPerPoint(MARKAMT,0); + ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sMarksmanshipGain+1)) / SubpointsPerPoint(MARKAMT, &gMercProfiles[gpSMCurrentMerc->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, SM_STATS_WIDTH)); ClipRect.iTop = (SM_MRKM_Y-1); ClipRect.iBottom = (SM_MRKM_Y-1) + SM_STATS_HEIGHT; @@ -2658,7 +2658,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) // LDR if (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sLeadershipGain) { - ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sLeadershipGain+1)) / SubpointsPerPoint(LDRAMT,0); + ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sLeadershipGain+1)) / SubpointsPerPoint(LDRAMT, &gMercProfiles[gpSMCurrentMerc->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, SM_STATS_WIDTH)); ClipRect.iTop = (SM_CHAR_Y-1); ClipRect.iBottom = (SM_CHAR_Y-1) + SM_STATS_HEIGHT; @@ -2670,7 +2670,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) // MECH if (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sMechanicGain) { - ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sMechanicGain+1)) / SubpointsPerPoint(MECHANAMT,0); + ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sMechanicGain+1)) / SubpointsPerPoint(MECHANAMT, &gMercProfiles[gpSMCurrentMerc->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, SM_STATS_WIDTH)); ClipRect.iTop = (SM_MECH_Y-1); ClipRect.iBottom = (SM_MECH_Y-1) + SM_STATS_HEIGHT; @@ -2682,7 +2682,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) // EXPLO if (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sExplosivesGain) { - ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sExplosivesGain+1)) / SubpointsPerPoint(EXPLODEAMT,0); + ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sExplosivesGain+1)) / SubpointsPerPoint(EXPLODEAMT, &gMercProfiles[gpSMCurrentMerc->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, SM_STATS_WIDTH)); ClipRect.iTop = (SM_EXPL_Y-1); ClipRect.iBottom = (SM_EXPL_Y-1) + SM_STATS_HEIGHT; @@ -2694,7 +2694,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) // MED if (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sMedicalGain) { - ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sMedicalGain+1)) / SubpointsPerPoint(MEDICALAMT,0); + ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sMedicalGain+1)) / SubpointsPerPoint(MEDICALAMT, &gMercProfiles[gpSMCurrentMerc->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, SM_STATS_WIDTH)); ClipRect.iTop = (SM_MED_Y-1); ClipRect.iBottom = (SM_MED_Y-1) + SM_STATS_HEIGHT; @@ -2706,7 +2706,7 @@ void RenderSMPanel( BOOLEAN *pfDirty ) // EXPLEVEL if (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sExpLevelGain) { - ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sExpLevelGain+1)) / SubpointsPerPoint(EXPERAMT, gpSMCurrentMerc->stats.bExpLevel); + ubBarWidth = (SM_STATS_WIDTH * (gMercProfiles[ gpSMCurrentMerc->ubProfile ].sExpLevelGain+1)) / SubpointsPerPoint(EXPERAMT, &gMercProfiles[gpSMCurrentMerc->ubProfile]); ubBarWidth = __max(0, __min(ubBarWidth, SM_STATS_WIDTH)); ClipRect.iTop = (SM_EXPLVL_Y-1); ClipRect.iBottom = (SM_EXPLVL_Y-1) + SM_STATS_HEIGHT; diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index d6c3738c..9a594ee2 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -1339,7 +1339,7 @@ MERCPROFILESTRUCT& MERCPROFILESTRUCT::operator=(const OLD_MERCPROFILESTRUCT_101& this->bSex = src.bSex; this->bArmourAttractiveness = src.bArmourAttractiveness; this->ubMiscFlags2 = src.ubMiscFlags2; - this->bEvolution = src.bEvolution; + this->fRegresses = src.bEvolution == 2; // formerly, 2 == CharacterEvolution::DEVOLVES this->ubMiscFlags = src.ubMiscFlags; this->bSexist = src.bSexist; this->bLearnToHate = src.bLearnToHate; diff --git a/Tactical/Soldier Profile.cpp b/Tactical/Soldier Profile.cpp index c307da6d..37052fb0 100644 --- a/Tactical/Soldier Profile.cpp +++ b/Tactical/Soldier Profile.cpp @@ -98,6 +98,7 @@ extern UINT8 gubItemDroppableFlag[NUM_INV_SLOTS]; //Random Stats RANDOM_STATS_VALUES gRandomStatsValue[NUM_PROFILES]; void RandomStats(); +void RandomGrowthModifiers(); void RandomStartSalary(); //Jenilee @@ -459,6 +460,35 @@ void RandomStats() ExitRandomMercs(); } } +void RandomGrowthModifiers() +{ + UINT32 cnt; + MERCPROFILESTRUCT * pProfile; + BOOLEAN useBellCurve = TRUE; + + if (gGameExternalOptions.fMercRandomGrowthModifiers == TRUE) + { + for (cnt = 0; cnt < NUM_PROFILES; cnt++) + { + pProfile = &(gMercProfiles[cnt]); + + // cap minimum growth modifier to negative half subpoints. this is effectively double speed using default values (subpoints = 50) + // cap maximum growth modifier to 30000. this would make a merc take 600x as long to level up a stat using default values + pProfile->bGrowthModifierExpLevel = RandomAbsoluteRange( pProfile->bGrowthModifierExpLevel, -gGameExternalOptions.usLevelSubpointsToImprove/2, 30000, gGameExternalOptions.iMercRandomGrowthModifiersRange, useBellCurve ); + pProfile->bGrowthModifierLife = RandomAbsoluteRange( pProfile->bGrowthModifierLife, -gGameExternalOptions.usHealthSubpointsToImprove/2, 30000, gGameExternalOptions.iMercRandomGrowthModifiersRange, useBellCurve ); + pProfile->bGrowthModifierAgility = RandomAbsoluteRange( pProfile->bGrowthModifierAgility, -gGameExternalOptions.usAgilitySubpointsToImprove/2, 30000, gGameExternalOptions.iMercRandomGrowthModifiersRange, useBellCurve ); + pProfile->bGrowthModifierDexterity = RandomAbsoluteRange( pProfile->bGrowthModifierDexterity, -gGameExternalOptions.usDexteritySubpointsToImprove/2, 30000, gGameExternalOptions.iMercRandomGrowthModifiersRange, useBellCurve ); + pProfile->bGrowthModifierStrength = RandomAbsoluteRange( pProfile->bGrowthModifierStrength, -gGameExternalOptions.usStrengthSubpointsToImprove/2, 30000, gGameExternalOptions.iMercRandomGrowthModifiersRange, useBellCurve ); + pProfile->bGrowthModifierLeadership = RandomAbsoluteRange( pProfile->bGrowthModifierLeadership, -gGameExternalOptions.usLeadershipSubpointsToImprove/2, 30000, gGameExternalOptions.iMercRandomGrowthModifiersRange, useBellCurve ); + pProfile->bGrowthModifierWisdom = RandomAbsoluteRange( pProfile->bGrowthModifierWisdom, -gGameExternalOptions.usWisdomSubpointsToImprove/2, 30000, gGameExternalOptions.iMercRandomGrowthModifiersRange, useBellCurve ); + pProfile->bGrowthModifierMarksmanship = RandomAbsoluteRange( pProfile->bGrowthModifierMarksmanship, -gGameExternalOptions.usMarksmanshipSubpointsToImprove/2, 30000, gGameExternalOptions.iMercRandomGrowthModifiersRange, useBellCurve ); + pProfile->bGrowthModifierMechanical = RandomAbsoluteRange( pProfile->bGrowthModifierMechanical, -gGameExternalOptions.usMechanicalSubpointsToImprove/2, 30000, gGameExternalOptions.iMercRandomGrowthModifiersRange, useBellCurve ); + pProfile->bGrowthModifierExplosive = RandomAbsoluteRange( pProfile->bGrowthModifierExplosive, -gGameExternalOptions.usExplosivesSubpointsToImprove/2, 30000, gGameExternalOptions.iMercRandomGrowthModifiersRange, useBellCurve ); + pProfile->bGrowthModifierMedical = RandomAbsoluteRange( pProfile->bGrowthModifierMedical, -gGameExternalOptions.usMedicalSubpointsToImprove/2, 30000, gGameExternalOptions.iMercRandomGrowthModifiersRange, useBellCurve ); + } + } +} + void RandomStartSalary() { UINT32 cnt; @@ -996,6 +1026,8 @@ for( int i = 0; i < NUM_PROFILES; i++ ) // --------------- RandomStats (); //random stats by Jazz + + RandomGrowthModifiers(); // Buggler: random starting salary RandomStartSalary (); @@ -2522,7 +2554,7 @@ void OverwriteMercProfileWithXMLData( UINT32 uiLoop ) gMercProfiles[ uiLoop ].bMechanical = tempProfiles[ uiLoop ].bMechanical ; gMercProfiles[ uiLoop ].bExpLevel = tempProfiles[ uiLoop ].bExpLevel ; - gMercProfiles[ uiLoop ].bEvolution = tempProfiles[ uiLoop ].bEvolution ; + gMercProfiles[uiLoop].fRegresses = tempProfiles[ uiLoop ].fRegresses; ////////////////////////////////////////////////////////////////////////////////////// // SANDRO - Check old/new traits and repair possible errors if (gGameOptions.fNewTraitSystem) @@ -2637,6 +2669,19 @@ void OverwriteMercProfileWithXMLData( UINT32 uiLoop ) gMercProfiles[ uiLoop ].usVoiceIndex = tempProfiles[uiLoop].usVoiceIndex; gMercProfiles[ uiLoop ].Type = tempProfiles[uiLoop].Type; + gMercProfiles[uiLoop].fRegresses = tempProfiles[uiLoop].fRegresses; + gMercProfiles[uiLoop].bGrowthModifierLife = tempProfiles[uiLoop].bGrowthModifierLife; + gMercProfiles[uiLoop].bGrowthModifierStrength = tempProfiles[uiLoop].bGrowthModifierStrength; + gMercProfiles[uiLoop].bGrowthModifierAgility = tempProfiles[uiLoop].bGrowthModifierAgility; + gMercProfiles[uiLoop].bGrowthModifierDexterity = tempProfiles[uiLoop].bGrowthModifierDexterity; + gMercProfiles[uiLoop].bGrowthModifierWisdom = tempProfiles[uiLoop].bGrowthModifierWisdom; + gMercProfiles[uiLoop].bGrowthModifierMarksmanship = tempProfiles[uiLoop].bGrowthModifierMarksmanship; + gMercProfiles[uiLoop].bGrowthModifierExplosive = tempProfiles[uiLoop].bGrowthModifierExplosive; + gMercProfiles[uiLoop].bGrowthModifierLeadership = tempProfiles[uiLoop].bGrowthModifierLeadership; + gMercProfiles[uiLoop].bGrowthModifierMedical = tempProfiles[uiLoop].bGrowthModifierMedical; + gMercProfiles[uiLoop].bGrowthModifierMechanical = tempProfiles[uiLoop].bGrowthModifierMechanical; + gMercProfiles[uiLoop].bGrowthModifierExpLevel = tempProfiles[uiLoop].bGrowthModifierExpLevel; + gProfileType[uiLoop] = gMercProfiles[uiLoop].Type; switch ( tempProfiles[uiLoop].Type ) diff --git a/Tactical/Soldier Profile.h b/Tactical/Soldier Profile.h index 9eef6079..39e0860e 100644 --- a/Tactical/Soldier Profile.h +++ b/Tactical/Soldier Profile.h @@ -314,7 +314,18 @@ typedef struct INT8 bExpLevel; - INT8 bEvolution; + BOOLEAN fRegresses; + INT16 bGrowthModifierLife; + INT16 bGrowthModifierStrength; + INT16 bGrowthModifierAgility; + INT16 bGrowthModifierDexterity; + INT16 bGrowthModifierWisdom; + INT16 bGrowthModifierMarksmanship; + INT16 bGrowthModifierExplosive; + INT16 bGrowthModifierLeadership; + INT16 bGrowthModifierMedical; + INT16 bGrowthModifierMechanical; + INT16 bGrowthModifierExpLevel; // changed by SANDRO INT8 bOldSkillTrait; INT8 bOldSkillTrait2; diff --git a/Tactical/XML_Profiles.cpp b/Tactical/XML_Profiles.cpp index ba3aafbb..380fffb1 100644 --- a/Tactical/XML_Profiles.cpp +++ b/Tactical/XML_Profiles.cpp @@ -101,7 +101,19 @@ profileStartElementHandle(void *userData, const XML_Char *name, const XML_Char * strcmp(name, "bMedical") == 0 || strcmp(name, "bMechanical") == 0 || strcmp(name, "bExpLevel") == 0 || - strcmp(name, "bEvolution") == 0 || + strcmp(name, "fRegresses") == 0 || + // rftr: growth rates are intended to replace the tag, letting each stat have its own growth modifier + strcmp(name, "bGrowthModifierLife") == 0 || + strcmp(name, "bGrowthModifierStrength") == 0 || + strcmp(name, "bGrowthModifierAgility") == 0 || + strcmp(name, "bGrowthModifierDexterity") == 0 || + strcmp(name, "bGrowthModifierWisdom") == 0 || + strcmp(name, "bGrowthModifierMarksmanship") == 0 || + strcmp(name, "bGrowthModifierExplosive") == 0 || + strcmp(name, "bGrowthModifierLeadership") == 0 || + strcmp(name, "bGrowthModifierMedical") == 0 || + strcmp(name, "bGrowthModifierMechanical") == 0 || + strcmp(name, "bGrowthModifierExpLevel") == 0 || // added by SANDRO strcmp(name, "bOldSkillTrait") == 0 || strcmp(name, "bOldSkillTrait2") == 0 || @@ -280,7 +292,18 @@ profileEndElementHandle(void *userData, const XML_Char *name) tempProfiles[pData->curIndex].bMechanical = pData->curProfile.bMechanical; tempProfiles[pData->curIndex].bExpLevel = pData->curProfile.bExpLevel; - tempProfiles[pData->curIndex].bEvolution = pData->curProfile.bEvolution; + tempProfiles[pData->curIndex].fRegresses = pData->curProfile.fRegresses; + tempProfiles[pData->curIndex].bGrowthModifierLife = pData->curProfile.bGrowthModifierLife; + tempProfiles[pData->curIndex].bGrowthModifierStrength = pData->curProfile.bGrowthModifierStrength; + tempProfiles[pData->curIndex].bGrowthModifierAgility = pData->curProfile.bGrowthModifierAgility; + tempProfiles[pData->curIndex].bGrowthModifierDexterity = pData->curProfile.bGrowthModifierDexterity; + tempProfiles[pData->curIndex].bGrowthModifierWisdom = pData->curProfile.bGrowthModifierWisdom; + tempProfiles[pData->curIndex].bGrowthModifierMarksmanship = pData->curProfile.bGrowthModifierMarksmanship; + tempProfiles[pData->curIndex].bGrowthModifierExplosive = pData->curProfile.bGrowthModifierExplosive; + tempProfiles[pData->curIndex].bGrowthModifierLeadership = pData->curProfile.bGrowthModifierLeadership; + tempProfiles[pData->curIndex].bGrowthModifierMedical = pData->curProfile.bGrowthModifierMedical; + tempProfiles[pData->curIndex].bGrowthModifierMechanical = pData->curProfile.bGrowthModifierMechanical; + tempProfiles[pData->curIndex].bGrowthModifierExpLevel = pData->curProfile.bGrowthModifierExpLevel; // added by SANDRO tempProfiles[pData->curIndex].bOldSkillTrait = pData->curProfile.bOldSkillTrait; tempProfiles[pData->curIndex].bOldSkillTrait2 = pData->curProfile.bOldSkillTrait2; @@ -586,11 +609,70 @@ profileEndElementHandle(void *userData, const XML_Char *name) pData->curElement = ELEMENT; pData->curProfile.bExpLevel = (UINT32) strtoul(pData->szCharData, NULL, 0); } - - else if(strcmp(name, "bEvolution") == 0) + + else if(strcmp(name, "fRegresses") == 0) { pData->curElement = ELEMENT; - pData->curProfile.bEvolution = (UINT32) strtoul(pData->szCharData, NULL, 0); + pData->curProfile.fRegresses = (BOOLEAN) strtoul(pData->szCharData, NULL, 0); + } + + else if (strncmp(name, "bGrowthModifier", 11) == 0) // doing this to avoid C1061 + { + if (strcmp(name, "bGrowthModifierLife") == 0) + { + pData->curElement = ELEMENT; + pData->curProfile.bGrowthModifierLife = (UINT32)strtoul(pData->szCharData, NULL, 0); + } + else if(strcmp(name, "bGrowthModifierStrength") == 0) + { + pData->curElement = ELEMENT; + pData->curProfile.bGrowthModifierStrength = (UINT32)strtoul(pData->szCharData, NULL, 0); + } + else if(strcmp(name, "bGrowthModifierAgility") == 0) + { + pData->curElement = ELEMENT; + pData->curProfile.bGrowthModifierAgility = (UINT32)strtoul(pData->szCharData, NULL, 0); + } + else if(strcmp(name, "bGrowthModifierDexterity") == 0) + { + pData->curElement = ELEMENT; + pData->curProfile.bGrowthModifierDexterity = (UINT32)strtoul(pData->szCharData, NULL, 0); + } + else if(strcmp(name, "bGrowthModifierWisdom") == 0) + { + pData->curElement = ELEMENT; + pData->curProfile.bGrowthModifierWisdom = (UINT32)strtoul(pData->szCharData, NULL, 0); + } + else if(strcmp(name, "bGrowthModifierMarksmanship") == 0) + { + pData->curElement = ELEMENT; + pData->curProfile.bGrowthModifierMarksmanship = (UINT32)strtoul(pData->szCharData, NULL, 0); + } + else if(strcmp(name, "bGrowthModifierExplosive") == 0) + { + pData->curElement = ELEMENT; + pData->curProfile.bGrowthModifierExplosive = (UINT32)strtoul(pData->szCharData, NULL, 0); + } + else if(strcmp(name, "bGrowthModifierLeadership") == 0) + { + pData->curElement = ELEMENT; + pData->curProfile.bGrowthModifierLeadership = (UINT32)strtoul(pData->szCharData, NULL, 0); + } + else if(strcmp(name, "bGrowthModifierMedical") == 0) + { + pData->curElement = ELEMENT; + pData->curProfile.bGrowthModifierMedical = (UINT32)strtoul(pData->szCharData, NULL, 0); + } + else if(strcmp(name, "bGrowthModifierMechanical") == 0) + { + pData->curElement = ELEMENT; + pData->curProfile.bGrowthModifierMechanical = (UINT32)strtoul(pData->szCharData, NULL, 0); + } + else if(strcmp(name, "bGrowthModifierExpLevel") == 0) + { + pData->curElement = ELEMENT; + pData->curProfile.bGrowthModifierExpLevel = (UINT32)strtoul(pData->szCharData, NULL, 0); + } } //////////////////////////////////////////////////////////////////////////// // SANDRO was here - messed this a bit @@ -1600,7 +1682,7 @@ BOOLEAN WriteMercProfiles() FilePrintf(hFile,"\t\t%d\r\n", gMercProfiles[ cnt ].bMedical); FilePrintf(hFile,"\t\t%d\r\n", gMercProfiles[ cnt ].bMechanical); FilePrintf(hFile,"\t\t%d\r\n", gMercProfiles[ cnt ].bExpLevel); - FilePrintf(hFile,"\t\t%d\r\n", gMercProfiles[ cnt ].bEvolution); + FilePrintf(hFile,"\t\t%d\r\n", gMercProfiles[ cnt ].fRegresses); //////////////////////////////////////////////////////////////////////////////////////////// // SANDRO - old/new traits if (gGameOptions.fNewTraitSystem) diff --git a/Tactical/soldier profile type.h b/Tactical/soldier profile type.h index a85653ea..8d427a5b 100644 --- a/Tactical/soldier profile type.h +++ b/Tactical/soldier profile type.h @@ -402,18 +402,7 @@ typedef enum NUM_SEXIST } SexistLevels; - - -// training defines for evolution, no stat increase, stat decrease( de-evolve ) -typedef enum -{ - NORMAL_EVOLUTION =0, - NO_EVOLUTION, - DEVOLVE, - THREEQUARTER_EVOLUTION, - HALF_EVOLUTION, - ONEQUARTER_EVOLUTION, -} CharacterEvolution; +// rftr: removed the CharacterEvolution enum as it was replaced by growth modifiers #define BUDDY_MERC( prof, bud ) ((prof)->bBuddy[0] == (bud) || (prof)->bBuddy[1] == (bud) || (prof)->bBuddy[2] == (bud) || (prof)->bBuddy[3] == (bud) || (prof)->bBuddy[4] == (bud) || ( (prof)->bLearnToLike == (bud) && (prof)->bLearnToLikeCount == 0 ) ) #define HATED_MERC( prof, hat ) ((prof)->bHated[0] == (hat) || (prof)->bHated[1] == (hat) || (prof)->bHated[2] == (hat) || (prof)->bHated[3] == (hat) || (prof)->bHated[4] == (hat) || ( (prof)->bLearnToHate == (hat) && (prof)->bLearnToHateCount == 0 ) ) @@ -789,7 +778,7 @@ public: INT8 bSex; INT8 bArmourAttractiveness; UINT8 ubMiscFlags2; - INT8 bEvolution; + BOOLEAN fRegresses; UINT8 ubMiscFlags; UINT8 bSexist; UINT8 bLearnToHate; @@ -1009,6 +998,19 @@ public: // Flugente: type of profile UINT32 Type; + + // rftr: growth modifiers - ignored if fRegresses is TRUE + INT16 bGrowthModifierLife; + INT16 bGrowthModifierStrength; + INT16 bGrowthModifierAgility; + INT16 bGrowthModifierDexterity; + INT16 bGrowthModifierWisdom; + INT16 bGrowthModifierMarksmanship; + INT16 bGrowthModifierExplosive; + INT16 bGrowthModifierLeadership; + INT16 bGrowthModifierMedical; + INT16 bGrowthModifierMechanical; + INT16 bGrowthModifierExpLevel; }; // MERCPROFILESTRUCT; // WANNE - BMP: DONE! diff --git a/TacticalAI/NPC.cpp b/TacticalAI/NPC.cpp index cf8d86c4..55606e27 100644 --- a/TacticalAI/NPC.cpp +++ b/TacticalAI/NPC.cpp @@ -808,7 +808,7 @@ INT32 GetEffectiveApproachValue( UINT8 usProfile, UINT8 usApproach, CHAR16* apSt if ( apStr ) { - swprintf( atStr, szLaptopStatText[0], threateneffectiveness ); + swprintf( atStr, szLaptopStatText[LAPTOP_STAT_TEXT_THREATEN_EFFECTIVENESS], threateneffectiveness ); wcscat( apStr, atStr ); } @@ -818,7 +818,7 @@ INT32 GetEffectiveApproachValue( UINT8 usProfile, UINT8 usApproach, CHAR16* apSt { if ( apStr ) { - swprintf( atStr, szLaptopStatText[1], gMercProfiles[usProfile].bLeadership ); + swprintf( atStr, szLaptopStatText[LAPTOP_STAT_TEXT_LEADERSHIP], gMercProfiles[usProfile].bLeadership ); wcscat( apStr, atStr ); } @@ -829,7 +829,7 @@ INT32 GetEffectiveApproachValue( UINT8 usProfile, UINT8 usApproach, CHAR16* apSt if ( apStr ) { - swprintf( atStr, szLaptopStatText[2], approachfactor ); + swprintf( atStr, szLaptopStatText[LAPTOP_STAT_TEXT_APPROACH_MODIFIER], approachfactor ); wcscat( apStr, atStr ); } @@ -855,7 +855,7 @@ INT32 GetEffectiveApproachValue( UINT8 usProfile, UINT8 usApproach, CHAR16* apSt if ( apStr ) { - swprintf( atStr, szLaptopStatText[3], bgmodifier ); + swprintf( atStr, szLaptopStatText[LAPTOP_STAT_TEXT_BACKGROUND_MODIFIER], bgmodifier ); wcscat( apStr, atStr ); } @@ -868,7 +868,7 @@ INT32 GetEffectiveApproachValue( UINT8 usProfile, UINT8 usApproach, CHAR16* apSt swprintf( atStr, L" \n" ); wcscat( apStr, atStr ); - swprintf( atStr, szLaptopStatText[4] ); + swprintf( atStr, szLaptopStatText[LAPTOP_STAT_TEXT_ASSERTIVE] ); wcscat( apStr, atStr ); } else if ( DoesMercHavePersonality( pSoldier, CHAR_TRAIT_MALICIOUS ) ) @@ -876,7 +876,7 @@ INT32 GetEffectiveApproachValue( UINT8 usProfile, UINT8 usApproach, CHAR16* apSt swprintf( atStr, L" \n" ); wcscat( apStr, atStr ); - swprintf( atStr, szLaptopStatText[5] ); + swprintf( atStr, szLaptopStatText[LAPTOP_STAT_TEXT_MALICIOUS] ); wcscat( apStr, atStr ); } } diff --git a/Utils/Text.h b/Utils/Text.h index 21037737..e2c3251c 100644 --- a/Utils/Text.h +++ b/Utils/Text.h @@ -3084,6 +3084,36 @@ extern STR16 szSMilitiaResourceText[]; extern STR16 szInteractiveActionText[]; extern STR16 szLaptopStatText[]; +enum +{ + LAPTOP_STAT_TEXT_THREATEN_EFFECTIVENESS, + LAPTOP_STAT_TEXT_LEADERSHIP, + LAPTOP_STAT_TEXT_APPROACH_MODIFIER, + LAPTOP_STAT_TEXT_BACKGROUND_MODIFIER, + LAPTOP_STAT_TEXT_ASSERTIVE, + LAPTOP_STAT_TEXT_MALICIOUS, + LAPTOP_STAT_TEXT_GOOD_GUY, + LAPTOP_STAT_TEXT_REFUSES_TO_ATTACK_NON_HOSTILES, + LAPTOP_STAT_TEXT_FRIENDLY_APPROACH, + LAPTOP_STAT_TEXT_DIRECT_APPROACH, + LAPTOP_STAT_TEXT_THREATEN_APPROACH, + LAPTOP_STAT_TEXT_RECRUIT_APPROACH, + LAPTOP_STAT_TEXT_MERC_REGRESSES, + LAPTOP_STAT_TEXT_FAST, + LAPTOP_STAT_TEXT_AVERAGE, + LAPTOP_STAT_TEXT_SLOW, + LAPTOP_STAT_TEXT_HEALTH_SPEED, + LAPTOP_STAT_TEXT_STRENGTH_SPEED, + LAPTOP_STAT_TEXT_AGILITY_SPEED, + LAPTOP_STAT_TEXT_DEXTERITY_SPEED, + LAPTOP_STAT_TEXT_WISDOM_SPEED, + LAPTOP_STAT_TEXT_MARKSMANSHIP_SPEED, + LAPTOP_STAT_TEXT_EXPLOSIVES_SPEED, + LAPTOP_STAT_TEXT_LEADERSHIP_SPEED, + LAPTOP_STAT_TEXT_MEDICAL_SPEED, + LAPTOP_STAT_TEXT_MECHANICAL_SPEED, + LAPTOP_STAT_TEXT_EXPERIENCE_SPEED, +}; // Flugente: gear templates extern STR16 szGearTemplateText[]; diff --git a/Utils/_ChineseText.cpp b/Utils/_ChineseText.cpp index 2a943df5..e587df2d 100644 --- a/Utils/_ChineseText.cpp +++ b/Utils/_ChineseText.cpp @@ -11655,13 +11655,21 @@ STR16 szLaptopStatText[] = L"威胁对话", //L"Threaten approach", L"招募对话", //L"Recruit approach", - L"%s正以正常速度学习。", //L"%s learns with normal speed.", - L"%s根本没有在学习。", //L"%s does not learn at all.", - L"%s遗忘了技能。", //L"%s unlearns his skills.", - L"%s正以3/4的速度学习。", //L"%s learns with 3/4 speed.", - - L"%s正以1/2的速度学习。", //L"%s learns with 1/2 speed.", - L"%s正以1/4的速度学习。", //L"%s learns with 1/4 speed.", + L"Stats will regress.", + L"Fast", + L"Average", + L"Slow", + L"Health growth", + L"Strength growth", + L"Agility growth", + L"Dexterity growth", + L"Wisdom growth", + L"Marksmanship growth", + L"Explosives growth", + L"Leadership growth", + L"Medical growth", + L"Mechanical growth", + L"Experience growth", }; STR16 szGearTemplateText[] = diff --git a/Utils/_DutchText.cpp b/Utils/_DutchText.cpp index 00abf9fc..4c56a70b 100644 --- a/Utils/_DutchText.cpp +++ b/Utils/_DutchText.cpp @@ -11664,13 +11664,21 @@ STR16 szLaptopStatText[] = // TODO.Translate L"Threaten approach", L"Recruit approach", - L"%s learns with normal speed.", // TODO.Translate - L"%s does not learn at all.", - L"%s unlearns his skills.", - L"%s learns with 3/4 speed.", - - L"%s learns with 1/2 speed.", - L"%s learns with 1/4 speed.", + L"Stats will regress.", + L"Fast", + L"Average", + L"Slow", + L"Health growth", + L"Strength growth", + L"Agility growth", + L"Dexterity growth", + L"Wisdom growth", + L"Marksmanship growth", + L"Explosives growth", + L"Leadership growth", + L"Medical growth", + L"Mechanical growth", + L"Experience growth", }; STR16 szGearTemplateText[] = // TODO.Translate diff --git a/Utils/_EnglishText.cpp b/Utils/_EnglishText.cpp index 5f4b9f5e..d2684b28 100644 --- a/Utils/_EnglishText.cpp +++ b/Utils/_EnglishText.cpp @@ -11655,13 +11655,21 @@ STR16 szLaptopStatText[] = L"Threaten approach", L"Recruit approach", - L"%s learns with normal speed.", - L"%s does not learn at all.", - L"%s unlearns his skills.", - L"%s learns with 3/4 speed.", - - L"%s learns with 1/2 speed.", - L"%s learns with 1/4 speed.", + L"Stats will regress.", + L"Fast", + L"Average", + L"Slow", + L"Health growth", + L"Strength growth", + L"Agility growth", + L"Dexterity growth", + L"Wisdom growth", + L"Marksmanship growth", + L"Explosives growth", + L"Leadership growth", + L"Medical growth", + L"Mechanical growth", + L"Experience growth", }; STR16 szGearTemplateText[] = diff --git a/Utils/_FrenchText.cpp b/Utils/_FrenchText.cpp index f97f68de..77fc295f 100644 --- a/Utils/_FrenchText.cpp +++ b/Utils/_FrenchText.cpp @@ -11646,13 +11646,21 @@ STR16 szLaptopStatText[] = // TODO.Translate L"Threaten approach", L"Recruit approach", - L"%s learns with normal speed.", // TODO.Translate - L"%s does not learn at all.", - L"%s unlearns his skills.", - L"%s learns with 3/4 speed.", - - L"%s learns with 1/2 speed.", - L"%s learns with 1/4 speed.", + L"Stats will regress.", + L"Fast", + L"Average", + L"Slow", + L"Health growth", + L"Strength growth", + L"Agility growth", + L"Dexterity growth", + L"Wisdom growth", + L"Marksmanship growth", + L"Explosives growth", + L"Leadership growth", + L"Medical growth", + L"Mechanical growth", + L"Experience growth", }; STR16 szGearTemplateText[] = // TODO.Translate diff --git a/Utils/_GermanText.cpp b/Utils/_GermanText.cpp index 0e86f7f6..62bc2deb 100644 --- a/Utils/_GermanText.cpp +++ b/Utils/_GermanText.cpp @@ -11560,13 +11560,21 @@ STR16 szLaptopStatText[] = L"Threaten approach", L"Recruit approach", - L"%s learns with normal speed.", // TODO.Translate - L"%s does not learn at all.", - L"%s unlearns his skills.", - L"%s learns with 3/4 speed.", - - L"%s learns with 1/2 speed.", - L"%s learns with 1/4 speed.", + L"Stats will regress.", + L"Fast", + L"Average", + L"Slow", + L"Health growth", + L"Strength growth", + L"Agility growth", + L"Dexterity growth", + L"Wisdom growth", + L"Marksmanship growth", + L"Explosives growth", + L"Leadership growth", + L"Medical growth", + L"Mechanical growth", + L"Experience growth", }; // TODO.Translate diff --git a/Utils/_ItalianText.cpp b/Utils/_ItalianText.cpp index 272ff9da..1968ae29 100644 --- a/Utils/_ItalianText.cpp +++ b/Utils/_ItalianText.cpp @@ -11655,13 +11655,21 @@ STR16 szLaptopStatText[] = // TODO.Translate L"Threaten approach", L"Recruit approach", - L"%s learns with normal speed.", // TODO.Translate - L"%s does not learn at all.", - L"%s unlearns his skills.", - L"%s learns with 3/4 speed.", - - L"%s learns with 1/2 speed.", - L"%s learns with 1/4 speed.", + L"Stats will regress.", + L"Fast", + L"Average", + L"Slow", + L"Health growth", + L"Strength growth", + L"Agility growth", + L"Dexterity growth", + L"Wisdom growth", + L"Marksmanship growth", + L"Explosives growth", + L"Leadership growth", + L"Medical growth", + L"Mechanical growth", + L"Experience growth", }; STR16 szGearTemplateText[] = // TODO.Translate diff --git a/Utils/_PolishText.cpp b/Utils/_PolishText.cpp index 35548ba1..379f3f5a 100644 --- a/Utils/_PolishText.cpp +++ b/Utils/_PolishText.cpp @@ -11668,13 +11668,21 @@ STR16 szLaptopStatText[] = // TODO.Translate L"Threaten approach", L"Recruit approach", - L"%s learns with normal speed.", // TODO.Translate - L"%s does not learn at all.", - L"%s unlearns his skills.", - L"%s learns with 3/4 speed.", - - L"%s learns with 1/2 speed.", - L"%s learns with 1/4 speed.", + L"Stats will regress.", + L"Fast", + L"Average", + L"Slow", + L"Health growth", + L"Strength growth", + L"Agility growth", + L"Dexterity growth", + L"Wisdom growth", + L"Marksmanship growth", + L"Explosives growth", + L"Leadership growth", + L"Medical growth", + L"Mechanical growth", + L"Experience growth", }; STR16 szGearTemplateText[] = // TODO.Translate diff --git a/Utils/_RussianText.cpp b/Utils/_RussianText.cpp index 0345b830..9b9b99e2 100644 --- a/Utils/_RussianText.cpp +++ b/Utils/_RussianText.cpp @@ -11650,13 +11650,21 @@ STR16 szLaptopStatText[] = // TODO.Translate L"Threaten approach", L"Recruit approach", - L"%s learns with normal speed.", // TODO.Translate - L"%s does not learn at all.", - L"%s unlearns his skills.", - L"%s learns with 3/4 speed.", - - L"%s learns with 1/2 speed.", - L"%s learns with 1/4 speed.", + L"Stats will regress.", + L"Fast", + L"Average", + L"Slow", + L"Health growth", + L"Strength growth", + L"Agility growth", + L"Dexterity growth", + L"Wisdom growth", + L"Marksmanship growth", + L"Explosives growth", + L"Leadership growth", + L"Medical growth", + L"Mechanical growth", + L"Experience growth", }; STR16 szGearTemplateText[] = // TODO.Translate From b91871b518af86c4b0c231495f6edebf2c55b1a8 Mon Sep 17 00:00:00 2001 From: rftrdev <102184004+rftrdev@users.noreply.github.com> Date: Fri, 11 Aug 2023 11:27:29 -0700 Subject: [PATCH 011/120] Move grenade bonuses from Demolitions to Throwing (#202) * Copy grenade settings from demolitions to throwing * Fix setting strings * Add throwing bonuses to the same spots as demolitions * Delete grenade bonuses from Demolitions * Update text * Reapply throwing check --- GameSettings.cpp | 6 +++--- GameSettings.h | 6 +++--- Laptop/personnel.cpp | 40 +++++++++++++++++++------------------- Tactical/Points.cpp | 4 ++-- Tactical/Weapons.cpp | 11 +++++------ Utils/_Ja25ChineseText.cpp | 6 +++--- Utils/_Ja25DutchText.cpp | 6 +++--- Utils/_Ja25EnglishText.cpp | 6 +++--- Utils/_Ja25FrenchText.cpp | 6 +++--- Utils/_Ja25GermanText.cpp | 6 +++--- Utils/_Ja25ItalianText.cpp | 6 +++--- Utils/_Ja25PolishText.cpp | 6 +++--- Utils/_Ja25RussianText.cpp | 6 +++--- 13 files changed, 57 insertions(+), 58 deletions(-) diff --git a/GameSettings.cpp b/GameSettings.cpp index 28bf1151..3263243b 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -2785,6 +2785,9 @@ void LoadSkillTraitsExternalSettings() gSkillTraitValues.ubTHBladesSilentCriticalHitChance = iniReader.ReadInteger("Throwing","TH_BLADES_SILENT_CRITICAL_HIT_CHANCE", 20, 0, 100); gSkillTraitValues.ubTHBladesCriticalHitMultiplierBonus = iniReader.ReadInteger("Throwing","SILENT_CRITICAL_HIT_MULTIPLIER_BONUS", 1, 0, 50); gSkillTraitValues.ubTHBladesAimClicksAdded = iniReader.ReadInteger("Throwing","POSSIBLE_AIM_CLICK_ADDED_TH_KNIVES", 1, 0, 5); + gSkillTraitValues.ubTHAPsNeededToThrowGrenadesReduction = iniReader.ReadInteger("Throwing","APS_NEEDED_TO_THROW_GRENADES_REDUCTION", 25, 0, 90); + gSkillTraitValues.ubTHMaxRangeToThrowGrenades = iniReader.ReadInteger("Throwing","MAX_RANGE_TO_THROW_GRENADES", 20, 0, 250); + gSkillTraitValues.ubTHCtHWhenThrowingGrenades = iniReader.ReadInteger("Throwing","CTH_WHEN_THROWING_GRENADES", 30, 0, 100); // NIGHT OPS gSkillTraitValues.ubNOeSightRangeBonusInDark = iniReader.ReadInteger("Night Ops","SIGHT_RANGE_BONUS_IN_DARK", 1, 0, 100); @@ -2811,9 +2814,6 @@ void LoadSkillTraitsExternalSettings() gSkillTraitValues.usBBIncreasedNeededDamageToFallDown = iniReader.ReadInteger("Bodybuilding","INCREASE_DAMAGE_NEEDED_TO_FALL_DOWN_IF_HIT_TO_LEGS", 100, 0, 500); // DEMOLITIONS - gSkillTraitValues.ubDEAPsNeededToThrowGrenadesReduction = iniReader.ReadInteger("Demolitions","APS_NEEDED_TO_THROW_GRENADES_REDUCTION", 25, 0, 90); - gSkillTraitValues.ubDEMaxRangeToThrowGrenades = iniReader.ReadInteger("Demolitions","MAX_RANGE_TO_THROW_GRENADES", 20, 0, 250); - gSkillTraitValues.ubDECtHWhenThrowingGrenades = iniReader.ReadInteger("Demolitions","CTH_WHEN_THROWING_GRENADES", 30, 0, 100); gSkillTraitValues.ubDEDamageOfBombsAndMines = iniReader.ReadInteger("Demolitions","DAMAGE_OF_PLACED_BOMBS_AND_MINES", 25, 0, 250); gSkillTraitValues.ubDEAttachDetonatorCheckBonus = iniReader.ReadInteger("Demolitions","ATTACH_DETONATOR_CHECK_BONUS", 50, 0, 250); gSkillTraitValues.ubDEPlantAndRemoveBombCheckBonus = iniReader.ReadInteger("Demolitions","PLANT_AND_REMOVE_BOMBS_AND_MINES_BONUS", 50, 0, 250); diff --git a/GameSettings.h b/GameSettings.h index 735538f3..207fa3da 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -2177,6 +2177,9 @@ typedef struct UINT8 ubTHBladesSilentCriticalHitChance; UINT8 ubTHBladesCriticalHitMultiplierBonus; UINT8 ubTHBladesAimClicksAdded; + UINT8 ubTHAPsNeededToThrowGrenadesReduction; + UINT8 ubTHMaxRangeToThrowGrenades; + UINT8 ubTHCtHWhenThrowingGrenades; // NIGHT OPS UINT8 ubNOeSightRangeBonusInDark; @@ -2203,9 +2206,6 @@ typedef struct UINT16 usBBIncreasedNeededDamageToFallDown; // DEMOLITIONS - UINT8 ubDEAPsNeededToThrowGrenadesReduction; - UINT8 ubDEMaxRangeToThrowGrenades; - UINT8 ubDECtHWhenThrowingGrenades; UINT8 ubDEDamageOfBombsAndMines; UINT8 ubDEAttachDetonatorCheckBonus; UINT8 ubDEPlantAndRemoveBombCheckBonus; diff --git a/Laptop/personnel.cpp b/Laptop/personnel.cpp index e2576e33..935b5cf0 100644 --- a/Laptop/personnel.cpp +++ b/Laptop/personnel.cpp @@ -8165,6 +8165,21 @@ void AssignPersonnelSkillTraitHelpText( UINT8 ubTraitNumber, BOOLEAN fExpertLeve wcscat( apStr, atStr ); } + if( gSkillTraitValues.ubTHAPsNeededToThrowGrenadesReduction != 0 ) + { + swprintf( atStr, gzIMPMinorTraitsHelpTextsThrowing[10], gSkillTraitValues.ubTHAPsNeededToThrowGrenadesReduction, sSpecialCharacters[0]); + wcscat( apStr, atStr ); + } + if( gSkillTraitValues.ubTHMaxRangeToThrowGrenades != 0 ) + { + swprintf( atStr, gzIMPMinorTraitsHelpTextsThrowing[11], gSkillTraitValues.ubTHMaxRangeToThrowGrenades, sSpecialCharacters[0]); + wcscat( apStr, atStr ); + } + if( gSkillTraitValues.ubTHCtHWhenThrowingGrenades != 0 ) + { + swprintf( atStr, gzIMPMinorTraitsHelpTextsThrowing[12], gSkillTraitValues.ubTHCtHWhenThrowingGrenades, sSpecialCharacters[0]); + wcscat( apStr, atStr ); + } break; } case NIGHT_OPS_NT: @@ -8270,44 +8285,29 @@ void AssignPersonnelSkillTraitHelpText( UINT8 ubTraitNumber, BOOLEAN fExpertLeve case DEMOLITIONS_NT: { swprintf( apStr, L"" ); - if( gSkillTraitValues.ubDEAPsNeededToThrowGrenadesReduction != 0 ) - { - swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[0], gSkillTraitValues.ubDEAPsNeededToThrowGrenadesReduction, sSpecialCharacters[0]); - wcscat( apStr, atStr ); - } - if( gSkillTraitValues.ubDEMaxRangeToThrowGrenades != 0 ) - { - swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[1], gSkillTraitValues.ubDEMaxRangeToThrowGrenades, sSpecialCharacters[0]); - wcscat( apStr, atStr ); - } - if( gSkillTraitValues.ubDECtHWhenThrowingGrenades != 0 ) - { - swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[2], gSkillTraitValues.ubDECtHWhenThrowingGrenades, sSpecialCharacters[0]); - wcscat( apStr, atStr ); - } if( gSkillTraitValues.ubDEDamageOfBombsAndMines != 0 ) { - swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[3], gSkillTraitValues.ubDEDamageOfBombsAndMines, sSpecialCharacters[0]); + swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[0], gSkillTraitValues.ubDEDamageOfBombsAndMines, sSpecialCharacters[0]); wcscat( apStr, atStr ); } if( gSkillTraitValues.ubDEAttachDetonatorCheckBonus != 0 ) { - swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[4], gSkillTraitValues.ubDEAttachDetonatorCheckBonus, sSpecialCharacters[0]); + swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[1], gSkillTraitValues.ubDEAttachDetonatorCheckBonus, sSpecialCharacters[0]); wcscat( apStr, atStr ); } if( gSkillTraitValues.ubDEPlantAndRemoveBombCheckBonus != 0 ) { - swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[5], gSkillTraitValues.ubDEPlantAndRemoveBombCheckBonus, sSpecialCharacters[0]); + swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[2], gSkillTraitValues.ubDEPlantAndRemoveBombCheckBonus, sSpecialCharacters[0]); wcscat( apStr, atStr ); } if( gSkillTraitValues.ubDEPlacedBombLevelBonus != 0 ) { - swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[6], gSkillTraitValues.ubDEPlacedBombLevelBonus); + swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[3], gSkillTraitValues.ubDEPlacedBombLevelBonus); wcscat( apStr, atStr ); } if( gSkillTraitValues.ubDEShapedChargeDamageMultiplier != 0 ) { - swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[7], gSkillTraitValues.ubDEShapedChargeDamageMultiplier); + swprintf( atStr, gzIMPMinorTraitsHelpTextsDemolitions[4], gSkillTraitValues.ubDEShapedChargeDamageMultiplier); wcscat( apStr, atStr ); } break; diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index 020d8df1..f16aacc8 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -3640,11 +3640,11 @@ INT16 MinAPsToThrow( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubAddTurningCos iAPCost += ( ( ( 100 * iTop ) / iBottom) + 1) / 2; // SANDRO - STOMP traits - reduce APs needed to throw grenades if having Demolitions skill - if( HAS_SKILL_TRAIT( pSoldier, DEMOLITIONS_NT ) && gGameOptions.fNewTraitSystem ) + if( HAS_SKILL_TRAIT( pSoldier, THROWING_NT ) && gGameOptions.fNewTraitSystem ) { if ( grenadAPreductionpossible ) { - iAPCost = max( 1, (INT32)(iAPCost * (100 - gSkillTraitValues.ubDEAPsNeededToThrowGrenadesReduction) / 100)); + iAPCost = max( 1, (INT32)(iAPCost * (100 - gSkillTraitValues.ubTHAPsNeededToThrowGrenadesReduction) / 100)); } } diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index b635debe..55acbf88 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -10175,10 +10175,10 @@ INT32 CalcMaxTossRange( SOLDIERTYPE * pSoldier, UINT16 usItem, BOOLEAN fArmed, O iRange += ((iRange * gSkillTraitValues.ubTHBladesMaxRange ) / 100); } // sevenfm: add range only for hand grenades and not launched grenades - else if ( (Item[ usItem ].usItemClass == IC_GRENADE) && Item[usItem].ubCursor == TOSSCURS && (HAS_SKILL_TRAIT( pSoldier, DEMOLITIONS_NT )) ) + else if ( (Item[ usItem ].usItemClass == IC_GRENADE) && Item[usItem].ubCursor == TOSSCURS && HAS_SKILL_TRAIT( pSoldier, THROWING_NT ) ) { // better max range due to expertise - iRange += ((iRange * gSkillTraitValues.ubDEMaxRangeToThrowGrenades) / 100); + iRange += ((iRange * gSkillTraitValues.ubTHMaxRangeToThrowGrenades) / 100); } } else @@ -10260,9 +10260,8 @@ UINT32 CalcThrownChanceToHit(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTi else { iChance += gSkillTraitValues.bCtHModifierThrowingGrenades; // -10% for untrained mercs - - if ( HAS_SKILL_TRAIT( pSoldier, DEMOLITIONS_NT ) ) - iChance += gSkillTraitValues.ubDECtHWhenThrowingGrenades; // +30% chance + if ( HAS_SKILL_TRAIT( pSoldier, THROWING_NT ) ) + iChance += gSkillTraitValues.ubTHCtHWhenThrowingGrenades; } } else @@ -12196,4 +12195,4 @@ BOOLEAN ArtilleryStrike( UINT16 usItem, UINT8 ubOwnerID, UINT32 usStartingGridNo //REAL_OBJECT* pObject = &( ObjectSlots[ iID ] ); return TRUE; -} \ No newline at end of file +} diff --git a/Utils/_Ja25ChineseText.cpp b/Utils/_Ja25ChineseText.cpp index 1a6feedd..919f2d14 100644 --- a/Utils/_Ja25ChineseText.cpp +++ b/Utils/_Ja25ChineseText.cpp @@ -310,6 +310,9 @@ STR16 gzIMPMinorTraitsHelpTextsThrowing[]= L"飞刀致命一击的额外伤害倍率 +%d\n",// L"+%d critical hit by throwing blade multiplier\n", L"飞刀的最大精瞄次数 +%d\n",// L"Adds %d more aim click for throwing blades\n", L"飞刀的最大精瞄次数 +%d\n",// L"Adds %d more aim clicks for throwing blades\n", + L"投掷手榴弹所需行动点 -%d%s\n",// L"-%d%s APs needed to throw grenades\n", + L"手榴弹最远投掷距离 +%d%s\n",// L"+%d%s max range when throwing grenades\n", + L"手榴弹的命中率 +%d%s\n",// L"+%d%s chance to hit when throwing grenades\n", }; STR16 gzIMPMinorTraitsHelpTextsNightOps[]= @@ -346,9 +349,6 @@ STR16 gzIMPMinorTraitsHelpTextsBodybuilding[]= STR16 gzIMPMinorTraitsHelpTextsDemolitions[]= { - L"投掷手榴弹所需行动点 -%d%s\n",// L"-%d%s APs needed to throw grenades\n", - L"手榴弹最远投掷距离 +%d%s\n",// L"+%d%s max range when throwing grenades\n", - L"手榴弹的命中率 +%d%s\n",// L"+%d%s chance to hit when throwing grenades\n", L"安置的炸弹和地雷的伤害 +%d%s\n",// L"+%d%s damage of set bombs and mines\n", L"组合炸弹的成功率 +%d%s\n",// L"+%d%s to attaching detonators check\n", L"安置/拆除炸弹成功率 +%d%s\n",// L"+%d%s to planting/removing bombs check\n", diff --git a/Utils/_Ja25DutchText.cpp b/Utils/_Ja25DutchText.cpp index 4548c46e..a2234862 100644 --- a/Utils/_Ja25DutchText.cpp +++ b/Utils/_Ja25DutchText.cpp @@ -310,6 +310,9 @@ STR16 gzIMPMinorTraitsHelpTextsThrowing[]= L"+%d critical hit with throwing blade multiplier\n", L"Adds %d more aim click for throwing blades\n", L"Adds %d more aim clicks for throwing blades\n", + L"-%d%s APs to throw grenades\n", + L"+%d%s max range when throwing grenades\n", + L"+%d%s CtH when throwing grenades\n", }; STR16 gzIMPMinorTraitsHelpTextsNightOps[]= @@ -346,9 +349,6 @@ STR16 gzIMPMinorTraitsHelpTextsBodybuilding[]= STR16 gzIMPMinorTraitsHelpTextsDemolitions[]= { - L"-%d%s APs to throw grenades\n", - L"+%d%s max range when throwing grenades\n", - L"+%d%s CtH when throwing grenades\n", L"+%d%s damage for set bombs and mines\n", L"+%d%s to attaching detonators check\n", L"+%d%s to planting/removing bombs check\n", diff --git a/Utils/_Ja25EnglishText.cpp b/Utils/_Ja25EnglishText.cpp index 63eb232a..b58a080d 100644 --- a/Utils/_Ja25EnglishText.cpp +++ b/Utils/_Ja25EnglishText.cpp @@ -310,6 +310,9 @@ STR16 gzIMPMinorTraitsHelpTextsThrowing[]= L"+%d critical hit with throwing blade multiplier\n", L"Adds %d more aim click for throwing blades\n", L"Adds %d more aim clicks for throwing blades\n", + L"-%d%s APs to throw grenades\n", + L"+%d%s max range when throwing grenades\n", + L"+%d%s CtH when throwing grenades\n", }; STR16 gzIMPMinorTraitsHelpTextsNightOps[]= @@ -346,9 +349,6 @@ STR16 gzIMPMinorTraitsHelpTextsBodybuilding[]= STR16 gzIMPMinorTraitsHelpTextsDemolitions[]= { - L"-%d%s APs to throw grenades\n", - L"+%d%s max range when throwing grenades\n", - L"+%d%s CtH when throwing grenades\n", L"+%d%s damage for set bombs and mines\n", L"+%d%s to attaching detonators check\n", L"+%d%s to planting/removing bombs check\n", diff --git a/Utils/_Ja25FrenchText.cpp b/Utils/_Ja25FrenchText.cpp index 290158fc..f20af04a 100644 --- a/Utils/_Ja25FrenchText.cpp +++ b/Utils/_Ja25FrenchText.cpp @@ -309,6 +309,9 @@ STR16 gzIMPMinorTraitsHelpTextsThrowing[]= L"+%d de dégâts critiques, si vous lancez plusieurs couteaux\n", L"Ajoute %d niveau(x) de visée pour lancer un couteau\n", L"Ajoute %d niveau(x) de visée pour lancer un couteau\n", + L"-%d%s du nombre de PA nécessaire pour lancer une grenade\n", + L"+%d%s de la portée maximale d'une grenade\n", + L"+%d%s de chance de toucher votre cible avec une grenade\n", }; STR16 gzIMPMinorTraitsHelpTextsNightOps[]= @@ -344,9 +347,6 @@ STR16 gzIMPMinorTraitsHelpTextsBodybuilding[]= }; STR16 gzIMPMinorTraitsHelpTextsDemolitions[]= { - L"-%d%s du nombre de PA nécessaire pour lancer une grenade\n", - L"+%d%s de la portée maximale d'une grenade\n", - L"+%d%s de chance de toucher votre cible avec une grenade\n", L"+%d%s de dégâts causés par un explosif ou une mine\n", L"+%d%s pour contrôler un détonateur\n", L"+%d%s pour placer/retirer un contrôleur d'explosif\n", diff --git a/Utils/_Ja25GermanText.cpp b/Utils/_Ja25GermanText.cpp index c1e9666e..a19fa526 100644 --- a/Utils/_Ja25GermanText.cpp +++ b/Utils/_Ja25GermanText.cpp @@ -310,6 +310,9 @@ STR16 gzIMPMinorTraitsHelpTextsThrowing[]= L"+%d Multiplikator für kritische Treffer durch Wurfwaffen\n", L"Gibt einen weiteren Zielklick beim Einsatz von Wurfwaffen\n", L"Gibt %d weitere Zielklicks beim Einsatz von Wurfwaffen\n", + L"-%d%s APs benötigt um Handgranaten (und ähnliche Objekte) zu werfen\n", + L"+%d%s höhere Reichweite beim Werfen von Handgranaten (und ähnliche Objekten)\n", + L"+%d%s höhere Trefferwahrscheinlichkeit beim Werfen von Handgranaten (und ähnlichen Objekten)\n", }; STR16 gzIMPMinorTraitsHelpTextsNightOps[]= @@ -346,9 +349,6 @@ STR16 gzIMPMinorTraitsHelpTextsBodybuilding[]= STR16 gzIMPMinorTraitsHelpTextsDemolitions[]= { - L"-%d%s APs benötigt um Handgranaten (und ähnliche Objekte) zu werfen\n", - L"+%d%s höhere Reichweite beim Werfen von Handgranaten (und ähnliche Objekten)\n", - L"+%d%s höhere Trefferwahrscheinlichkeit beim Werfen von Handgranaten (und ähnlichen Objekten)\n", L"+%d%s höherer Schaden für gelegte Bomben und Minen\n", L"+%d%s mehr Erfolg beim Anbringen von Zündern\n", L"+%d%s mehr Erfolg beim Legen und Entschärfen von Bomben\n", diff --git a/Utils/_Ja25ItalianText.cpp b/Utils/_Ja25ItalianText.cpp index 5bd9c790..4ffb9454 100644 --- a/Utils/_Ja25ItalianText.cpp +++ b/Utils/_Ja25ItalianText.cpp @@ -308,6 +308,9 @@ STR16 gzIMPMinorTraitsHelpTextsThrowing[]= L"+%d critical hit with throwing blade multiplier\n", L"Adds %d more aim click for throwing blades\n", L"Adds %d more aim clicks for throwing blades\n", + L"-%d%s APs to throw grenades\n", + L"+%d%s max range when throwing grenades\n", + L"+%d%s CtH when throwing grenades\n", }; STR16 gzIMPMinorTraitsHelpTextsNightOps[]= @@ -344,9 +347,6 @@ STR16 gzIMPMinorTraitsHelpTextsBodybuilding[]= STR16 gzIMPMinorTraitsHelpTextsDemolitions[]= { - L"-%d%s APs to throw grenades\n", - L"+%d%s max range when throwing grenades\n", - L"+%d%s CtH when throwing grenades\n", L"+%d%s damage for set bombs and mines\n", L"+%d%s to attaching detonators check\n", L"+%d%s to planting/removing bombs check\n", diff --git a/Utils/_Ja25PolishText.cpp b/Utils/_Ja25PolishText.cpp index 506e37c1..9446a5b2 100644 --- a/Utils/_Ja25PolishText.cpp +++ b/Utils/_Ja25PolishText.cpp @@ -310,6 +310,9 @@ STR16 gzIMPMinorTraitsHelpTextsThrowing[]= L"+%d critical hit with throwing blade multiplier\n", L"Adds %d more aim click for throwing blades\n", L"Adds %d more aim clicks for throwing blades\n", + L"-%d%s APs to throw grenades\n", + L"+%d%s max range when throwing grenades\n", + L"+%d%s CtH when throwing grenades\n", }; STR16 gzIMPMinorTraitsHelpTextsNightOps[]= @@ -346,9 +349,6 @@ STR16 gzIMPMinorTraitsHelpTextsBodybuilding[]= STR16 gzIMPMinorTraitsHelpTextsDemolitions[]= { - L"-%d%s APs to throw grenades\n", - L"+%d%s max range when throwing grenades\n", - L"+%d%s CtH when throwing grenades\n", L"+%d%s damage for set bombs and mines\n", L"+%d%s to attaching detonators check\n", L"+%d%s to planting/removing bombs check\n", diff --git a/Utils/_Ja25RussianText.cpp b/Utils/_Ja25RussianText.cpp index 022b1f59..8ce7b35f 100644 --- a/Utils/_Ja25RussianText.cpp +++ b/Utils/_Ja25RussianText.cpp @@ -310,6 +310,9 @@ STR16 gzIMPMinorTraitsHelpTextsThrowing[]= L"+%d к множителю критического урона при броске ножа\n", L"+%d клик прицеливания для метательных ножей\n", L"+%d кликов прицеливания для метательных ножей\n", + L"-%d%s ОД для броска гранаты\n", + L"+%d%s к максимальной дальности броска гранаты\n", + L"+%d%s к точности броска гранаты\n", }; STR16 gzIMPMinorTraitsHelpTextsNightOps[]= @@ -346,9 +349,6 @@ STR16 gzIMPMinorTraitsHelpTextsBodybuilding[]= STR16 gzIMPMinorTraitsHelpTextsDemolitions[]= { - L"-%d%s ОД для броска гранаты\n", - L"+%d%s к максимальной дальности броска гранаты\n", - L"+%d%s к точности броска гранаты\n", L"+%d%s к урону для установленных бомб и мин\n", L"+%d%s к умению устанавливать детонатор\n", L"+%d%s к установке/разминированию бомб\n", From 5400fb019dcd4c97f7445474fa73cc94ce720981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Fa=C5=82kowski?= Date: Sat, 19 Aug 2023 22:30:57 +0200 Subject: [PATCH 012/120] Loading screen multiple resolutions support and stretch modes, loading bar fixes --- GameSettings.cpp | 4 +- GameSettings.h | 1 + Loading Screen.cpp | 127 ++++++++++++++++++++++++--------- Loading Screen.h | 2 + SaveLoadGame.cpp | 18 ++--- Utils/Animated ProgressBar.cpp | 57 ++++++++++----- 6 files changed, 149 insertions(+), 60 deletions(-) diff --git a/GameSettings.cpp b/GameSettings.cpp index 3791ae0c..349fa561 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -1147,7 +1147,9 @@ void LoadGameExternalOptions() giTimerIntervals[ NEXTSCROLL ] = (INT16)(giTimerIntervals[ NEXTSCROLL ] / gGameExternalOptions.fScrollSpeedFactor); gGameExternalOptions.gfUseExternalLoadscreens = iniReader.ReadBoolean("Graphics Settings","USE_EXTERNALIZED_LOADSCREENS", FALSE); - + + gGameExternalOptions.ubLoadscreenStretchMode = iniReader.ReadInteger("Graphics Settings", "LOADSCREEN_STRETCH_MODE", 0, 0, 2); + if (!is_networked) gGameExternalOptions.gfUseLoadScreenHints = iniReader.ReadBoolean("Graphics Settings","USE_LOADSCREENHINTS", TRUE); else diff --git a/GameSettings.h b/GameSettings.h index 5bdeb6dc..523066f5 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -781,6 +781,7 @@ typedef struct INT32 ubEnemiesItemDrop; BOOLEAN gfUseExternalLoadscreens; + UINT32 ubLoadscreenStretchMode; // added by anv BOOLEAN gfUseLoadScreenHints; // added by Flugente UINT32 ubAdditionalDelayUntilLoadScreenDisposal; // added by WANNE to have time to read the load screen hints diff --git a/Loading Screen.cpp b/Loading Screen.cpp index a0641d3b..2650cc9f 100644 --- a/Loading Screen.cpp +++ b/Loading Screen.cpp @@ -23,6 +23,7 @@ extern BOOLEAN gfSchedulesHosed; #include "Ja25 Strategic Ai.h" #endif UINT8 gubLastLoadingScreenID = LOADINGSCREEN_NOTHING; +FLOAT fLoadingScreenAspectRatio; //BOOLEAN bShowSmallImage = FALSE; SECTOR_LOADSCREENS gSectorLoadscreens[MAX_SECTOR_LOADSCREENS]; @@ -343,6 +344,62 @@ static void BuildLoadscreenFilename(std::string& dst, const char* path, int reso dst.append(".sti"); } +std::string GetResolutionSuffix(SCREEN_RESOLUTION resolution) +{ + switch (resolution) + { + case _960x540: return "_960x540"; + case _800x600: return "_800x600"; + case _1024x600: return "_1024x600"; + case _1280x720: return "_1280x720"; + case _1024x768: return "_1024x768"; + case _1280x768: return "_1280x768"; + case _1360x768: return "_1360x768"; + case _1366x768: return "_1366x768"; + case _1280x800: return "_1280x800"; + case _1440x900: return "_1440x900"; + case _1600x900: return "_1600x900"; + case _1280x960: return "_1280x960"; + case _1440x960: return "_1440x960"; + case _1770x1000: return "_1770x1000"; + case _1280x1024: return "_1280x1024"; + case _1360x1024: return "_1360x1024"; + case _1600x1024: return "_1600x1024"; + case _1440x1050: return "_1440x1050"; + case _1680x1050: return "_1680x1050"; + case _1920x1080: return "_1920x1080"; + case _1600x1200: return "_1600x1200"; + case _1920x1200: return "_1920x1200"; + case _2560x1440: return "_2560x1440"; + case _2560x1600: return "_2560x1600"; + default: return ""; + } +} + +std::string FindBestFittingLoadscreenFilename(const std::string& baseName, SCREEN_RESOLUTION resolution) +{ + for (SCREEN_RESOLUTION res = resolution; res <= _2560x1600; res = (SCREEN_RESOLUTION)(res + 1)) + { + std::string fileName = baseName + GetResolutionSuffix(res); + if (FileExists((CHAR8*)((fileName + ".png").c_str()))) + { + return fileName + ".png"; + } + + if (FileExists((CHAR8*)((fileName + ".sti").c_str()))) + { + return fileName + ".sti"; + } + } + + if (FileExists((CHAR8*)((baseName + ".png").c_str()))) + { + return baseName + ".png"; + } + + return baseName + ".sti"; +} + //sets up the loadscreen with specified ID, and draws it to the FRAME_BUFFER, //and refreshing the screen with it. void DisplayLoadScreenWithID( UINT8 ubLoadScreenID ) @@ -420,27 +477,8 @@ void DisplayLoadScreenWithID( UINT8 ubLoadScreenID ) } } - std::string strImage; - - BuildLoadscreenFilename(strImage, imagePath.c_str(), 0, imageFormat.c_str()); - strImage.copy(vs_desc.ImageFile, sizeof(vs_desc.ImageFile)-1); - - - if ( !FileExists(vs_desc.ImageFile) ) - { - std::string strImage; - BuildLoadscreenFilename(strImage, imagePath.c_str(), 0, "png"); - strImage.copy(vs_desc.ImageFile, sizeof(vs_desc.ImageFile) - 1); - - if (!FileExists(vs_desc.ImageFile)) - { - std::string strImage("LOADSCREENS\\"); - - BuildLoadscreenFilename(strImage, LoadScreenNames[1], 0, imageFormat.c_str()); - - strImage.copy(vs_desc.ImageFile, sizeof(vs_desc.ImageFile) - 1); - } - } + std::string strImage = FindBestFittingLoadscreenFilename(imagePath, (SCREEN_RESOLUTION)iResolution); + strImage.copy(vs_desc.ImageFile, sizeof(vs_desc.ImageFile) - 1); } else { @@ -475,18 +513,41 @@ void DisplayLoadScreenWithID( UINT8 ubLoadScreenID ) //Blit the background image GetVideoSurface(&hVSurface, uiLoadScreen); - - // Stretch the background image - SrcRect.iLeft = 0; - SrcRect.iTop = 0; - SrcRect.iRight = hVSurface->usWidth; - SrcRect.iBottom = hVSurface->usHeight; - - DstRect.iLeft = 0; - DstRect.iTop = 0; - DstRect.iRight = SCREEN_WIDTH; - DstRect.iBottom = SCREEN_HEIGHT; - + + fLoadingScreenAspectRatio = (FLOAT)hVSurface->usWidth / (FLOAT)hVSurface->usHeight; + FLOAT fScreenAspectRatio = (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT; + + if (gGameExternalOptions.ubLoadscreenStretchMode == 1 || + (gGameExternalOptions.ubLoadscreenStretchMode == 2 && fLoadingScreenAspectRatio > fScreenAspectRatio)) + { + // match height, preserve aspect ratio + INT32 iCalculatedWidth = (INT32)(SCREEN_HEIGHT * fLoadingScreenAspectRatio + 0.5f); + + SrcRect.iLeft = 0; + SrcRect.iTop = 0; + SrcRect.iRight = hVSurface->usWidth; + SrcRect.iBottom = hVSurface->usHeight; + + DstRect.iLeft = (SCREEN_WIDTH - iCalculatedWidth) / 2; + DstRect.iTop = 0; + DstRect.iRight = SCREEN_WIDTH - ((SCREEN_WIDTH - iCalculatedWidth) / 2); + DstRect.iBottom = SCREEN_HEIGHT; + } + else + { + // vanilla (stretch to fit) + // Stretch the background image + SrcRect.iLeft = 0; + SrcRect.iTop = 0; + SrcRect.iRight = hVSurface->usWidth; + SrcRect.iBottom = hVSurface->usHeight; + + DstRect.iLeft = 0; + DstRect.iTop = 0; + DstRect.iRight = SCREEN_WIDTH; + DstRect.iBottom = SCREEN_HEIGHT; + } + BltStretchVideoSurface( FRAME_BUFFER, uiLoadScreen, 0, 0, 0, &SrcRect, &DstRect ); DeleteVideoSurfaceFromIndex( uiLoadScreen ); diff --git a/Loading Screen.h b/Loading Screen.h index fa5bc658..831c9e2b 100644 --- a/Loading Screen.h +++ b/Loading Screen.h @@ -84,6 +84,8 @@ enum //For use by the game loader, before it can possibly know the situation. extern UINT8 gubLastLoadingScreenID; +extern FLOAT fLoadingScreenAspectRatio; + //returns the UINT8 ID for the specified sector. UINT8 GetLoadScreenID( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ ); diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index 5c245e84..844e49d6 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -6694,15 +6694,6 @@ BOOLEAN LoadSavedGame( int ubSavedGameID ) //Reset the Ai Timer clock giRTAILastUpdateTime = 0; - //if we are in tactical - if( guiScreenToGotoAfterLoadingSavedGame == GAME_SCREEN ) - { - //Initialize the current panel - InitializeCurrentPanel( ); - - SelectSoldier( gusSelectedSoldier, FALSE, TRUE ); - } - uiRelEndPerc += 1; SetRelativeStartAndEndPercentage( 0, uiRelStartPerc, uiRelEndPerc, L"Final Checks..." ); RenderProgressBar( 0, 100 ); @@ -6831,6 +6822,15 @@ BOOLEAN LoadSavedGame( int ubSavedGameID ) RemoveLoadingScreenProgressBar(); + //if we are in tactical + if (guiScreenToGotoAfterLoadingSavedGame == GAME_SCREEN) + { + //Initialize the current panel + InitializeCurrentPanel(); + + SelectSoldier(gusSelectedSoldier, FALSE, TRUE); + } + // sevenfm: reset sound map ResetSoundMap(); diff --git a/Utils/Animated ProgressBar.cpp b/Utils/Animated ProgressBar.cpp index 652d5f05..5cdfa0ab 100644 --- a/Utils/Animated ProgressBar.cpp +++ b/Utils/Animated ProgressBar.cpp @@ -14,6 +14,7 @@ #include "WordWrap.h" #include "Message.h" #include "Text.h" + #include "Loading Screen.h" double rStart, rEnd; double rActual; @@ -63,10 +64,31 @@ void CreateLoadingScreenProgressBar(BOOLEAN resetLoadScreenHint) // CreateProgressBar(0, 259 + ((SCREEN_WIDTH - 1024) / 2), 683 + ((SCREEN_HEIGHT - 768) / 2), 767 + ((SCREEN_WIDTH - 1024) / 2), 708 + ((SCREEN_HEIGHT - 768) / 2)); // } //} - - CreateProgressBar(0, SCREEN_WIDTH*162/640, SCREEN_HEIGHT*427/480, SCREEN_WIDTH*480/640, SCREEN_HEIGHT*443/480); + FLOAT fScreenAspectRatio = (FLOAT)SCREEN_WIDTH / (FLOAT)SCREEN_HEIGHT; + if (gGameExternalOptions.ubLoadscreenStretchMode == 1 || + (gGameExternalOptions.ubLoadscreenStretchMode == 2 && fLoadingScreenAspectRatio > fScreenAspectRatio)) + { + // match height, preserve aspect ratioernalOptions.ubLoadscreenStretchMode == 2 && fLoadingScreenAspectRatio > fScreenAspectRatio)) + INT32 iCalculatedWidth = (INT32)(SCREEN_HEIGHT * fLoadingScreenAspectRatio + 0.5f); + + UINT16 usLeft = (UINT16)((SCREEN_WIDTH - iCalculatedWidth) / 2 + (iCalculatedWidth * 162.0f / 640.0f) + 0.5f); + UINT16 usTop = (UINT16)((SCREEN_HEIGHT * 427.0f / 480.0f) + 0.5f); + UINT16 usRight = (UINT16)((SCREEN_WIDTH - iCalculatedWidth) / 2 + (iCalculatedWidth * 478.0f / 640.0f) + 0.5f); + UINT16 usBottom = (UINT16)((SCREEN_HEIGHT * 443.0f / 480.0f) + 0.5f); + + CreateProgressBar(0, usLeft, usTop, usRight, usBottom); + } + else + { + UINT16 usLeft = (UINT16)((SCREEN_WIDTH * 162.0f / 640.0f) + 0.5f); + UINT16 usTop = (UINT16)((SCREEN_HEIGHT * 427.0f / 480.0f) + 0.5f); + UINT16 usRight = (UINT16)((SCREEN_WIDTH * 478.0f / 640.0f) + 0.5f); + UINT16 usBottom = (UINT16)((SCREEN_HEIGHT * 443.0f / 480.0f) + 0.5f); + + CreateProgressBar(0, usLeft, usTop, usRight, usBottom); + } SetProgressBarUseBorder(0, FALSE ); } @@ -334,6 +356,8 @@ void SetRelativeStartAndEndPercentage( UINT8 ubID, UINT16 uiRelStartPerc, UINT16 pCurr->rStart = (double)uiRelStartPerc*0.01f; pCurr->rEnd = (double)uiRelEndPerc*0.01f; + UINT8 yTextOffset = (UINT8)(3.0f * SCREEN_HEIGHT / 480.0f + 0.5f); + //Render the entire panel now, as it doesn't need update during the normal rendering if( pCurr->fPanel ) { @@ -352,7 +376,7 @@ void SetRelativeStartAndEndPercentage( UINT8 ubID, UINT16 uiRelStartPerc, UINT16 usStartX = pCurr->usPanelLeft + // left position (pCurr->usPanelRight - pCurr->usPanelLeft)/2 - // + half width StringPixLength( pCurr->swzTitle, pCurr->usTitleFont ) / 2; // - half string width - usStartY = pCurr->usPanelTop + 3; + usStartY = pCurr->usPanelTop + yTextOffset; SetFont( pCurr->usTitleFont ); SetFontForeground( pCurr->ubTitleFontForeColor ); SetFontShadow( pCurr->ubTitleFontShadowColor ); @@ -370,21 +394,21 @@ void SetRelativeStartAndEndPercentage( UINT8 ubID, UINT16 uiRelStartPerc, UINT16 { UINT16 usFontHeight = GetFontHeight( pCurr->usMsgFont ); - RestoreExternBackgroundRect( pCurr->usBarLeft, pCurr->usBarBottom, (INT16)(pCurr->usBarRight-pCurr->usBarLeft), (INT16)(usFontHeight + 3) ); + RestoreExternBackgroundRect( pCurr->usBarLeft, pCurr->usBarBottom, (INT16)(pCurr->usBarRight-pCurr->usBarLeft), (INT16)(usFontHeight + yTextOffset) ); } SetFont( pCurr->usMsgFont ); SetFontForeground( pCurr->ubMsgFontForeColor ); SetFontShadow( pCurr->ubMsgFontShadowColor ); SetFontBackground( 0 ); - mprintf( pCurr->usBarLeft, pCurr->usBarBottom + 3, str ); + mprintf( pCurr->usBarLeft, pCurr->usBarBottom + yTextOffset, str ); } } // Flugente: loadscreen hints if (gGameExternalOptions.gfUseLoadScreenHints && usCurrentLoadScreenHint ) { - ShowLoadScreenHintInLoadScreen(pCurr->usBarBottom + 3 - 100); + ShowLoadScreenHintInLoadScreen(pCurr->usBarBottom + yTextOffset - 100); } } @@ -408,25 +432,24 @@ void RenderProgressBar( UINT8 ubID, UINT32 uiPercentage ) if( pCurr ) { - rActual = pCurr->rStart+(pCurr->rEnd-pCurr->rStart)*uiPercentage*0.01; + rActual = pCurr->rStart + (pCurr->rEnd - pCurr->rStart) * uiPercentage * 0.01; - if( fabs(rActual - pCurr->rLastActual) < 0.01 ) + pCurr->rLastActual = (DOUBLE)((INT32)(std::round(rActual * 100)) * 0.01); + + end = (INT32)(pCurr->usBarLeft + std::round(rActual * (pCurr->usBarRight - pCurr->usBarLeft))); + if (end < pCurr->usBarLeft) { - return; + end = pCurr->usBarLeft; } - - pCurr->rLastActual = ( DOUBLE )( ( INT32)( rActual * 100 ) * 0.01 ); - - end = (INT32)(pCurr->usBarLeft+2.0+rActual*(pCurr->usBarRight-pCurr->usBarLeft-4)); - if( end < pCurr->usBarLeft+2 || end > pCurr->usBarRight-2 ) + else if (end > pCurr->usBarRight) { - return; + end = pCurr->usBarRight; } if( !pCurr->fDrawBorder ) { ColorFillVideoSurfaceArea( pCurr->uiFrameBuffer, //FRAME_BUFFER, pCurr->usBarLeft, pCurr->usBarTop, end, pCurr->usBarBottom, - Get16BPPColor(FROMRGB( pCurr->ubColorFillRed, pCurr->ubColorFillGreen, pCurr->ubColorFillBlue )) ); + Get16BPPColor(FROMRGB(pCurr->ubColorFillRed, pCurr->ubColorFillGreen, pCurr->ubColorFillBlue))); //if( pCurr->usBarRight > gusLeftmostShaded ) //{ // ShadowVideoSurfaceRect( FRAME_BUFFER, gusLeftmostShaded+1, pCurr->usBarTop, end, pCurr->usBarBottom ); @@ -493,7 +516,7 @@ void SetProgressBarTextDisplayFlag( UINT8 ubID, BOOLEAN fDisplayText, BOOLEAN fU //if we are to use the save buffer, blit the portion of the screen to the save buffer if( fSaveScreenToFrameBuffer ) { - UINT16 usFontHeight = GetFontHeight( pCurr->usMsgFont )+3; + UINT16 usFontHeight = GetFontHeight(pCurr->usMsgFont) + (UINT8)(3.0f * SCREEN_HEIGHT / 480.f + 0.5f); //blit everything to the save buffer ( cause the save buffer can bleed through ) BlitBufferToBuffer(guiRENDERBUFFER, guiSAVEBUFFER, pCurr->usBarLeft, pCurr->usBarBottom, (UINT16)(pCurr->usBarRight-pCurr->usBarLeft), usFontHeight ); From 2060022e944e6171abd8937cc60ee19cf184af2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Fa=C5=82kowski?= Date: Sun, 20 Aug 2023 19:52:34 +0200 Subject: [PATCH 013/120] Battle Panel Multi Resolution (#203) * Battle panel interface with support for multiple resolutions and scrollable list * Support for localized versions of battle panel * Removed commented out code * Fixed wrong copypasta in German version --- Strategic/Auto Resolve.cpp | 4 +- Strategic/Map Screen Interface Bottom.cpp | 2 +- Strategic/PreBattle Interface.cpp | 324 +++++++++++++--------- Strategic/PreBattle Interface.h | 1 + Strategic/mapscreen.cpp | 38 ++- Utils/Multi Language Graphic Utils.cpp | 36 +++ Utils/Multi Language Graphic Utils.h | 3 + 7 files changed, 268 insertions(+), 140 deletions(-) diff --git a/Strategic/Auto Resolve.cpp b/Strategic/Auto Resolve.cpp index 04fa2d56..2029541e 100644 --- a/Strategic/Auto Resolve.cpp +++ b/Strategic/Auto Resolve.cpp @@ -681,7 +681,7 @@ UINT32 AutoResolveScreenHandle() SGPRect ClipRect; gpAR->fEnteringAutoResolve = FALSE; //Take the framebuffer, shade it, and save it to the SAVEBUFFER. - ClipRect.iLeft = 0 + xResOffset; + ClipRect.iLeft = 0; ClipRect.iTop = 0; /*ClipRect.iRight = 640; ClipRect.iBottom = 480;*/ @@ -692,7 +692,7 @@ UINT32 AutoResolveScreenHandle() Blt16BPPBufferShadowRect( (UINT16*)pDestBuf, uiDestPitchBYTES, &ClipRect ); UnLockVideoSurface( FRAME_BUFFER ); //BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, 0, 0, 640, 480 ); - BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, 0 + xResOffset, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); + BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); KillPreBattleInterface(); CalculateAutoResolveInfo(); CalculateSoldierCells( FALSE ); diff --git a/Strategic/Map Screen Interface Bottom.cpp b/Strategic/Map Screen Interface Bottom.cpp index 0c5530ab..1cb96593 100644 --- a/Strategic/Map Screen Interface Bottom.cpp +++ b/Strategic/Map Screen Interface Bottom.cpp @@ -1936,7 +1936,7 @@ BOOLEAN AllowedToExitFromMapscreenTo( INT8 bExitToWhere ) } // battle about to occur? - if( ( fDisableDueToBattleRoster ) || ( fDisableMapInterfaceDueToBattle ) ) + if( ( fDisableDueToBattleRoster ) || ( fDisableMapInterfaceDueToBattle ) || ( gfPreBattleInterfaceActive )) { return( FALSE ); } diff --git a/Strategic/PreBattle Interface.cpp b/Strategic/PreBattle Interface.cpp index f05cf42e..a26c7ab8 100644 --- a/Strategic/PreBattle Interface.cpp +++ b/Strategic/PreBattle Interface.cpp @@ -48,6 +48,7 @@ #include "militiasquads.h" // added by Flugente #include "SkillCheck.h" // added by Flugente #include "Strategic Transport Groups.h" + #include "Utilities.h" #ifdef JA2UB #include "ub_config.h" @@ -99,13 +100,23 @@ enum //GraphicIDs for the panel #define ROW_HEIGHT 10 //The start of the black space #define TOP_Y 113 +#define TOP_Y_TEXT_BUFFER 1 //The end of the black space -//#define BOTTOM_Y (349+(OUR_TEAM_SIZE_NO_VEHICLE-18)*ROW_HEIGHT) -#define BOTTOM_Y 349 +#define BOTTOM_HEIGHT 8 //The internal height of the uninvolved panel -#define INTERNAL_HEIGHT 27 -//The actual height of the uninvolved panel -#define ACTUAL_HEIGHT 24 +#define UNINVOLVED_RELEVANT_HEIGHT 28 +#define UNINVOLVED_OFFSET_HEIGHT 7 + +#define PREBATTLE_INTERFACE_WIDTH 261 +INT32 iPrebattleInterfaceHeight = 360; +UINT16 xOffset; +UINT16 yOffset; +UINT16 blanketStartX; +UINT16 blanketStartY; + +INT16 bListOffset = 0; +UINT16 ubDesiredListHeight = 0; +UINT16 ubAllowedListHeight = 0; BOOLEAN gfDisplayPotentialRetreatPaths = FALSE; UINT16 gusRetreatButtonLeft, gusRetreatButtonTop, gusRetreatButtonRight, gusRetreatButtonBottom; @@ -300,6 +311,8 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI ) gAmbushRadiusModifier = 0.0f; + bListOffset = 0; + // ARM: Feb01/98 - Cancel out of mapscreen movement plotting if PBI subscreen is coming up if ( ( GetSelectedDestChar() != -1) || fPlotForHelicopter || fPlotForMilitia ) { @@ -481,32 +494,69 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI ) fMapScreenBottomDirty = TRUE; ChangeSelectedMapSector( gubPBSectorX, gubPBSectorY, gubPBSectorZ ); - // Headrock: Added FALSE argument, We might need TRUE but not sure. Will need to initiate battle :) - RenderMapScreenInterfaceBottom( FALSE ); if( !fShowTeamFlag ) { ToggleShowTeamsMode(); } - //Define the blanket region to cover all of the other regions used underneath the panel. - MSYS_DefineRegion( &PBInterfaceBlanket, 0 + xResOffset, 0 + yResOffset, 261 + xResOffset, 359 + yResOffset, MSYS_PRIORITY_HIGHEST - 5, 0, 0, 0 ); - //Create the panel VObjectDesc.fCreateFlags = VOBJECT_CREATE_FROMFILE; - GetMLGFilename( VObjectDesc.ImageFile, MLG_PREBATTLEPANEL ); + + // anv: prebattle interface per vertical resolution + if (isWidescreenUI()) + { + GetMLGFilename(VObjectDesc.ImageFile, MLG_PREBATTLEPANEL_1280x720); + iPrebattleInterfaceHeight = 600; + xOffset = xResOffset + 15; + yOffset = 0; + blanketStartX = 0; + blanketStartY = 0; + } + else if (iResolution >= _640x480 && iResolution < _800x600) + { + GetMLGFilename(VObjectDesc.ImageFile, MLG_PREBATTLEPANEL); + iPrebattleInterfaceHeight = 360; + xOffset = xResOffset; + yOffset = yResOffset; + blanketStartX = yOffset; + blanketStartY = yOffset; + } + else if (iResolution < _1024x768) + { + GetMLGFilename(VObjectDesc.ImageFile, MLG_PREBATTLEPANEL_800x600); + iPrebattleInterfaceHeight = 478; + xOffset = xResOffset; + yOffset = yResOffset; + blanketStartX = yOffset; + blanketStartY = yOffset; + } + else + { + GetMLGFilename(VObjectDesc.ImageFile, MLG_PREBATTLEPANEL_1024x768); + iPrebattleInterfaceHeight = 647; + xOffset = xResOffset; + yOffset = yResOffset; + blanketStartX = yOffset; + blanketStartY = yOffset; + } + ubAllowedListHeight = iPrebattleInterfaceHeight - TOP_Y - BOTTOM_HEIGHT; + if( !AddVideoObject( &VObjectDesc, &uiInterfaceImages ) ) AssertMsg( 0, "Failed to load interface\\PreBattlePanel.sti" ); + //Define the blanket region to cover all of the other regions used underneath the panel. + MSYS_DefineRegion( &PBInterfaceBlanket, blanketStartX, blanketStartY, PREBATTLE_INTERFACE_WIDTH + xOffset, iPrebattleInterfaceHeight + yOffset, MSYS_PRIORITY_HIGHEST, 0, 0, 0 ); + //Create the 3 buttons iPBButtonImage[0] = LoadButtonImage( "INTERFACE\\PreBattleButton.sti", -1, 0, -1, 1, -1 ); if( iPBButtonImage[ 0 ] == -1 ) AssertMsg( 0, "Failed to load interface\\PreBattleButton.sti" ); iPBButtonImage[1] = UseLoadedButtonImage( iPBButtonImage[ 0 ], -1, 0, -1, 1, -1 ); iPBButtonImage[2] = UseLoadedButtonImage( iPBButtonImage[ 0 ], -1, 0, -1, 1, -1 ); - iPBButton[0] = QuickCreateButton( iPBButtonImage[0], 27 + xResOffset, 54 + yResOffset, BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGHEST - 2, DEFAULT_MOVE_CALLBACK, AutoResolveBattleCallback ); - iPBButton[1] = QuickCreateButton( iPBButtonImage[1], 98 + xResOffset, 54 + yResOffset, BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGHEST - 2, DEFAULT_MOVE_CALLBACK, GoToSectorCallback ); - iPBButton[2] = QuickCreateButton( iPBButtonImage[2], 169 + xResOffset, 54 + yResOffset, BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGHEST - 2, DEFAULT_MOVE_CALLBACK, RetreatMercsCallback ); + iPBButton[0] = QuickCreateButton( iPBButtonImage[0], 27 + xOffset, 54 + yOffset, BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, AutoResolveBattleCallback ); + iPBButton[1] = QuickCreateButton( iPBButtonImage[1], 98 + xOffset, 54 + yOffset, BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, GoToSectorCallback ); + iPBButton[2] = QuickCreateButton( iPBButtonImage[2], 169 + xOffset, 54 + yOffset, BUTTON_NO_TOGGLE, MSYS_PRIORITY_HIGHEST, DEFAULT_MOVE_CALLBACK, RetreatMercsCallback ); SpecifyGeneralButtonTextAttributes( iPBButton[0], gpStrategicString[ STR_PB_AUTORESOLVE_BTN ], BLOCKFONT, FONT_BEIGE, 141 ); SpecifyGeneralButtonTextAttributes( iPBButton[1], gpStrategicString[ STR_PB_GOTOSECTOR_BTN ], BLOCKFONT, FONT_BEIGE, 141 ); @@ -1050,7 +1100,7 @@ void DoTransitionFromMapscreenToPreBattleInterface() INT32 iPercentage, iFactor; UINT32 uiTimeRange; INT16 sStartLeft, sEndLeft, sStartTop, sEndTop; - INT32 iLeft, iTop, iWidth, iHeight; + INT32 iLeft, iTop, iWidth; BOOLEAN fEnterAutoResolveMode = FALSE; if( !gfExtraBuffer ) @@ -1058,12 +1108,11 @@ void DoTransitionFromMapscreenToPreBattleInterface() PauseTime( FALSE ); - PBIRect.iLeft = 0 + xResOffset; - PBIRect.iTop = 0 + yResOffset; - PBIRect.iRight = 261 + xResOffset; - PBIRect.iBottom = 359 + yResOffset; - iWidth = 261; - iHeight = 359; + PBIRect.iLeft = 0 + xOffset; + PBIRect.iTop = 0 + yOffset; + PBIRect.iRight = PREBATTLE_INTERFACE_WIDTH + xOffset; + PBIRect.iBottom = iPrebattleInterfaceHeight + yOffset; + iWidth = PREBATTLE_INTERFACE_WIDTH; uiTimeRange = 1000; iPercentage = 0; @@ -1072,8 +1121,8 @@ void DoTransitionFromMapscreenToPreBattleInterface() GetScreenXYFromMapXY( gubPBSectorX, gubPBSectorY, &sStartLeft, &sStartTop ); sStartLeft += UI_MAP.GridSize.iX / 2; sStartTop += UI_MAP.GridSize.iY / 2; - sEndLeft = 131 + xResOffset; - sEndTop = 180 + yResOffset; + sEndLeft = PBIRect.iLeft; + sEndTop = PBIRect.iTop; //save the mapscreen buffer BlitBufferToBuffer( FRAME_BUFFER, guiEXTRABUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); @@ -1095,17 +1144,23 @@ void DoTransitionFromMapscreenToPreBattleInterface() gfEnterAutoResolveMode = TRUE; } - BlitBufferToBuffer( guiSAVEBUFFER, FRAME_BUFFER, 27 + xResOffset, 54 + yResOffset, 209, 32 ); + BlitBufferToBuffer( guiSAVEBUFFER, FRAME_BUFFER, 27 + xOffset, 54 + yOffset, 209, 32 ); RenderButtons(); - BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, 27 + xResOffset, 54 + yResOffset, 209, 32 ); + BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, 27 + xOffset, 54 + yOffset, 209, 32 ); gfRenderPBInterface = TRUE; //hide the prebattle interface - BlitBufferToBuffer( guiEXTRABUFFER, FRAME_BUFFER, 0 + xResOffset, 0 + yResOffset, 261 + xResOffset, 359 + yResOffset ); + BlitBufferToBuffer( guiEXTRABUFFER, FRAME_BUFFER, 0 + xOffset, 0 + yOffset, PREBATTLE_INTERFACE_WIDTH + xOffset, iPrebattleInterfaceHeight + yOffset ); PlayJA2SampleFromFile( "SOUNDS\\Laptop power up (8-11).wav", RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); InvalidateScreen(); RefreshScreen( NULL ); + SGPRect PrevRect; + PrevRect.iLeft = sStartLeft; + PrevRect.iRight = sStartLeft + 1; + PrevRect.iTop = sStartTop; + PrevRect.iBottom = sStartTop + 1; + while( iPercentage < 100 ) { uiCurrTime = GetJA2Clock(); @@ -1117,19 +1172,12 @@ void DoTransitionFromMapscreenToPreBattleInterface() if( iPercentage < 50 ) iPercentage = (UINT32)(iPercentage + iPercentage * iFactor * 0.01 + 0.5); else - iPercentage = (UINT32)(iPercentage + (100-iPercentage) * iFactor * 0.01 + 0.05); + iPercentage = (UINT32)(iPercentage + (100 - iPercentage) * iFactor * 0.01 + 0.05); - //Calculate the center point. - iLeft = sStartLeft - (sStartLeft-sEndLeft+1) * iPercentage / 100; - if( sStartTop > sEndTop ) - iTop = sStartTop - (sStartTop-sEndTop+1) * iPercentage / 100; - else - iTop = sStartTop + (sEndTop-sStartTop+1) * iPercentage / 100; - - DstRect.iLeft = iLeft - iWidth * iPercentage / 200; + DstRect.iLeft = sStartLeft + (sEndLeft - sStartLeft) * iPercentage / 100; DstRect.iRight = DstRect.iLeft + max( iWidth * iPercentage / 100, 1 ); - DstRect.iTop = iTop - iHeight * iPercentage / 200; - DstRect.iBottom = DstRect.iTop + max( iHeight * iPercentage / 100, 1 ); + DstRect.iTop = sStartTop + (sEndTop - sStartTop) * iPercentage / 100; + DstRect.iBottom = DstRect.iTop + max(iPrebattleInterfaceHeight * iPercentage / 100, 1); BltStretchVideoSurface( FRAME_BUFFER, guiSAVEBUFFER, 0, 0, 0, &PBIRect, &DstRect ); @@ -1137,14 +1185,35 @@ void DoTransitionFromMapscreenToPreBattleInterface() RefreshScreen( NULL ); //Restore the previous rect. - BlitBufferToBuffer( guiEXTRABUFFER, FRAME_BUFFER, (UINT16)DstRect.iLeft, (UINT16)DstRect.iTop, - (UINT16)(DstRect.iRight-DstRect.iLeft+1), (UINT16)(DstRect.iBottom-DstRect.iTop+1) ); + BlitBufferToBuffer(guiEXTRABUFFER, FRAME_BUFFER, (UINT16)PrevRect.iLeft, (UINT16)PrevRect.iTop, + (UINT16)PrevRect.iRight, (UINT16)PrevRect.iBottom); + + PrevRect.iLeft = DstRect.iLeft; + PrevRect.iRight = DstRect.iRight; + PrevRect.iTop = DstRect.iTop; + PrevRect.iBottom = DstRect.iBottom; } BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); gfZoomDone = TRUE; } +void ScrollPreBattleInterface( BOOLEAN fUp ) +{ + if ( ubDesiredListHeight <= ubAllowedListHeight ) + return; + + if ( fUp ) + { + bListOffset = max( 0, bListOffset - ubAllowedListHeight ); + } + else + { + bListOffset = min( bListOffset + ubAllowedListHeight, ubDesiredListHeight - ubAllowedListHeight ); + } + gfRenderPBInterface = TRUE; +} + void KillPreBattleInterface() { if( !gfPreBattleInterfaceActive ) @@ -1184,7 +1253,7 @@ void KillPreBattleInterface() //Enable the options button when the auto resolve screen comes up EnableDisAbleMapScreenOptionsButton( TRUE ); - ColorFillVideoSurfaceArea( guiSAVEBUFFER, 0, 0, 261 + xResOffset, 359 + yResOffset, 0 ); + ColorFillVideoSurfaceArea( guiSAVEBUFFER, 0, 0, PREBATTLE_INTERFACE_WIDTH + xOffset, iPrebattleInterfaceHeight + yOffset, 0 ); EnableTeamInfoPanels(); if( ButtonList[ giMapContractButton ] ) @@ -1277,8 +1346,8 @@ void RenderPBHeader( INT32 *piX, INT32 *piWidth) } width = StringPixLength( str, FONT10ARIALBOLD ); x = 130 - width / 2; - mprintf( x + xResOffset, 4 + yResOffset, str ); - InvalidateRegion( 0, 0, 231 + xResOffset, 12 + yResOffset ); + mprintf( x + xOffset, 4 + yOffset, str ); + InvalidateRegion( 0, 0, 231 + xOffset, 12 + yOffset ); *piX = x; *piWidth = width; } @@ -1293,10 +1362,15 @@ void RenderPreBattleInterface() UINT8 ubHPPercent, ubBPPercent; BOOLEAN fMouseInRetreatButtonArea; UINT8 ubJunk; + SGPRect ClipRect; + UINT16 ubDesiredParticipantsListHeight = 0; + UINT16 ubDesiredUninvolvedListHeight = 0; + UINT16 ubUninvolvedStartY = 0; + //PLAYERGROUP *pPlayer; // Make the background black! - //ColorFillVideoSurfaceArea( guiSAVEBUFFER, 0, 0, 261 + xResOffset, SCREEN_HEIGHT - 120, 0 ); + //ColorFillVideoSurfaceArea( guiSAVEBUFFER, 0, 0, 261 + xOffset, SCREEN_HEIGHT - 120, 0 ); //This code determines if the cursor is inside the rectangle consisting of the //retreat button. If it is inside, then we set up the variables so that the retreat @@ -1337,33 +1411,21 @@ void RenderPreBattleInterface() gfRenderPBInterface = FALSE; GetVideoObject( &hVObject, uiInterfaceImages ); //main panel - BltVideoObject( guiSAVEBUFFER, hVObject, MAINPANEL, xResOffset, yResOffset, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( guiSAVEBUFFER, hVObject, MAINPANEL, xOffset, yOffset, VO_BLT_SRCTRANSPARENCY, NULL ); //main title RenderPBHeader( &x, &width ); //now draw the title bars up to the text. for( i = x - 12; i > 20; i -= 10 ) { - BltVideoObject( guiSAVEBUFFER, hVObject, TITLE_BAR_PIECE, i + xResOffset, 6 + yResOffset, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( guiSAVEBUFFER, hVObject, TITLE_BAR_PIECE, i + xOffset, 6 + yOffset, VO_BLT_SRCTRANSPARENCY, NULL ); } for( i = x + width + 2; i < 231; i += 10 ) { - BltVideoObject( guiSAVEBUFFER, hVObject, TITLE_BAR_PIECE, i + xResOffset, 6 + yResOffset, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject( guiSAVEBUFFER, hVObject, TITLE_BAR_PIECE, i + xOffset, 6 + yOffset, VO_BLT_SRCTRANSPARENCY, NULL ); } - BltVideoObject(guiSAVEBUFFER, hVObject, BOTTOM_LINE, 0 + xResOffset, BOTTOM_Y + yResOffset, VO_BLT_SRCTRANSPARENCY, NULL); - BltVideoObject(guiSAVEBUFFER, hVObject, BOTTOM_LINE, 0 + xResOffset, BOTTOM_Y + yResOffset + 10, VO_BLT_SRCTRANSPARENCY, NULL); - BltVideoObject(guiSAVEBUFFER, hVObject, BOTTOM_LINE, 0 + xResOffset, BOTTOM_Y + yResOffset + 20, VO_BLT_SRCTRANSPARENCY, NULL); - BltVideoObject(guiSAVEBUFFER, hVObject, BOTTOM_LINE, 0 + xResOffset, BOTTOM_Y + yResOffset + 30, VO_BLT_SRCTRANSPARENCY, NULL); - //Draw the bottom edges - for (i = 0; i < max(guiNumUninvolved, 1); i++) - { - y = BOTTOM_Y + ROW_HEIGHT * (i + 1) + 30; - BltVideoObject(guiSAVEBUFFER, hVObject, BOTTOM_LINE, 0 + xResOffset, y + yResOffset, VO_BLT_SRCTRANSPARENCY, NULL); - } - BltVideoObject(guiSAVEBUFFER, hVObject, UNINVOLVED_HEADER, 8 + xResOffset, BOTTOM_Y + yResOffset, VO_BLT_SRCTRANSPARENCY, NULL); - BltVideoObject(guiSAVEBUFFER, hVObject, BOTTOM_END, 0 + xResOffset, BOTTOM_Y + yResOffset + 35 + ROW_HEIGHT * max(guiNumUninvolved, 1), VO_BLT_SRCTRANSPARENCY, NULL); - + // header SetFont( BLOCKFONT ); SetFontForeground( FONT_BEIGE ); swprintf( str, gpStrategicString[ STR_PB_LOCATION ] ); @@ -1373,7 +1435,7 @@ void RenderPreBattleInterface() SetFont( BLOCKFONTNARROW ); width = StringPixLength( str, BLOCKFONTNARROW ); } - mprintf( 65 - width + xResOffset , 17 + yResOffset, str ); + mprintf( 65 - width + xOffset , 17 + yOffset, str ); SetFont( BLOCKFONT ); if( GetEnemyEncounterCode() == CREATURE_ATTACK_CODE ) @@ -1405,7 +1467,7 @@ void RenderPreBattleInterface() SetFont( BLOCKFONTNARROW ); width = StringPixLength( str, BLOCKFONTNARROW ); } - mprintf( 54 + xResOffset - width , 38 + yResOffset, str ); + mprintf( 54 + xOffset - width , 38 + yOffset, str ); SetFont( BLOCKFONT ); swprintf( str, gpStrategicString[ STR_PB_MERCS ] ); @@ -1415,7 +1477,7 @@ void RenderPreBattleInterface() SetFont( BLOCKFONTNARROW ); width = StringPixLength( str, BLOCKFONTNARROW ); } - mprintf( 139 + xResOffset - width , 38 + yResOffset, str ); + mprintf( 139 + xOffset - width , 38 + yOffset, str ); SetFont( BLOCKFONT ); swprintf( str, gpStrategicString[ STR_PB_MILITIA ] ); @@ -1425,29 +1487,53 @@ void RenderPreBattleInterface() SetFont( BLOCKFONTNARROW ); width = StringPixLength( str, BLOCKFONTNARROW ); } - mprintf( 224 + xResOffset - width , 38 + yResOffset, str ); + mprintf( 224 + xOffset - width , 38 + yOffset, str ); - //Draw the bottom columns - for( i = 0; i < (INT32)max( guiNumUninvolved, 1 ); i++ ) + ubDesiredParticipantsListHeight = guiNumInvolved * ROW_HEIGHT; + ubDesiredUninvolvedListHeight = UNINVOLVED_RELEVANT_HEIGHT + max(guiNumUninvolved, 1) * ROW_HEIGHT; + + ubDesiredListHeight = ubDesiredParticipantsListHeight + ubDesiredUninvolvedListHeight; + + if (ubDesiredListHeight >= ubAllowedListHeight) { - y = BOTTOM_Y + ROW_HEIGHT * (i+1) + 1 + ACTUAL_HEIGHT; - BltVideoObject( guiSAVEBUFFER, hVObject, BOTTOM_COLUMN, 161 + xResOffset, y + yResOffset, VO_BLT_SRCTRANSPARENCY, NULL ); + ubUninvolvedStartY = ubDesiredParticipantsListHeight; + } + else + { + ubUninvolvedStartY = ubAllowedListHeight - ubDesiredUninvolvedListHeight; } - // WDS - make number of mercenaries, etc. be configurable - for( i = 0; i < (INT32)(25/*3+ OUR_TEAM_SIZE_NO_VEHICLE - max( guiNumUninvolved, 1 )*/); i++ ) + ClipRect.iLeft = xOffset; + ClipRect.iTop = yOffset + TOP_Y; + ClipRect.iRight = xOffset + PREBATTLE_INTERFACE_WIDTH; + ClipRect.iBottom = yOffset + TOP_Y + ubAllowedListHeight;// + TOP_Y_BUFFER; + SetClippingRect(&ClipRect); + + // Draw the top columns + // Draw from the top to uninvolved header + for ( y = TOP_Y - bListOffset; y < TOP_Y - bListOffset + ubUninvolvedStartY; y += ROW_HEIGHT ) { - y = TOP_Y + ROW_HEIGHT * i; - BltVideoObject( guiSAVEBUFFER, hVObject, TOP_COLUMN, 186 + xResOffset, y + yResOffset, VO_BLT_SRCTRANSPARENCY, NULL ); + BltVideoObject(guiSAVEBUFFER, hVObject, TOP_COLUMN, 186 + xOffset, y + yOffset, VO_BLT_CLIP | VO_BLT_SRCTRANSPARENCY, NULL); } + // Draw extra empty participants rows to close off bottom of the content area + for ( y = TOP_Y - bListOffset + ubUninvolvedStartY + ROW_HEIGHT; y < TOP_Y - bListOffset + ubUninvolvedStartY + ubDesiredUninvolvedListHeight; y += ROW_HEIGHT ) + { + BltVideoObject(guiSAVEBUFFER, hVObject, BOTTOM_COLUMN, 161 + xOffset, y + yOffset, VO_BLT_CLIP | VO_BLT_SRCTRANSPARENCY, NULL); + } + + // Draw uninvolved header + BltVideoObject( guiSAVEBUFFER, hVObject, UNINVOLVED_HEADER, 8 + xOffset, yOffset + TOP_Y + ubUninvolvedStartY - UNINVOLVED_OFFSET_HEIGHT - bListOffset, VO_BLT_CLIP | VO_BLT_SRCTRANSPARENCY, NULL ); + + RestoreClipRegionToFullScreen(); + //location SetFont( FONT10ARIAL ); SetFontForeground( FONT_YELLOW ); SetFontShadow( FONT_NEARBLACK ); GetSectorIDString( gubPBSectorX, gubPBSectorY, gubPBSectorZ, pSectorName, TRUE ); - mprintf( 70 + xResOffset, 17 + yResOffset, L"%s %s", gpStrategicString[ STR_PB_SECTOR ], pSectorName ); + mprintf( 70 + xOffset, 17 + yOffset, L"%s %s", gpStrategicString[STR_PB_SECTOR], pSectorName ); //enemy SetFont( FONT14ARIAL ); @@ -1472,58 +1558,55 @@ void RenderPreBattleInterface() } x = 57 + (27 - StringPixLength( str, FONT14ARIAL )) / 2; y = 36; - mprintf( x + xResOffset, y + yResOffset, str ); + mprintf( x + xOffset, y + yOffset, str ); //player swprintf( str, L"%d", guiNumInvolved ); x = 142 + (27 - StringPixLength( str, FONT14ARIAL )) / 2; - mprintf( x + xResOffset, y + yResOffset, str ); + mprintf( x + xOffset, y + yOffset, str ); //militia swprintf( str, L"%d", NumNonPlayerTeamMembersInSector( gubPBSectorX, gubPBSectorY, MILITIA_TEAM ) ); x = 227 + (27 - StringPixLength( str, FONT14ARIAL )) / 2; - mprintf( x + xResOffset, y + yResOffset, str ); + mprintf( x + xOffset, y + yOffset, str ); SetFontShadow( FONT_NEARBLACK ); SetFont( BLOCKFONT2 ); SetFontForeground( FONT_YELLOW ); + SetFontDestBuffer( guiSAVEBUFFER, xOffset, yOffset + TOP_Y, + xOffset + PREBATTLE_INTERFACE_WIDTH, yOffset + TOP_Y + ubAllowedListHeight, FALSE ); + //print out the participants of the battle. // | NAME | ASSIGN | COND | HP | BP | line = 0; - y = TOP_Y + 1; - for( i = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; i <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; i++ ) + y = TOP_Y + TOP_Y_TEXT_BUFFER - bListOffset; + for( i = gTacticalStatus.Team[OUR_TEAM].bFirstID; i <= gTacticalStatus.Team[OUR_TEAM].bLastID; i++) { - if( MercPtrs[ i ]->bActive && MercPtrs[ i ]->stats.bLife && !(MercPtrs[ i ]->flags.uiStatusFlags & SOLDIER_VEHICLE) ) + if( MercPtrs[i]->bActive && MercPtrs[i]->stats.bLife && !(MercPtrs[i]->flags.uiStatusFlags & SOLDIER_VEHICLE) ) { - if ( PlayerMercInvolvedInThisCombat( MercPtrs[ i ] ) ) - { //involved - if( line == giHilitedInvolved ) - SetFontForeground( FONT_WHITE ); - else - SetFontForeground( FONT_YELLOW ); + if( PlayerMercInvolvedInThisCombat( MercPtrs[ i ] ) ) + { //NAME wcscpy( str, MercPtrs[ i ]->name ); - x = 17 + (52-StringPixLength( str, BLOCKFONT2)) / 2; - mprintf( x + xResOffset , y + yResOffset, str ); + x = 17 + (52 - StringPixLength(str, BLOCKFONT2)) / 2; + mprintf( x + xOffset, y + yOffset, str ); //ASSIGN GetMapscreenMercAssignmentString( MercPtrs[ i ], str ); - x = 72 + (54-StringPixLength( str, BLOCKFONT2)) / 2; - mprintf( x + xResOffset, y + yResOffset, str ); + x = 72 + (54 - StringPixLength(str, BLOCKFONT2)) / 2; + mprintf( x + xOffset, y + yOffset, str ); //COND GetSoldierConditionInfo( MercPtrs[ i ], str, &ubHPPercent, &ubBPPercent ); - x = 129 + (58-StringPixLength( str, BLOCKFONT2)) / 2; - mprintf( x + xResOffset, y + yResOffset, str ); + x = 129 + (58 - StringPixLength(str, BLOCKFONT2)) / 2; + mprintf( x + xOffset, y + yOffset, str ); //HP swprintf( str, L"%d%%", ubHPPercent ); - x = 189 + (25-StringPixLength( str, BLOCKFONT2)) / 2; + x = 189 + (25 - StringPixLength(str, BLOCKFONT2)) / 2; wcscat( str, sSpecialCharacters[0] ); - mprintf( x + xResOffset, y + yResOffset, str ); + mprintf( x + xOffset, y + yOffset, str ); //BP swprintf( str, L"%d%%", ubBPPercent ); x = 217 + (25-StringPixLength( str, BLOCKFONT2)) / 2; wcscat( str, sSpecialCharacters[0] ); - mprintf( x + xResOffset, y + yResOffset, str ); - - line++; + mprintf( x + xOffset, y + yOffset, str ); y += ROW_HEIGHT; } } @@ -1533,51 +1616,44 @@ void RenderPreBattleInterface() // | NAME | ASSIGN | LOC | DEST | DEP | if( !guiNumUninvolved ) { - SetFontForeground( FONT_YELLOW ); wcscpy( str, gpStrategicString[ STR_PB_NONE ] ); - x = 17 + (52-StringPixLength( str, BLOCKFONT2)) / 2; - y = BOTTOM_Y + ROW_HEIGHT + 2 + ACTUAL_HEIGHT; - mprintf( x + xResOffset, y + yResOffset, str ); + x = 17 + (52 - StringPixLength( str, BLOCKFONT2)) / 2; + mprintf( x + xOffset, yOffset + TOP_Y + TOP_Y_TEXT_BUFFER + ubUninvolvedStartY + UNINVOLVED_RELEVANT_HEIGHT - bListOffset, str ); } else { pGroup = gpGroupList; - y = BOTTOM_Y + ROW_HEIGHT + 2 + ACTUAL_HEIGHT; - for( i = gTacticalStatus.Team[ OUR_TEAM ].bFirstID; i <= gTacticalStatus.Team[ OUR_TEAM ].bLastID; i++ ) + y = TOP_Y + TOP_Y_TEXT_BUFFER + ubUninvolvedStartY + UNINVOLVED_RELEVANT_HEIGHT - bListOffset; + for( i = gTacticalStatus.Team[OUR_TEAM].bFirstID; i <= gTacticalStatus.Team[OUR_TEAM].bLastID; i++ ) { if( MercPtrs[ i ]->bActive && MercPtrs[ i ]->stats.bLife && !(MercPtrs[ i ]->flags.uiStatusFlags & SOLDIER_VEHICLE) ) { - if ( !PlayerMercInvolvedInThisCombat( MercPtrs[ i ] ) ) + if( !PlayerMercInvolvedInThisCombat(MercPtrs[ i ]) ) { - // uninvolved - if( line == giHilitedUninvolved ) - SetFontForeground( FONT_WHITE ); - else - SetFontForeground( FONT_YELLOW ); //NAME wcscpy( str, MercPtrs[ i ]->name ); - x = 17 + (52-StringPixLength( str, BLOCKFONT2)) / 2; - mprintf( x + xResOffset, y + yResOffset, str ); + x = 17 + (52 - StringPixLength(str, BLOCKFONT2)) / 2; + mprintf( x + xOffset, y + yOffset, str ); //ASSIGN GetMapscreenMercAssignmentString( MercPtrs[ i ], str ); - x = 72 + (54-StringPixLength( str, BLOCKFONT2)) / 2; - mprintf( x + xResOffset, y + yResOffset, str ); + x = 72 + (54 - StringPixLength(str, BLOCKFONT2)) / 2; + mprintf( x + xOffset, y + yOffset, str ); //LOC GetMapscreenMercLocationString( MercPtrs[ i ], str ); - x = 128 + (33-StringPixLength( str, BLOCKFONT2)) / 2; - mprintf( x + xResOffset, y + yResOffset, str ); + x = 128 + (33 - StringPixLength(str, BLOCKFONT2)) / 2; + mprintf( x + xOffset, y + yOffset, str ); //DEST GetMapscreenMercDestinationString( MercPtrs[ i ], str ); - if( wcslen( str ) > 0 ) + if (wcslen(str) > 0) { - x = 164 + (41-StringPixLength( str, BLOCKFONT2)) / 2; - mprintf( x + xResOffset, y + yResOffset, str ); + x = 164 + (41 - StringPixLength(str, BLOCKFONT2)) / 2; + mprintf( x + xOffset, y + yOffset, str ); } //DEP GetMapscreenMercDepartureString( MercPtrs[ i ], str, &ubJunk ); - x = 208 + (34-StringPixLength( str, BLOCKFONT2)) / 2; - mprintf( x + xResOffset, y + yResOffset, str ); - line++; + x = 208 + (34 - StringPixLength(str, BLOCKFONT2)) / 2; + mprintf(x + xOffset, y + yOffset, str); + y += ROW_HEIGHT; } } @@ -1587,12 +1663,7 @@ void RenderPreBattleInterface() // mark any and ALL pop up boxes as altered MarkAllBoxesAsAltered( ); - if(!gfZoomDone) - RestoreExternBackgroundRect( 0 + xResOffset, 0 + yResOffset, 261 + xResOffset, 359 + yResOffset ); - else if(!guiNumUninvolved) - RestoreExternBackgroundRect( 0 + xResOffset, 0 + yResOffset, 261 + xResOffset, 389 + yResOffset ); - else - RestoreExternBackgroundRect( 0 + xResOffset, 0 + yResOffset, 261 + xResOffset, y + yResOffset ); + RestoreExternBackgroundRect( 0 + xOffset, 0 + yOffset, PREBATTLE_INTERFACE_WIDTH, iPrebattleInterfaceHeight ); // restore font destinanation buffer to the frame buffer SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE ); @@ -1602,7 +1673,7 @@ void RenderPreBattleInterface() RenderPBHeader( &x, &width ); //the text is important enough to blink. } - //InvalidateRegion( 0, 0, 261, 359 ); + InvalidateRegion( 0, 0, PREBATTLE_INTERFACE_WIDTH, iPrebattleInterfaceHeight ); if( gfEnterAutoResolveMode ) { gfEnterAutoResolveMode = FALSE; @@ -1611,7 +1682,6 @@ void RenderPreBattleInterface() } gfIgnoreAllInput = FALSE; - } void AutoResolveBattleCallback( GUI_BUTTON *btn, INT32 reason ) diff --git a/Strategic/PreBattle Interface.h b/Strategic/PreBattle Interface.h index 78070486..f0406674 100644 --- a/Strategic/PreBattle Interface.h +++ b/Strategic/PreBattle Interface.h @@ -7,6 +7,7 @@ void InitPreBattleInterface( GROUP *pBattleGroup, BOOLEAN fPersistantPBI ); void KillPreBattleInterface(); void RenderPreBattleInterface(); +void ScrollPreBattleInterface( BOOLEAN fUp ); extern BOOLEAN gfPreBattleInterfaceActive; extern BOOLEAN gfDisplayPotentialRetreatPaths; diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 4d387161..655d6b50 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -5708,7 +5708,7 @@ UINT32 MapScreenHandle(void) HandleCharBarRender( ); } - if( (fShowInventoryFlag && !isWidescreenUI()) || fDisableDueToBattleRoster ) + if( ( fShowInventoryFlag || fDisableDueToBattleRoster ) && !isWidescreenUI() ) { for( iCounter = 0; iCounter < MAX_SORT_METHODS; iCounter++ ) { @@ -5824,9 +5824,6 @@ UINT32 MapScreenHandle(void) HandleContractRenewalSequence( ); - // handle dialog - HandleDialogue( ); - // handle display of inventory pop up // HEADROCK HAM 3.5: Externalize! HandleDisplayOfItemPopUpForSector( gGameExternalOptions.ubDefaultArrivalSectorX, gGameExternalOptions.ubDefaultArrivalSectorY, startingZ ); @@ -6065,6 +6062,8 @@ UINT32 MapScreenHandle(void) //InvalidateRegion( 0,0, 640, 480); EndFrameBufferRender( ); + // handle dialog + HandleDialogue(); // if not going anywhere else if ( guiPendingScreen == NO_PENDING_SCREEN ) @@ -7225,14 +7224,29 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent ) break; case PGUP: - // WANNE: Jump to first merc in list - fResetMapCoords = TRUE; - GoToFirstCharacterInList( ); + if (gfPreBattleInterfaceActive) + { + ScrollPreBattleInterface(TRUE); + } + else + { + // WANNE: Jump to first merc in list + fResetMapCoords = TRUE; + GoToFirstCharacterInList(); + } + break; case PGDN: - // WANNE: Jump to last merc in list - fResetMapCoords = TRUE; - GoToLastCharacterInList( ); + if (gfPreBattleInterfaceActive) + { + ScrollPreBattleInterface(FALSE); + } + else + { + // WANNE: Jump to last merc in list + fResetMapCoords = TRUE; + GoToLastCharacterInList(); + } break; case SHIFT_PGUP: @@ -10927,6 +10941,10 @@ void BlitBackgroundToSaveBuffer( void ) ForceButtonUnDirty( giMapContractButton ); ForceButtonUnDirty( giCharInfoButton[ 0 ] ); ForceButtonUnDirty( giCharInfoButton[ 1 ] ); + if (isWidescreenUI()) + { + ForceButtonUnDirty(giMapInvDoneButton); + } RenderPreBattleInterface(); } diff --git a/Utils/Multi Language Graphic Utils.cpp b/Utils/Multi Language Graphic Utils.cpp index 0371e72e..102c7d3f 100644 --- a/Utils/Multi Language Graphic Utils.cpp +++ b/Utils/Multi Language Graphic Utils.cpp @@ -76,6 +76,15 @@ BOOLEAN GetMLGFilename( SGPFILENAME filename, UINT16 usMLGGraphicID ) case MLG_PREBATTLEPANEL: sprintf( filename, "INTERFACE\\PreBattlePanel.sti" ); return TRUE; + case MLG_PREBATTLEPANEL_800x600: + sprintf(filename, "INTERFACE\\PreBattlePanel_800x600.sti"); + return TRUE; + case MLG_PREBATTLEPANEL_1024x768: + sprintf(filename, "INTERFACE\\PreBattlePanel_1024x768.sti"); + return TRUE; + case MLG_PREBATTLEPANEL_1280x720: + sprintf(filename, "INTERFACE\\PreBattlePanel_1280x720.sti"); + return TRUE; case MLG_SMALLTITLE: sprintf( filename, "LAPTOP\\SmallTitle.sti" ); return TRUE; @@ -203,6 +212,15 @@ BOOLEAN GetMLGFilename( SGPFILENAME filename, UINT16 usMLGGraphicID ) case MLG_PREBATTLEPANEL: sprintf( filename, "GERMAN\\PreBattlePanel_german.sti" ); return TRUE; + case MLG_PREBATTLEPANEL_800x600: + sprintf(filename, "GERMAN\\PreBattlePanel_800x600_german.sti"); + return TRUE; + case MLG_PREBATTLEPANEL_1024x768: + sprintf(filename, "GERMAN\\PreBattlePanel_1024x768_german.sti"); + return TRUE; + case MLG_PREBATTLEPANEL_1280x720: + sprintf(filename, "GERMAN\\PreBattlePanel_1280x720_german.sti"); + return TRUE; case MLG_SMALLTITLE: sprintf( filename, "GERMAN\\SmallTitle_german.sti" ); return TRUE; @@ -368,6 +386,15 @@ BOOLEAN GetMLGFilename( SGPFILENAME filename, UINT16 usMLGGraphicID ) case MLG_PREBATTLEPANEL: sprintf( filename, "%s\\PreBattlePanel_%s.sti", zLanguage, zLanguage ); break; + case MLG_PREBATTLEPANEL_800x600: + sprintf(filename, "%s\\PreBattlePanel_800x600_%s.sti", zLanguage, zLanguage); + break; + case MLG_PREBATTLEPANEL_1024x768: + sprintf(filename, "%s\\PreBattlePanel_1024x768_%s.sti", zLanguage, zLanguage); + break; + case MLG_PREBATTLEPANEL_1280x720: + sprintf(filename, "%s\\PreBattlePanel_1280x720_%s.sti", zLanguage, zLanguage); + break; case MLG_SMALLTITLE: sprintf( filename, "%s\\SmallTitle_%s.sti", zLanguage, zLanguage ); break; @@ -492,6 +519,15 @@ BOOLEAN GetMLGFilename( SGPFILENAME filename, UINT16 usMLGGraphicID ) case MLG_PREBATTLEPANEL: sprintf( filename, "INTERFACE\\PreBattlePanel.sti" ); return TRUE; + case MLG_PREBATTLEPANEL_800x600: + sprintf(filename, "INTERFACE\\PreBattlePanel_800x600.sti"); + return TRUE; + case MLG_PREBATTLEPANEL_1024x768: + sprintf(filename, "INTERFACE\\PreBattlePanel_1024x768.sti"); + return TRUE; + case MLG_PREBATTLEPANEL_1280x720: + sprintf(filename, "INTERFACE\\PreBattlePanel_1280x720.sti"); + return TRUE; case MLG_SMALLTITLE: sprintf( filename, "LAPTOP\\SmallTitle.sti" ); return TRUE; diff --git a/Utils/Multi Language Graphic Utils.h b/Utils/Multi Language Graphic Utils.h index 12f74fd5..dcedbcc1 100644 --- a/Utils/Multi Language Graphic Utils.h +++ b/Utils/Multi Language Graphic Utils.h @@ -26,6 +26,9 @@ enum MLG_OPTIONHEADER, //OptionScreenAddOns MLG_ORDERGRID, MLG_PREBATTLEPANEL, + MLG_PREBATTLEPANEL_800x600, + MLG_PREBATTLEPANEL_1024x768, + MLG_PREBATTLEPANEL_1280x720, MLG_SECTORINVENTORY, MLG_SMALLFLORISTSYMBOL, //SmallSymbol MLG_SMALLTITLE, From 1e1d456fd27c9fe70e51f4e2da76347b138a64a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Fa=C5=82kowski?= Date: Mon, 21 Aug 2023 18:44:02 +0200 Subject: [PATCH 014/120] Prevent deadlocks due to self-healing interactive spots and self-attacking (#205) --- Tactical/Handle Items.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index 9c9b47fc..a865d703 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -279,7 +279,8 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bLevel, UINT16 usHa { pTargetSoldier = MercPtrs[ usSoldierIndex ]; - if ( fFromUI ) + // anv: don't try to heal interactive spots + if (fFromUI && Item[usHandItem].usItemClass != IC_MEDKIT) { INT32 sInteractiveGridNo; @@ -325,6 +326,13 @@ INT32 HandleItem( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bLevel, UINT16 usHa { if (pTargetSoldier->bTeam == gbPlayerNum || pTargetSoldier->aiData.bNeutral) { + // anv: don't try to attack yourself, it will only cause deadlock + if (pSoldier == pTargetSoldier) + { + TacticalCharacterDialogue(pSoldier, QUOTE_REFUSING_ORDER); + return(ITEM_HANDLE_REFUSAL); + } + // nice mercs won't shoot other nice guys or neutral civilians if ((gMercProfiles[pSoldier->ubProfile].ubMiscFlags3 & PROFILE_MISC_FLAG3_GOODGUY) && ((pTargetSoldier->ubProfile == NO_PROFILE && pTargetSoldier->aiData.bNeutral && pTargetSoldier->ubBodyType != CROW) || From 1289c399ce8bffcaac099dd50c169339dabddef4 Mon Sep 17 00:00:00 2001 From: kitty624 <58940527+kitty624@users.noreply.github.com> Date: Tue, 22 Aug 2023 00:22:20 +0200 Subject: [PATCH 015/120] Update XML.h - added path to sub-directory for Extra Items - to avoid cluttering up the parent directory when using this feature - it allows to place extra items in sector via xml and based on difficulty level - the new directory "ExtraItems" will contain more details on how-to-use --- Tactical/XML.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tactical/XML.h b/Tactical/XML.h index 3505f1bb..03a95811 100644 --- a/Tactical/XML.h +++ b/Tactical/XML.h @@ -157,8 +157,8 @@ typedef PARSE_STAGE; #define ALTSECTORSFILENAME "Map\\AltSectors.xml" #define SAMSITESFILENAME "Map\\SamSites.xml" #define HELISITESFILENAME "Map\\HeliSites.xml" -#define EXTRAITEMSFILENAME "Map\\A9_0_ExtraItems" // ".xml" will be added @runtime -#define EXTRAITEMSFILENAME2 "Map\\A11_0_ExtraItems" // ".xml" will be added @runtime +#define EXTRAITEMSFILENAME "Map\\ExtraItems\\A9_0_ExtraItems" // ".xml" will be added @runtime +#define EXTRAITEMSFILENAME2 "Map\\ExtraItems\\A11_0_ExtraItems" // ".xml" will be added @runtime #define SHIPPINGDESTINATIONSFILENAME "Map\\ShippingDestinations.xml" #define DELIVERYMETHODSFILENAME "Map\\DeliveryMethods.xml" #define DELIVERYMETHODSFILENAME "Map\\DeliveryMethods.xml" From 6bae48658e66dc7bc732874f9c4cf163c38ba2ff Mon Sep 17 00:00:00 2001 From: rftrdev <102184004+rftrdev@users.noreply.github.com> Date: Wed, 23 Aug 2023 00:34:54 -0700 Subject: [PATCH 016/120] Fix personality check for backgrounds during IMP creation (#208) --- Laptop/IMP Background.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Laptop/IMP Background.cpp b/Laptop/IMP Background.cpp index 9ea5c40e..b7cddab4 100644 --- a/Laptop/IMP Background.cpp +++ b/Laptop/IMP Background.cpp @@ -15,6 +15,7 @@ #include "CharProfile.h" #include "soldier profile type.h" #include "IMP Compile Character.h" + #include "IMP Disability Trait.h" #include "GameSettings.h" #include "Interface.h" @@ -671,7 +672,7 @@ BOOLEAN IsBackGroundAllowed( UINT16 ubNumber ) return FALSE; } - switch ( iPersonality ) + switch ( iChosenDisabilityTrait() ) { case HEAT_INTOLERANT: if ( zBackground[ ubNumber ].value[BG_DESERT] > 0 ) @@ -807,4 +808,4 @@ void BtnIMPBackgroundPreviousCallback(GUI_BUTTON *btn,INT32 reason) usBackground = 0; } } -} \ No newline at end of file +} From 8ec02b2d40b0c81eb1e3a6a58188b384b0c8dae4 Mon Sep 17 00:00:00 2001 From: rftrdev <102184004+rftrdev@users.noreply.github.com> Date: Wed, 23 Aug 2023 01:21:22 -0700 Subject: [PATCH 017/120] Add version info to main menu (#209) --- MainMenuScreen.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MainMenuScreen.cpp b/MainMenuScreen.cpp index 1db5e174..bebe6193 100644 --- a/MainMenuScreen.cpp +++ b/MainMenuScreen.cpp @@ -855,6 +855,9 @@ void RenderMainMenu() DrawTextToScreen( L"BLOCKFONTNARROW: "/*gzCopyrightText[ 0 ]*/, 0, 445, 640, BLOCKFONTNARROW, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED ); DrawTextToScreen( L"FONT14HUMANIST: "/*gzCopyrightText[ 0 ]*/, 0, 465, 640, FONT14HUMANIST, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED ); #else + CHAR16 text[128]; + swprintf(text, L"%s: %s %S %s", pMessageStrings[ MSG_VERSION ], zProductLabel, czVersionString, zBuildInformation ); + DrawTextToScreen( text, 10, 10, SCREEN_WIDTH, TINYFONT1, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, LEFT_JUSTIFIED ); DrawTextToScreen( gzCopyrightText[ 0 ], 0, SCREEN_HEIGHT - 20, SCREEN_WIDTH, FONT10ARIAL, FONT_MCOLOR_WHITE, FONT_MCOLOR_BLACK, FALSE, CENTER_JUSTIFIED ); #endif From 3ddacf1a44fd5e378fbca8dac8845f2dfa4f1f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Fa=C5=82kowski?= Date: Mon, 28 Aug 2023 15:26:02 +0200 Subject: [PATCH 018/120] Fix vehicles consuming fuel after instant movement cancel (#213) --- Strategic/Strategic Movement.cpp | 44 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Strategic/Strategic Movement.cpp b/Strategic/Strategic Movement.cpp index 68eb7123..cbabfed6 100644 --- a/Strategic/Strategic Movement.cpp +++ b/Strategic/Strategic Movement.cpp @@ -1951,33 +1951,33 @@ void GroupArrivedAtSector( UINT8 ubGroupID, BOOLEAN fCheckForBattle, BOOLEAN fNe SectorInfo[SECTOR( pGroup->ubSectorX, pGroup->ubSectorY )].bLastKnownEnemies = NumNonPlayerTeamMembersInSector( pGroup->ubSectorX, pGroup->ubSectorY, ENEMY_TEAM ); } - // award life 'experience' for travelling, based on travel time! - if ( !pGroup->fVehicle ) + // Flugente: do not award experience gain if we never left + if (!fNeverLeft) { - // Flugente: do not award experience gain if we never left - if ( !fNeverLeft ) + // award life 'experience' for travelling, based on travel time! + if (!pGroup->fVehicle) { // gotta be walking to get tougher - AwardExperienceForTravelling( pGroup ); + AwardExperienceForTravelling(pGroup); } - } - else if( !IsGroupTheHelicopterGroup( pGroup ) ) - { - SOLDIERTYPE *pSoldier; - INT32 iVehicleID; - iVehicleID = GivenMvtGroupIdFindVehicleId( pGroup->ubGroupID ); - AssertMsg( iVehicleID != -1, "GroupArrival for vehicle group. Invalid iVehicleID. " ); - - pSoldier = GetSoldierStructureForVehicle( iVehicleID ); - AssertMsg( pSoldier, "GroupArrival for vehicle group. Invalid soldier pointer." ); - - SpendVehicleFuel( pSoldier, (INT16)(pGroup->uiTraverseTime*6) ); - - if( !VehicleFuelRemaining( pSoldier ) ) + else if (!IsGroupTheHelicopterGroup(pGroup)) { - ReportVehicleOutOfGas( iVehicleID, pGroup->ubSectorX, pGroup->ubSectorY ); - //Nuke the group's path, so they don't continue moving. - ClearMercPathsAndWaypointsForAllInGroup( pGroup ); + SOLDIERTYPE* pSoldier; + INT32 iVehicleID; + iVehicleID = GivenMvtGroupIdFindVehicleId(pGroup->ubGroupID); + AssertMsg(iVehicleID != -1, "GroupArrival for vehicle group. Invalid iVehicleID. "); + + pSoldier = GetSoldierStructureForVehicle(iVehicleID); + AssertMsg(pSoldier, "GroupArrival for vehicle group. Invalid soldier pointer."); + + SpendVehicleFuel(pSoldier, (INT16)(pGroup->uiTraverseTime * 6)); + + if (!VehicleFuelRemaining(pSoldier)) + { + ReportVehicleOutOfGas(iVehicleID, pGroup->ubSectorX, pGroup->ubSectorY); + //Nuke the group's path, so they don't continue moving. + ClearMercPathsAndWaypointsForAllInGroup(pGroup); + } } } } From d56288e313729b2c6eecde92eb65e04ea01bec1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Fa=C5=82kowski?= Date: Mon, 28 Aug 2023 15:26:34 +0200 Subject: [PATCH 019/120] Fixed incorrect vehicle group id after reloading the game and vehicle movement plot issues. (#207) --- Strategic/Map Screen Interface.cpp | 42 ++++++++++++++++++++++++------ Tactical/Squads.cpp | 15 ++++++++++- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/Strategic/Map Screen Interface.cpp b/Strategic/Map Screen Interface.cpp index 37eb3087..678c4fd7 100644 --- a/Strategic/Map Screen Interface.cpp +++ b/Strategic/Map Screen Interface.cpp @@ -4582,6 +4582,28 @@ void HandleSettingTheSelectedListOfMercs( void ) INT8 pbErrorNumber = -1; pSoldier = MercPtrs[gCharactersList[GetSelectedDestChar()].usSolID]; INT8 bSquadValue = pSoldier->bAssignment; + if (bSquadValue == VEHICLE) + { + for (INT8 bCounter = 0; bCounter < NUMBER_OF_SQUADS; ++bCounter) + { + if (Squad[bCounter][0] != NULL && IsVehicle(Squad[bCounter][0]) && + Squad[bCounter][0]->bVehicleID == pSoldier->iVehicleId) + { + bSquadValue = bCounter; + break; + } + } + } + if (bSquadValue >= NUMBER_OF_SQUADS) + { + if (pbErrorNumber != -1) + { + ReportMapScreenMovementError(pbErrorNumber); + } + SetSelectedDestChar(-1); + giDestHighLine = -1; + return; + } // find number of characters in particular squad. for (INT8 bCounter = 0; bCounter < NUMBER_OF_SOLDIERS_PER_SQUAD; ++bCounter) @@ -4693,17 +4715,21 @@ INT8 FindSquadThatSoldierCanJoin( SOLDIERTYPE *pSoldier ) // run through the list of squads for( bCounter = 0; bCounter < NUMBER_OF_SQUADS; bCounter++ ) { - // is this squad in this sector - if( IsThisSquadInThisSector( pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ, bCounter ) ) + // anv: don't automatically put people in vehicle squads + if (Squad[bCounter][0] == NULL || !IsVehicle(Squad[bCounter][0])) { - // does it have room? - if( IsThisSquadFull( bCounter ) == FALSE ) + // is this squad in this sector + if (IsThisSquadInThisSector(pSoldier->sSectorX, pSoldier->sSectorY, pSoldier->bSectorZ, bCounter)) { - // is it doing the same thing as the soldier is (staying or going) ? - if( IsSquadSelectedForMovement( bCounter ) == IsSoldierSelectedForMovement( pSoldier ) ) + // does it have room? + if (IsThisSquadFull(bCounter) == FALSE) { - // go ourselves a match, then - return( bCounter ); + // is it doing the same thing as the soldier is (staying or going) ? + if (IsSquadSelectedForMovement(bCounter) == IsSoldierSelectedForMovement(pSoldier)) + { + // go ourselves a match, then + return(bCounter); + } } } } diff --git a/Tactical/Squads.cpp b/Tactical/Squads.cpp index 7fb7c6b3..a7dda1b1 100644 --- a/Tactical/Squads.cpp +++ b/Tactical/Squads.cpp @@ -1700,7 +1700,20 @@ void CheckSquadMovementGroups( void ) for (INT8 iSoldier = 0; iSoldier < NUMBER_OF_SOLDIERS_PER_SQUAD; iSoldier++) { if (Squad[iSquad][iSoldier] != NULL) { - Squad[iSquad][iSoldier]->ubGroupID = pGroup->ubGroupID; + if (IsVehicle(Squad[iSquad][iSoldier])) + { + INT32 iCounter = 0; + for (iCounter = 0; iCounter < ubNumberOfVehicles; iCounter++) + { + if (pVehicleList[iCounter].ubProfileID == Squad[iSquad][iSoldier]->ubProfile) + break; + } + Squad[iSquad][iSoldier]->ubGroupID = pVehicleList[iCounter].ubMovementGroup; + } + else + { + Squad[iSquad][iSoldier]->ubGroupID = pGroup->ubGroupID; + } } } } From 7edecd68495723af86bf62fd6b1c18a592d96615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Fa=C5=82kowski?= Date: Mon, 28 Aug 2023 15:26:46 +0200 Subject: [PATCH 020/120] Fixed vehicle body not properly removed when destroyed during ramming (#210) --- Tactical/Soldier Control.cpp | 20 ++++++++++++++++++++ Tactical/Soldier Control.h | 8 ++++++++ TileEngine/structure.cpp | 4 ++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 9a594ee2..271368d0 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -10700,6 +10700,22 @@ UINT8 SOLDIERTYPE::SoldierTakeDamage( INT8 bHeight, INT16 sLifeDeduct, INT16 sBr return(ubCombinedLoss); } +void SOLDIERTYPE::SoldierTakeDelayedDamage(INT8 bHeight, INT16 sLifeDeduct, INT16 sBreathLoss, UINT8 ubReason, UINT8 ubAttacker, INT32 sSourceGrid, INT16 sSubsequent, BOOLEAN fShowDamage) +{ + delayedDamageFunction = [this, bHeight, sLifeDeduct, sBreathLoss, ubReason, ubAttacker, sSourceGrid, sSubsequent, fShowDamage]() + { + this->SoldierTakeDamage(bHeight, sLifeDeduct, sBreathLoss, ubReason, ubAttacker, sSourceGrid, sSubsequent, fShowDamage); + }; +} + +void SOLDIERTYPE::ResolveDelayedDamage() +{ + if (delayedDamageFunction) + { + delayedDamageFunction(); + delayedDamageFunction = nullptr; + } +} extern BOOLEAN IsMercSayingDialogue( UINT8 ubProfileID ); @@ -11499,6 +11515,8 @@ void SOLDIERTYPE::MoveMerc( FLOAT dMovementChange, FLOAT dAngle, BOOLEAN fCheckR // OK, set new position this->EVENT_InternalSetSoldierPosition( dXPos, dYPos, FALSE, FALSE, FALSE ); + this->ResolveDelayedDamage(); + // Flugente: drag people if ( currentlydragging ) { @@ -26234,4 +26252,6 @@ void SOLDIERTYPE::InitializeExtraData(void) this->ubQuickItemSlot = 0; this->usGrenadeItem = 0; + + this->delayedDamageFunction = nullptr; } diff --git a/Tactical/Soldier Control.h b/Tactical/Soldier Control.h index e02e1de0..69745618 100644 --- a/Tactical/Soldier Control.h +++ b/Tactical/Soldier Control.h @@ -20,6 +20,7 @@ #include #include "GameSettings.h" // added by Flugente #include "Disease.h" // added by Flugente +#include #define PTR_CIVILIAN (pSoldier->bTeam == CIV_TEAM) #define PTR_CROUCHED (gAnimControl[ pSoldier->usAnimState ].ubHeight == ANIM_CROUCH) @@ -1656,6 +1657,10 @@ public: UINT8 ubQuickItemSlot; UINT16 usGrenadeItem; + + // anv: resolve damage with delay, e.g. damage applied mid movement that would cause issues with world data if applied immediately + std::function delayedDamageFunction; + public: // CREATION FUNCTIONS BOOLEAN DeleteSoldier( void ); @@ -1719,6 +1724,9 @@ public: void ReviveSoldier( void ); UINT8 SoldierTakeDamage( INT8 bHeight, INT16 sLifeDeduct, INT16 sBreathDeduct, UINT8 ubReason, UINT8 ubAttacker, INT32 sSourceGrid, INT16 sSubsequent, BOOLEAN fShowDamage ); + // anv: resolve damage with delay, e.g. damage applied mid movement that would cause issues with world data if applied immediately + void SoldierTakeDelayedDamage(INT8 bHeight, INT16 sLifeDeduct, INT16 sBreathDeduct, UINT8 ubReason, UINT8 ubAttacker, INT32 sSourceGrid, INT16 sSubsequent, BOOLEAN fShowDamage); + void ResolveDelayedDamage(); // Palette functions for soldiers BOOLEAN CreateSoldierPalettes( void ); diff --git a/TileEngine/structure.cpp b/TileEngine/structure.cpp index 49264a51..1d8b2fc2 100644 --- a/TileEngine/structure.cpp +++ b/TileEngine/structure.cpp @@ -1914,10 +1914,10 @@ INT8 DamageStructure( STRUCTURE * pStructure, UINT8 ubDamage, UINT8 ubReason, IN //Since the structure is being damaged, set the map element that a structure is damaged gpWorldLevelData[ tmpgridno ].uiFlags |= MAPELEMENT_STRUCTURE_DAMAGED; - // handle structure revenge - damage to vehicle + // handle structure revenge - damage to vehicle - to be resolved after movement if ( ubOwner != NOBODY && MercPtrs[ubOwner] && !ARMED_VEHICLE( MercPtrs[ubOwner] ) ) { - MercPtrs[ ubOwner ]->SoldierTakeDamage( 0, Random(max(0,(ubBaseArmour-10)/5))+max(0,(ubBaseArmour-10)/5), 0, TAKE_DAMAGE_STRUCTURE_EXPLOSION, NOBODY, MercPtrs[ ubOwner ]->sGridNo, 0, TRUE ); + MercPtrs[ubOwner]->SoldierTakeDelayedDamage(0, Random(max(0,(ubBaseArmour-10)/5)) + max(0,(ubBaseArmour-10)/5), 0, TAKE_DAMAGE_STRUCTURE_EXPLOSION, NOBODY, MercPtrs[ ubOwner ]->sGridNo, 0, TRUE); } // recompile = TRUE means that we destroyed something From ee3d2472e720739add6445ad9bf01e2dc613b8a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Fa=C5=82kowski?= Date: Tue, 29 Aug 2023 21:25:14 +0200 Subject: [PATCH 021/120] Removed unnecessary offset for face gear --- Tactical/Faces.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tactical/Faces.cpp b/Tactical/Faces.cpp index aad59742..059ba827 100644 --- a/Tactical/Faces.cpp +++ b/Tactical/Faces.cpp @@ -1467,8 +1467,8 @@ void GetXYForRightIconPlacement_FaceGera( FACETYPE *pFace, UINT16 ubIndex, INT16 usHeight = pTrav->usHeight; usWidth = pTrav->usWidth; - sX = sFaceX + ( usWidth * bNumIcons ) + 1; - sY = sFaceY + pFace->usFaceHeight - usHeight - 1; + sX = sFaceX + ( usWidth * bNumIcons ); + sY = sFaceY + pFace->usFaceHeight - usHeight; *psX = sX; *psY = sY; From 7910be0ab7119895b1ab2fc166ad909e8d59f7b6 Mon Sep 17 00:00:00 2001 From: kitty624 <58940527+kitty624@users.noreply.github.com> Date: Wed, 30 Aug 2023 19:34:30 +0200 Subject: [PATCH 022/120] Fix personality check for backgrounds during IMP creation --- Laptop/IMP Background.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Laptop/IMP Background.cpp b/Laptop/IMP Background.cpp index b7cddab4..ec269423 100644 --- a/Laptop/IMP Background.cpp +++ b/Laptop/IMP Background.cpp @@ -16,6 +16,7 @@ #include "soldier profile type.h" #include "IMP Compile Character.h" #include "IMP Disability Trait.h" + #include "IMP Character Trait.h" #include "GameSettings.h" #include "Interface.h" @@ -708,7 +709,7 @@ BOOLEAN IsBackGroundAllowed( UINT16 ubNumber ) break; } - switch ( iAttitude ) + switch ( iChosenCharacterTrait() ) { case CHAR_TRAIT_SOCIABLE: if ( zBackground[ ubNumber ].uiFlags & BACKGROUND_XENOPHOBIC ) From 0962319a433e61dcf2857ad88a6a0bacde961fbc Mon Sep 17 00:00:00 2001 From: kitty624 <58940527+kitty624@users.noreply.github.com> Date: Thu, 31 Aug 2023 02:55:51 +0200 Subject: [PATCH 023/120] Fix skill checks for backgrounds during IMP creation fixed checks for major and minor traits determining available IMP backgrounds edited disability trait case HEAT INTOLERANT added case DEAF at disability traits --- Laptop/IMP Background.cpp | 137 +++++++++++++++++++++++++++++++++++++- 1 file changed, 135 insertions(+), 2 deletions(-) diff --git a/Laptop/IMP Background.cpp b/Laptop/IMP Background.cpp index ec269423..1ab6cd75 100644 --- a/Laptop/IMP Background.cpp +++ b/Laptop/IMP Background.cpp @@ -17,6 +17,7 @@ #include "IMP Compile Character.h" #include "IMP Disability Trait.h" #include "IMP Character Trait.h" + #include "IMP Minor Trait.h" #include "GameSettings.h" #include "Interface.h" @@ -602,6 +603,11 @@ void ResetDisplaySkills() extern INT32 SkillsList[ ATTITUDE_LIST_SIZE ]; +extern BOOLEAN gfSkillTraitQuestions[20]; +extern BOOLEAN gfSkillTraitQuestions2[20]; + +extern BOOLEAN gfMinorTraitQuestions[IMP_SKILL_TRAITS_NEW_NUMBER_MINOR_SKILLS]; + BOOLEAN IsBackGroundAllowed( UINT16 ubNumber ) { if ( !ubNumber ) @@ -613,6 +619,122 @@ BOOLEAN IsBackGroundAllowed( UINT16 ubNumber ) else if ( !fCharacterIsMale && zBackground[ ubNumber ].uiFlags & BACKGROUND_NO_FEMALE ) return FALSE; + /* kitty: fixed following skillcheck + * the previous used "SkillList" and the after-remap naming convention (i.e. DOCTOR_NT) didn't work in this place/point of character creation + * left the out-commented previous code for reference and potential rollback + * used distinctive single and dual trait for major traits to allow for possible future finetuning by trait level + * 2023/08/30 + */ + + // major traits (single-trait and dual-trait) + if (gfSkillTraitQuestions[IMP_SKILL_TRAITS_NEW_HEAVY_WEAPONS] || gfSkillTraitQuestions2[IMP_SKILL_TRAITS_NEW_HEAVY_WEAPONS]) + { + + if (gfSkillTraitQuestions[IMP_SKILL_TRAITS_NEW_HEAVY_WEAPONS] && gfSkillTraitQuestions2[IMP_SKILL_TRAITS_NEW_HEAVY_WEAPONS]) + { + if (zBackground[ubNumber].value[BG_ARTILLERY] > 0) //dual trait (expert) + return FALSE; + } + else + { + if (zBackground[ubNumber].value[BG_ARTILLERY] > 0) //single trait + return FALSE; + } + } + + if (gfSkillTraitQuestions[IMP_SKILL_TRAITS_NEW_PROF_SNIPER] || gfSkillTraitQuestions2[IMP_SKILL_TRAITS_NEW_PROF_SNIPER]) + { + + if (gfSkillTraitQuestions[IMP_SKILL_TRAITS_NEW_PROF_SNIPER] && gfSkillTraitQuestions2[IMP_SKILL_TRAITS_NEW_PROF_SNIPER]) + { + if (zBackground[ubNumber].value[BG_PERC_CTH_MAX] < 0) //dual trait (expert) + return FALSE; + } + else + { + if (zBackground[ubNumber].value[BG_PERC_CTH_MAX] < 0) //single trait + return FALSE; + } + } + + if (gfSkillTraitQuestions[IMP_SKILL_TRAITS_NEW_MARTIAL_ARTS] || gfSkillTraitQuestions2[IMP_SKILL_TRAITS_NEW_MARTIAL_ARTS]) + { + + if (gfSkillTraitQuestions[IMP_SKILL_TRAITS_NEW_MARTIAL_ARTS] && gfSkillTraitQuestions2[IMP_SKILL_TRAITS_NEW_MARTIAL_ARTS]) + { + if (zBackground[ubNumber].value[BG_PERC_DAMAGE_MELEE] < 0) //dual trait (expert) + return FALSE; + } + else + { + if (zBackground[ubNumber].value[BG_PERC_DAMAGE_MELEE] < 0) //single trait + return FALSE; + } + } + + if (gfSkillTraitQuestions[IMP_SKILL_TRAITS_NEW_TECHNICIAN] || gfSkillTraitQuestions2[IMP_SKILL_TRAITS_NEW_TECHNICIAN]) + { + + if (gfSkillTraitQuestions[IMP_SKILL_TRAITS_NEW_TECHNICIAN] && gfSkillTraitQuestions2[IMP_SKILL_TRAITS_NEW_TECHNICIAN]) + { + if (zBackground[ubNumber].value[BG_MECHANICAL] < 0) //dual trait (expert) + return FALSE; + } + else + { + if (zBackground[ubNumber].value[BG_MECHANICAL] < 0) //single trait + return FALSE; + } + } + + if (gfSkillTraitQuestions[IMP_SKILL_TRAITS_NEW_DOCTOR] || gfSkillTraitQuestions2[IMP_SKILL_TRAITS_NEW_DOCTOR]) + { + + if (gfSkillTraitQuestions[IMP_SKILL_TRAITS_NEW_DOCTOR] && gfSkillTraitQuestions2[IMP_SKILL_TRAITS_NEW_DOCTOR]) + { + if (zBackground[ubNumber].value[BG_MEDICAL] < 0) //dual trait (expert) + return FALSE; + } + else + { + if (zBackground[ubNumber].value[BG_MEDICAL] < 0) //single trait + return FALSE; + } + } + + // minor traits (single trait only) + if (gfMinorTraitQuestions[IMP_SKILL_TRAITS_NEW_MELEE]) + { + if (zBackground[ubNumber].value[BG_PERC_CTH_BLADE] < 0) //single trait + return FALSE; + } + + if (gfMinorTraitQuestions[IMP_SKILL_TRAITS_NEW_STEALTHY]) + { + if (zBackground[ubNumber].value[BG_PERC_STEALTH] < 0) + return FALSE; + } + + if (gfMinorTraitQuestions[IMP_SKILL_TRAITS_NEW_ATHLETICS]) + { + if (zBackground[ubNumber].value[BG_PERC_SPEED_RUNNING] < 0) + return FALSE; + } + + if (gfMinorTraitQuestions[IMP_SKILL_TRAITS_NEW_DEMOLITIONS]) + { + if (zBackground[ubNumber].value[BG_EXPLOSIVE_ASSIGN] < 0) + return FALSE; + } + + if (gfMinorTraitQuestions[IMP_SKILL_TRAITS_NEW_SURVIVAL]) + { + if (zBackground[ubNumber].value[BG_PERC_CAMO] < 0) + return FALSE; + } + + /* previous code for reference + * if ( SkillsList[0] == HEAVY_WEAPONS_NT || SkillsList[1] == HEAVY_WEAPONS_NT || SkillsList[2] == HEAVY_WEAPONS_NT ) { if ( zBackground[ ubNumber ].value[BG_ARTILLERY] > 0 ) @@ -672,11 +794,18 @@ BOOLEAN IsBackGroundAllowed( UINT16 ubNumber ) if ( zBackground[ ubNumber ].value[BG_EXPLOSIVE_ASSIGN] < 0 ) return FALSE; } + */ + + /*kitty: + * added BG_TROPICAL to case HEAT_INTOLERANT - since tropical sector also is part of "MercIsHot"+HEAT_INTOLERANT (SoldierProfile.cpp), like desert + * added case DEAF - if merc is deaf, granting any bonus to hearing seems implausible + * 2023/08/30 + */ switch ( iChosenDisabilityTrait() ) { case HEAT_INTOLERANT: - if ( zBackground[ ubNumber ].value[BG_DESERT] > 0 ) + if ( zBackground[ ubNumber ].value[BG_DESERT] > 0 || zBackground[ ubNumber ].value[BG_TROPICAL] > 0 ) return FALSE; break; case NERVOUS: @@ -701,8 +830,12 @@ BOOLEAN IsBackGroundAllowed( UINT16 ubNumber ) if ( zBackground[ ubNumber ].value[BG_LEADERSHIP] > 0 ) return FALSE; break; + case DEAF: + if (zBackground[ ubNumber ].value[BG_PERC_HEARING_NIGHT] > 0 || zBackground[ ubNumber ].value[BG_PERC_HEARING_DAY] > 0) + return FALSE; + break; case AFRAID_OF_HEIGHTS: - if ( zBackground[ubNumber].value[BG_HEIGHT] > 0 ) + if ( zBackground[ ubNumber ].value[BG_HEIGHT] > 0 ) return FALSE; break; default: From 28aa73a859d71f802d961dfed617a7ea8b01cf8a Mon Sep 17 00:00:00 2001 From: rftrdev <102184004+rftrdev@users.noreply.github.com> Date: Sat, 2 Sep 2023 23:01:17 -0700 Subject: [PATCH 024/120] Clamp coolness to valid values when generating ARC ammo cache (#220) Fixes #217 --- Strategic/Rebel Command.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Strategic/Rebel Command.cpp b/Strategic/Rebel Command.cpp index b5ce30aa..84f6f69f 100644 --- a/Strategic/Rebel Command.cpp +++ b/Strategic/Rebel Command.cpp @@ -4429,7 +4429,8 @@ void SetupInfo() && (gGameOptions.ubGameStyle == STYLE_SCIFI || !Item[i].scifi)) { // coolness runs from 1-10, so apply offset - ItemIdCache::ammo[Item[i].ubCoolness-1].push_back(i); + const UINT8 coolness = min(max(1, Item[i].ubCoolness), 10); + ItemIdCache::ammo[coolness-1].push_back(i); } } } From 23ceb0fa4c7bfa3946f85fb881eee7709ad2c568 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Tue, 5 Sep 2023 17:33:42 +0300 Subject: [PATCH 025/120] Fix bug in OCTH prone CTH calculation (by Seven) (#221) GetToHitBonus() expects BOOLEAN for fProneStance argument, with no comparison to ANIM_PRONE, the ubEndHeight ends up adding bipod bonuses to *all* stances --- Tactical/Weapons.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 55acbf88..5e9350a6 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -7480,7 +7480,7 @@ UINT32 CalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTime, else { INT16 moda = GetToHitBonus(pInHand, iRange, bLightLevel, stance && iRange > MIN_PRONE_RANGE); - INT16 modb = GetToHitBonus(pInHand, iRange, bLightLevel, gAnimControl[pSoldier->usAnimState].ubEndHeight && iRange > MIN_PRONE_RANGE); + INT16 modb = GetToHitBonus(pInHand, iRange, bLightLevel, gAnimControl[pSoldier->usAnimState].ubEndHeight == ANIM_PRONE && iRange > MIN_PRONE_RANGE); iChance += (INT32)((gGameExternalOptions.ubProneModifierPercentage * moda + (100 - gGameExternalOptions.ubProneModifierPercentage) * modb) / 100); } From fc5573f73d7425070f8d6fc33fee6ab4c7f1894e Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:57:40 +0300 Subject: [PATCH 026/120] Correct check for stance (#222) Same issue as in commit 23ceb0f --- Tactical/Weapons.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 5e9350a6..667f9be4 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -7479,7 +7479,7 @@ UINT32 CalcChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTime, } else { - INT16 moda = GetToHitBonus(pInHand, iRange, bLightLevel, stance && iRange > MIN_PRONE_RANGE); + INT16 moda = GetToHitBonus(pInHand, iRange, bLightLevel, stance == ANIM_PRONE && iRange > MIN_PRONE_RANGE); INT16 modb = GetToHitBonus(pInHand, iRange, bLightLevel, gAnimControl[pSoldier->usAnimState].ubEndHeight == ANIM_PRONE && iRange > MIN_PRONE_RANGE); iChance += (INT32)((gGameExternalOptions.ubProneModifierPercentage * moda + (100 - gGameExternalOptions.ubProneModifierPercentage) * modb) / 100); } From 4c861e441af4dc4fca87f04f428f98ab192d2c5b Mon Sep 17 00:00:00 2001 From: sun-alf Date: Fri, 8 Sep 2023 15:55:01 +0300 Subject: [PATCH 027/120] [Fix] Revive FPS drawing overlay To enable built-in FPS, change gbFPSDisplay to SHOW_FULL_FPS (1) in debugger (or change it in src code and rebuild). --- TileEngine/Render Dirty.cpp | 6 ++++++ TileEngine/Render Dirty.h | 3 ++- gamescreen.cpp | 5 +++-- jascreens.cpp | 43 +++++++++++++------------------------ 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/TileEngine/Render Dirty.cpp b/TileEngine/Render Dirty.cpp index f90b3d25..1e22feb6 100644 --- a/TileEngine/Render Dirty.cpp +++ b/TileEngine/Render Dirty.cpp @@ -1009,6 +1009,12 @@ BOOLEAN UpdateVideoOverlay( VIDEO_OVERLAY_DESC *pTopmostDesc, UINT32 iBlitterInd } } + if ( uiFlags & VOVERLAY_DESC_FONT ) + { + gVideoOverlays[iBlitterIndex].uiFontID = pTopmostDesc->uiFontID; + gVideoOverlays[iBlitterIndex].ubFontBack = pTopmostDesc->ubFontBack; + gVideoOverlays[iBlitterIndex].ubFontFore = pTopmostDesc->ubFontFore; + } if ( uiFlags & VOVERLAY_DESC_DISABLED ) { diff --git a/TileEngine/Render Dirty.h b/TileEngine/Render Dirty.h index e3171deb..113f0766 100644 --- a/TileEngine/Render Dirty.h +++ b/TileEngine/Render Dirty.h @@ -15,9 +15,10 @@ #define VOVERLAY_STARTDISABLED 0x00000002 -#define VOVERLAY_DESC_TEXT 0x00001000 +#define VOVERLAY_DESC_TEXT 0x00001000 #define VOVERLAY_DESC_DISABLED 0x00002000 #define VOVERLAY_DESC_POSITION 0x00004000 +#define VOVERLAY_DESC_FONT 0x00008000 // STRUCTURES diff --git a/gamescreen.cpp b/gamescreen.cpp index 67e70d99..28fd812d 100644 --- a/gamescreen.cpp +++ b/gamescreen.cpp @@ -166,6 +166,7 @@ UINT32 MainGameScreenInit(void) UnLockVideoSurface( FRAME_BUFFER); InitializeBackgroundRects(); + InitializeBaseDirtyRectQueue(); //EnvSetTimeInHours(ENV_TIME_12); @@ -188,8 +189,8 @@ UINT32 MainGameScreenInit(void) giFPSOverlay = RegisterVideoOverlay( ( VOVERLAY_STARTDISABLED | VOVERLAY_DIRTYBYTEXT ), &VideoOverlayDesc ); // SECOND, PERIOD COUNTER - VideoOverlayDesc.sLeft = 30; - VideoOverlayDesc.sTop = 0; + VideoOverlayDesc.sLeft = 0; + VideoOverlayDesc.sTop = 12; VideoOverlayDesc.sX = VideoOverlayDesc.sLeft; VideoOverlayDesc.sY = VideoOverlayDesc.sTop; swprintf( VideoOverlayDesc.pzText, L"Levelnodes: 100000" ); diff --git a/jascreens.cpp b/jascreens.cpp index 80f5188a..f921cb0b 100644 --- a/jascreens.cpp +++ b/jascreens.cpp @@ -122,46 +122,33 @@ void DisplayFrameRate( ) uiFrameCount = 0; } - // Create string - SetFont( SMALLFONT1 ); - - //DebugMsg(TOPIC_JA2, DBG_LEVEL_0, String( "FPS: %d ", __min( uiFPS, 1000 ) ) ); - - if ( uiFPS < 20 ) - { - SetFontBackground( FONT_MCOLOR_BLACK ); - SetFontForeground( FONT_MCOLOR_LTRED ); - } - else - { - SetFontBackground( FONT_MCOLOR_BLACK ); - SetFontForeground( FONT_MCOLOR_DKGRAY ); - } - if ( gbFPSDisplay == SHOW_FULL_FPS ) { + memset(&VideoOverlayDesc, 0, sizeof(VideoOverlayDesc)); + // FRAME RATE - memset( &VideoOverlayDesc, 0, sizeof( VideoOverlayDesc ) ); - swprintf( VideoOverlayDesc.pzText, L"%ld", __min( uiFPS, 1000 ) ); - VideoOverlayDesc.uiFlags = VOVERLAY_DESC_TEXT; + VideoOverlayDesc.uiFontID = SMALLFONT1; + VideoOverlayDesc.ubFontBack = FONT_MCOLOR_BLACK; + VideoOverlayDesc.ubFontFore = uiFPS < 20 ? FONT_MCOLOR_LTRED : FONT_MCOLOR_DKGRAY; + swprintf( VideoOverlayDesc.pzText, L"FPS: %ld", __min( uiFPS, 1000 ) ); + VideoOverlayDesc.uiFlags = VOVERLAY_DESC_TEXT | VOVERLAY_DESC_FONT | VOVERLAY_DESC_DISABLED; UpdateVideoOverlay( &VideoOverlayDesc, giFPSOverlay, FALSE ); // TIMER COUNTER - swprintf( VideoOverlayDesc.pzText, L"%ld", __min( giTimerDiag, 1000 ) ); - VideoOverlayDesc.uiFlags = VOVERLAY_DESC_TEXT; + swprintf( VideoOverlayDesc.pzText, L"Frame: %04ld ms", __min( giTimerDiag, 10000 ) ); + VideoOverlayDesc.uiFlags = VOVERLAY_DESC_TEXT | VOVERLAY_DESC_DISABLED; UpdateVideoOverlay( &VideoOverlayDesc, giCounterPeriodOverlay, FALSE ); - - if( GetMouseMapPos( &usMapPos) ) - { + //if( GetMouseMapPos( &usMapPos) ) + //{ //gprintfdirty( 0, 315, L"(%d)",sMapPos); //mprintf( 0,315,L"(%d)",sMapPos); - } - else - { + //} + //else + //{ //gprintfdirty( 0, 315, L"(%d %d)",gusMouseXPos, gusMouseYPos - INTERFACE_START_Y ); //mprintf( 0,315,L"(%d %d)",gusMouseXPos, gusMouseYPos - INTERFACE_START_Y ); - } + //} } if ( ( gTacticalStatus.uiFlags & GODMODE ) ) From f8637e59725ff7af3445d5aa687fed48720c5ff9 Mon Sep 17 00:00:00 2001 From: sun-alf Date: Fri, 8 Sep 2023 21:53:38 +0300 Subject: [PATCH 028/120] [~] Performance optimizations around Attachment[] and Launchable[] arrays AIMNAS with its ~50K elements in Attachment[] suffered of performance drop when MOLLE stuff is in the visible inventory. To resolve it the following is done: * Introduce gMAXATTACHMENTS_READ with actual number of elements in Attachment[]; according refactoring. * Introduce gMAXLAUNCHABLES_READ with actual number of elements in Launchable[]; according refactoring. * Introduce std::multimap AttachmentBackmap for quick access to attachments using itemId as a key. * Sort Attachment[] by attachmentIndex right after loading from XML. According order in XML is not needed anymore. * Introduce FindAttachmentRange() for quick access to attachments using attachmentId as a key (binary search in Attachment[]). In a few words, GetHelpTextForItemInLaptop(), ValidAttachment(), SetAttachmentSlotsFlag() were heavily optimized. --- Laptop/BobbyRGuns.cpp | 155 +++++++++++++++-------------------- Tactical/Interface Items.cpp | 34 +++----- Tactical/Item Types.h | 24 +++++- Tactical/Items.cpp | 133 +++++++++++++++++++----------- Tactical/Items.h | 1 + Tactical/XML_Attachments.cpp | 41 ++++++--- Tactical/XML_Launchable.cpp | 6 +- 7 files changed, 224 insertions(+), 170 deletions(-) diff --git a/Laptop/BobbyRGuns.cpp b/Laptop/BobbyRGuns.cpp index 479a1ef7..01136a57 100644 --- a/Laptop/BobbyRGuns.cpp +++ b/Laptop/BobbyRGuns.cpp @@ -362,6 +362,29 @@ void GetHelpTextForItemInLaptop( STR16 pzStr, UINT16 usItemNumber ); void HandleBobbyRGunsKeyBoardInput(); void HandleBobbyRayMouseWheel(void); +// Appends source STR16 to target STR16 using decorators ("\n" and "..."). +// Returns TRUE if everything fits target, FALSE otherwise. +static BOOLEAN DecorateAppendString(STR16 target, size_t targetCapacity, STR16 source, UINT32 frontDecoratorsCnt = 1) +{ + const CHAR16 DECORATOR0[] = L"\n"; + const CHAR16 DECORATOR1[] = L"\n..."; + BOOLEAN result = FALSE; + size_t decoratorLen = wcslen(DECORATOR0) * frontDecoratorsCnt; + + if (wcslen(target) + decoratorLen + wcslen(source) + 1 < targetCapacity) + { + for (UINT32 i = 0; i < frontDecoratorsCnt; i++) + wcscat(target, DECORATOR0); + wcscat(target, source); + result = TRUE; + } + else if (wcslen(target) + wcslen(DECORATOR1) + 1 < targetCapacity) + { + wcscat(target, DECORATOR1); + } // otherwise don't even touch the target + return result; +} + void GameInitBobbyRGuns() { guiTempCurrentMode=0; @@ -4088,7 +4111,8 @@ void HandleBobbyRayMouseWheel(void) } void GetHelpTextForItemInLaptop( STR16 pzStr, UINT16 usItemNumber ) -{ +{ + const size_t ATTACHMENTS_STRBUF_SIZE = 3800; CHAR16 zItemName[ SIZE_ITEM_NAME ]; UINT8 ubItemCount=0; @@ -4115,12 +4139,9 @@ void GetHelpTextForItemInLaptop( STR16 pzStr, UINT16 usItemNumber ) // HEADROCK HAM 3: Variables for "Possible Attachment List" BOOLEAN fAttachmentsFound = FALSE; // Contains entire string of attachment names - CHAR16 attachStr[3900]; - // Contains current attachment string - CHAR16 attachStr2[100]; + CHAR16 attachStr[ATTACHMENTS_STRBUF_SIZE]; // Contains temporary attachment list before added to string constant from text.h - CHAR16 attachStr3[3900]; - UINT16 usAttachment; + CHAR16 attachStr3[ATTACHMENTS_STRBUF_SIZE]; CreateItem(usItemNumber, 100, &pObject); INT16 ubAttackAPs = BaseAPsToShootOrStab( APBPConstants[DEFAULT_APS], APBPConstants[DEFAULT_AIMSKILL], &pObject, NULL ); @@ -4146,109 +4167,69 @@ void GetHelpTextForItemInLaptop( STR16 pzStr, UINT16 usItemNumber ) else wcscat( apStr, L" / -" ); - // HEADROCK HAM 3: Empty these strings first, to avoid crashes. Please keep this here. - swprintf( attachStr, L"" ); - swprintf( attachStr2, L"" ); - swprintf( attachStr3, L"" ); + attachStr[0] = 0; + attachStr3[0] = 0; // HEADROCK HAM 3: Generate list of possible attachments to a gun (Guns only!) if (gGameExternalOptions.fBobbyRayTooltipsShowAttachments) { - UINT16 iLoop = 0; - // Check entire attachment list - while( 1 ) + if (UsingNewAttachmentSystem()) { - //Madd: Common Attachment Framework - //TODO: Note that the items in this list will be duplicated if they are present in both the CAF and the old attachment method - //need to refactor this to work more like the NAS attachment slots method - usAttachment = 0; - if ( IsAttachmentPointAvailable(Item[usItemNumber].uiIndex, iLoop) ) - { - usAttachment = iLoop; - // If the attachment is not hidden - if (usAttachment > 0 && !Item[ usAttachment ].hiddenaddon && !Item[ usAttachment ].hiddenattachment) - { - if (wcslen( attachStr3 ) + wcslen(Item[usAttachment].szItemName) > 3800) - { - // End list early to avoid stack overflow - wcscat( attachStr3, L"\n..." ); - break; - } - else - {// Add the attachment's name to the list. - fAttachmentsFound = TRUE; - swprintf( attachStr2, L"\n%s", Item[ usAttachment ].szItemName ); - wcscat( attachStr3, attachStr2); - } - } - } - - // Is the weapon we're checking the same as the one we're tooltipping? - usAttachment = 0; - if (Attachment[iLoop][1] == Item[usItemNumber].uiIndex) + std::pair::iterator, std::multimap::iterator> range; + std::multimap::iterator it; + range = AttachmentBackmap.equal_range(Item[usItemNumber].uiIndex); + for (it = range.first; it != range.second; it++) { - usAttachment = Attachment[iLoop][0]; - } - - // If the attachment is not hidden - if (usAttachment > 0 && !Item[ usAttachment ].hiddenaddon && !Item[ usAttachment ].hiddenattachment) - { - if (wcslen( attachStr3 ) + wcslen(Item[usAttachment].szItemName) > 3800) + UINT16 attachmentId = it->second.attachmentIndex; + if (!Item[attachmentId].hiddenaddon && !Item[attachmentId].hiddenattachment && ItemIsLegal(attachmentId, TRUE)) { - // End list early to avoid stack overflow - wcscat( attachStr3, L"\n..." ); - break; - } - else - {// Add the attachment's name to the list. fAttachmentsFound = TRUE; - swprintf( attachStr2, L"\n%s", Item[ usAttachment ].szItemName ); - wcscat( attachStr3, attachStr2); + if (DecorateAppendString(attachStr3, ATTACHMENTS_STRBUF_SIZE, Item[attachmentId].szItemName) == FALSE) + break; } } - - - iLoop++; - if (Attachment[iLoop][0] == 0 && Item[iLoop].usItemClass == 0) - { - // Reached end of list - break; - } } + else // old attachment system + { + for (UINT32 itemId = 1; itemId < gMAXITEMS_READ; itemId++) + { + // If the attachment is not hidden and attachable to the gun (usItemNumber) + if (!Item[itemId].hiddenaddon && !Item[itemId].hiddenattachment && + ItemIsLegal(itemId, TRUE) && IsAttachmentPointAvailable(Item[usItemNumber].uiIndex, itemId)) + { + fAttachmentsFound = TRUE; + if (DecorateAppendString(attachStr3, ATTACHMENTS_STRBUF_SIZE, Item[itemId].szItemName) == FALSE) + break; + } + } + } + if (fAttachmentsFound) { - // Add extra empty line and attachment list title - swprintf( attachStr, L"\n \n%s", gWeaponStatsDesc[ 14 ] ); - wcscat( attachStr, attachStr3 ); + DecorateAppendString(attachStr, ATTACHMENTS_STRBUF_SIZE, gWeaponStatsDesc[14], 2); // 2 new lines and "Attachments:" title + DecorateAppendString(attachStr, ATTACHMENTS_STRBUF_SIZE, attachStr3, 0); // no new line, list of attachments (starts with new line) } } //Sum up default attachments. BOOLEAN fFoundDefault = FALSE; - swprintf( attachStr2, L"" ); - swprintf( attachStr3, L"" ); - for(UINT8 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS; cnt++){ - if(Item[usItemNumber].defaultattachments[cnt] != 0){ - if (wcslen( attachStr ) + wcslen(attachStr3) + wcslen(Item[ Item[usItemNumber].defaultattachments[cnt] ].szItemName) > 3800) - { - // End list early to avoid stack overflow - wcscat( attachStr3, L"\n..." ); + attachStr3[0] = 0; + for (UINT8 cnt = 0; cnt < MAX_DEFAULT_ATTACHMENTS; cnt++) + { + if (Item[usItemNumber].defaultattachments[cnt] != 0) + { + if (DecorateAppendString(attachStr3, ATTACHMENTS_STRBUF_SIZE, Item[Item[usItemNumber].defaultattachments[cnt]].szItemName) == FALSE) break; - } fFoundDefault = TRUE; - swprintf( attachStr2, L"\n%s", Item[ Item[usItemNumber].defaultattachments[cnt] ].szItemName ); - wcscat( attachStr3, attachStr2 ); - } else { - //If we found an empty entry, we can assume the rest will be empty too. - break; } + else // If we found an empty entry, we can assume the rest will be empty too. + break; } - if(fFoundDefault){ - //Found at least one default attachment, write it to the attachment string. - CHAR16 defaultStr[50]; - swprintf( defaultStr, L"\n \n%s", gWeaponStatsDesc[ 17 ] ); - wcscat( attachStr, defaultStr ); - wcscat( attachStr, attachStr3 ); + + if (fFoundDefault) + { + DecorateAppendString(attachStr, ATTACHMENTS_STRBUF_SIZE, gWeaponStatsDesc[17], 2); // 2 new lines and "Default:" title + DecorateAppendString(attachStr, ATTACHMENTS_STRBUF_SIZE, attachStr3, 0); // no new line, list of attachments (starts with new line) } // HEADROCK HAM 3: Added last string (attachStr), for display of the possible attachment list. diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index d71aa3ca..9b783204 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -2913,20 +2913,16 @@ void HandleAnyMercInSquadHasCompatibleStuff( UINT8 ubSquad, OBJECTTYPE *pObject, BOOLEAN IsMutuallyValidAttachmentOrLaunchable(UINT16 usAttItem, UINT16 usItem)//dnl ch76 091113 { - UINT32 uiLoop = 0; - while ( Attachment[uiLoop][0] ) + for (UINT32 uiLoop = 0; uiLoop < gMAXATTACHMENTS_READ; uiLoop++) { - if(Attachment[uiLoop][0] == usAttItem && Attachment[uiLoop][1] == usItem || Attachment[uiLoop][0] == usItem && Attachment[uiLoop][1] == usAttItem ) + if (Attachment[uiLoop].attachmentIndex == usAttItem && Attachment[uiLoop].itemIndex == usItem || Attachment[uiLoop].attachmentIndex == usItem && Attachment[uiLoop].itemIndex == usAttItem) return(TRUE); - ++uiLoop; } - uiLoop = 0; - while ( Launchable[uiLoop][0] ) + for (UINT32 uiLoop = 0; uiLoop < gMAXLAUNCHABLES_READ; uiLoop++) { if ( Launchable[uiLoop][0] == usAttItem && Launchable[uiLoop][1] == usItem || Launchable[uiLoop][0] == usItem && Launchable[uiLoop][1] == usAttItem ) return(TRUE); - ++uiLoop; } return(FALSE); @@ -5765,12 +5761,8 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex) } // sevenfm: check launchables - for (UINT16 usLoop = 0; usLoop < MAXITEMS + 1; usLoop++) + for (UINT16 usLoop = 0; usLoop < gMAXLAUNCHABLES_READ; usLoop++) { - // check that reached end of valid launchables - if (Launchable[usLoop][0] == 0) - break; - usAttachment = 0; if (Launchable[usLoop][1] == pObject->usItem && AttachmentSlots[usLoopSlotID].nasAttachmentClass & Item[Launchable[usLoop][0]].nasAttachmentClass) { @@ -5801,17 +5793,14 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex) } // check all attachments - for (UINT16 usLoop = 0; usLoop < MAXATTACHMENTS; usLoop++) + //TODO: should be optimized using AttachmentBackmap and/or possibly FindAttachmentRange() + for (UINT32 uiLoop = 0; uiLoop < gMAXATTACHMENTS_READ; uiLoop++) { - // check that reached end of valid attachments - if (Attachment[usLoop][0] == 0) - break; - usAttachment = 0; - if (Attachment[usLoop][1] == pObject->usItem && AttachmentSlots[usLoopSlotID].nasAttachmentClass & Item[Attachment[usLoop][0]].nasAttachmentClass) + if (Attachment[uiLoop].itemIndex == pObject->usItem && AttachmentSlots[usLoopSlotID].nasAttachmentClass & Item[Attachment[uiLoop].attachmentIndex].nasAttachmentClass) { //search primary item attachments.xml - usAttachment = Attachment[usLoop][0]; + usAttachment = Attachment[uiLoop].attachmentIndex; } else { @@ -5820,8 +5809,11 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex) UINT16* p = cnt ? &attachedList.front() : NULL; while (cnt) { - if (Attachment[usLoop][1] == *p && AttachmentSlots[usLoopSlotID].nasAttachmentClass & Item[Attachment[usLoop][0]].nasAttachmentClass) - usAttachment = Attachment[usLoop][0]; + if (Attachment[uiLoop].itemIndex == *p && AttachmentSlots[usLoopSlotID].nasAttachmentClass & Item[Attachment[uiLoop].attachmentIndex].nasAttachmentClass) + { + usAttachment = Attachment[uiLoop].attachmentIndex; + break; + } cnt--, p++; } diff --git a/Tactical/Item Types.h b/Tactical/Item Types.h index 67e761d4..cdd3d2a1 100644 --- a/Tactical/Item Types.h +++ b/Tactical/Item Types.h @@ -1724,9 +1724,30 @@ typedef enum MAXITEMS = 16001 } ITEMDEFINE; +struct AttachmentStruct +{ + UINT16 attachmentIndex; + UINT16 itemIndex; + UINT16 APCost; + UINT16 NASOnly; + + bool operator<(const AttachmentStruct& a) const + { + bool result = false; + if (attachmentIndex < a.attachmentIndex) + result = true; + else if (attachmentIndex == a.attachmentIndex) + result = itemIndex < a.itemIndex; + + return result; + } +}; + // Flugente: in order not to loop over MAXITEMS items if we only have a few thousand, remember the actual number of items in the xml extern UINT32 gMAXITEMS_READ; extern UINT32 gMAXAMMOTYPES_READ; +extern UINT32 gMAXATTACHMENTS_READ; +extern UINT32 gMAXLAUNCHABLES_READ; /* CHRISL: Arrays to track ic group information. These allow us to determine which LBE slots control which pockets and what LBE class the pockets are.*/ @@ -1781,7 +1802,8 @@ const INT16 icDefault[NUM_INV_SLOTS] = { #define MAXATTACHMENTS 60000 extern INVTYPE Item[MAXITEMS]; -extern UINT16 Attachment[MAXATTACHMENTS][4]; +extern AttachmentStruct Attachment[MAXATTACHMENTS]; +extern std::multimap AttachmentBackmap; //WarmSteel - Here we have some definitions for NAS typedef struct diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index ba9d4e00..dd56f7f7 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -566,7 +566,8 @@ AttachmentInfoStruct AttachmentInfo[MAXITEMS+1];// = AttachmentSlotStruct AttachmentSlots[MAXITEMS+1]; ItemReplacementStruct ItemReplacement[MAXATTACHMENTS]; -UINT16 Attachment[MAXATTACHMENTS][4];// = +AttachmentStruct Attachment[MAXATTACHMENTS];// = +std::multimap AttachmentBackmap; // key is itemId //{ // {SILENCER, GLOCK_17}, // {SILENCER, GLOCK_18}, @@ -2253,7 +2254,6 @@ INT32 GetAttachmentInfoIndex( UINT16 usItem ) //Determine if it is possible to add this attachment to the item. BOOLEAN ValidAttachment( UINT16 usAttachment, UINT16 usItem, UINT8 * pubAPCost ) { - INT32 iLoop = 0; if (pubAPCost) { *pubAPCost = (UINT8)APBPConstants[AP_RELOAD_GUN]; //default value } @@ -2269,40 +2269,26 @@ BOOLEAN ValidAttachment( UINT16 usAttachment, UINT16 usItem, UINT8 * pubAPCost ) *pubAPCost = Item[usAttachment].ubAttachToPointAPCost; return TRUE; } + // look for the section of the array pertaining to this attachment... - while( 1 ) - { - if (Attachment[iLoop][0] == usAttachment) - { - break; - } - ++iLoop; - if (Attachment[iLoop][0] == 0) - { - // the proposed item cannot be attached to anything! - return( FALSE ); - } - } + UINT32 startIndex = 0, endIndex = 0; + if (FindAttachmentRange(usAttachment, &startIndex, &endIndex) == FALSE) + return FALSE; + // now look through this section for the item in question - while( 1 ) + for (UINT32 iLoop = startIndex; iLoop <= endIndex; iLoop++) { - if (Attachment[iLoop][1] == usItem) + if (Attachment[iLoop].itemIndex == usItem) { - if ( UsingNewAttachmentSystem( ) || Attachment[iLoop][3] != 1 ) + if ( UsingNewAttachmentSystem( ) || Attachment[iLoop].NASOnly != 1 ) { if (pubAPCost) - *pubAPCost = (UINT8)Attachment[iLoop][2]; //Madd: get ap cost of attaching items :) - break; + *pubAPCost = (UINT8)Attachment[iLoop].APCost; //Madd: get ap cost of attaching items :) } - } - ++iLoop; - if (Attachment[iLoop][0] != usAttachment) - { - // the proposed item cannot be attached to the item in question - return( FALSE ); + return TRUE; } } - return( TRUE ); + return FALSE; } BOOLEAN ValidAttachment( UINT16 usAttachment, OBJECTTYPE * pObj, UINT8 * pubAPCost, UINT8 subObject, std::vector usAttachmentSlotIndexVector) @@ -5677,40 +5663,40 @@ BOOLEAN OBJECTTYPE::AttachObjectNAS( SOLDIERTYPE * pSoldier, OBJECTTYPE * pAttac UINT64 SetAttachmentSlotsFlag(OBJECTTYPE* pObj) { UINT64 uiSlotFlag = 0; - UINT32 uiLoop = 0; - UINT32 fItem; if (pObj->exists() == false) return 0; - UINT64 point = GetAvailableAttachmentPoint(pObj, 0); - - while (uiLoop < gMAXITEMS_READ && Item[uiLoop].usItemClass != 0 || - uiLoop < MAXATTACHMENTS && Attachment[uiLoop][0] != 0 || - uiLoop < MAXITEMS + 1 && Launchable[uiLoop][0] != 0) + if (UsingNewAttachmentSystem()) { - if (uiLoop > 0 && uiLoop < gMAXITEMS_READ && IsAttachmentPointAvailable(point, uiLoop, TRUE)) + std::pair::iterator, std::multimap::iterator> range; + std::multimap::iterator it; + range = AttachmentBackmap.equal_range(pObj->usItem); + for (it = range.first; it != range.second; it++) { - fItem = uiLoop; - if (fItem && ItemIsLegal(fItem, TRUE)) - uiSlotFlag |= Item[fItem].nasAttachmentClass; + UINT16 attachmentId = it->second.attachmentIndex; + if (ItemIsLegal(attachmentId, TRUE)) + uiSlotFlag |= Item[attachmentId].nasAttachmentClass; } - if (uiLoop < MAXATTACHMENTS && Attachment[uiLoop][1] == pObj->usItem) + for (UINT32 i = 0; i < gMAXLAUNCHABLES_READ; i++) { - fItem = Attachment[uiLoop][0]; - if (fItem && ItemIsLegal(fItem, TRUE)) - uiSlotFlag |= Item[fItem].nasAttachmentClass; + if (Launchable[i][1] == pObj->usItem) + { + UINT16 attachmentId = Launchable[i][0]; + if (ItemIsLegal(attachmentId, TRUE)) + uiSlotFlag |= Item[attachmentId].nasAttachmentClass; + } } - - if (uiLoop < MAXITEMS + 1 && Launchable[uiLoop][1] == pObj->usItem) + } + else + { + UINT64 point = GetAvailableAttachmentPoint(pObj, 0); + for (UINT32 itemId = 1; itemId < gMAXITEMS_READ; itemId++) { - fItem = Launchable[uiLoop][0]; - if (fItem && ItemIsLegal(fItem, TRUE)) - uiSlotFlag |= Item[fItem].nasAttachmentClass; + if (ItemIsLegal(itemId, TRUE) && IsAttachmentPointAvailable(point, itemId, TRUE)) + uiSlotFlag |= Item[itemId].nasAttachmentClass; } - - uiLoop++; } return uiSlotFlag; @@ -16028,3 +16014,52 @@ UINT16 GetLaunchableOfExplosionType(UINT16 launcher, UINT8 explosionType) } return NOTHING; } + +BOOLEAN FindAttachmentRange(UINT16 usAttachment, UINT32* pStartIndex, UINT32* pEndIndex) +{ + BOOLEAN result = FALSE; + + INT32 leftMargin = 0; + INT32 rightMargin = (INT32)gMAXATTACHMENTS_READ - 1; + INT32 middle = 0; + // use binary search to locate the group of elements for given attachment item Id (usAttachment) + while (leftMargin <= rightMargin) + { + middle = leftMargin + (rightMargin - leftMargin) / 2; + + if (Attachment[middle].attachmentIndex == usAttachment) + { + result = TRUE; + break; + } + else if (Attachment[middle].attachmentIndex < usAttachment) + leftMargin = middle + 1; + else + rightMargin = middle - 1; + } + + if (result) + { + // now middle is an index somewhere within the group, seek for beginning and ending of the group + if (pStartIndex) + { + *pStartIndex = (UINT32)middle; + for (INT32 i = middle - 1; i >= leftMargin; i--) + if (Attachment[i].attachmentIndex == usAttachment) + *pStartIndex = (UINT32)i; + else + break; + } + if (pEndIndex) + { + *pEndIndex = (UINT32)middle; + for (INT32 i = middle + 1; i <= rightMargin; i++) + if (Attachment[i].attachmentIndex == usAttachment) + *pEndIndex = (UINT32)i; + else + break; + } + } + + return result; +} diff --git a/Tactical/Items.h b/Tactical/Items.h index bc0c49c6..ce23180f 100644 --- a/Tactical/Items.h +++ b/Tactical/Items.h @@ -568,6 +568,7 @@ INT32 GetPercentRangeBonus( OBJECTTYPE * pObj ); UINT8 GetInventorySleepModifier( SOLDIERTYPE *pSoldier ); void AttachDefaultAttachments(OBJECTTYPE *pObj, BOOLEAN fAllDefaultAttachments=TRUE);//dnl ch75 261013 +BOOLEAN FindAttachmentRange(UINT16 usAttachment, UINT32* pStartIndex, UINT32* pEndIndex); // Flugente: is this object useable by militia? BOOLEAN ObjectIsMilitiaRelevant( OBJECTTYPE *pObj ); diff --git a/Tactical/XML_Attachments.cpp b/Tactical/XML_Attachments.cpp index 7eaa8936..fdb28fc9 100644 --- a/Tactical/XML_Attachments.cpp +++ b/Tactical/XML_Attachments.cpp @@ -20,6 +20,8 @@ struct } typedef attachmentParseData; +UINT32 gMAXATTACHMENTS_READ = 0; + static void XMLCALL attachmentStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts) { @@ -93,9 +95,9 @@ attachmentEndElementHandle(void *userData, const XML_Char *name) if(pData->curIndex < pData->maxArraySize) { //DebugMsg(TOPIC_JA2, DBG_LEVEL_3,"AttachmentStartElementHandle: writing attachment to array"); - Attachment[pData->curIndex][0] = pData->curAttachment[0]; //write the attachment into the table - Attachment[pData->curIndex][1] = pData->curAttachment[1]; - Attachment[pData->curIndex][2] = pData->curAttachment[2]; + Attachment[pData->curIndex].attachmentIndex = pData->curAttachment[0]; //write the attachment into the table + Attachment[pData->curIndex].itemIndex = pData->curAttachment[1]; + Attachment[pData->curIndex].APCost = pData->curAttachment[2]; } } else if(strcmp(name, "attachmentIndex") == 0) @@ -127,7 +129,25 @@ attachmentEndElementHandle(void *userData, const XML_Char *name) } +static void MapAttachments() +{ + std::list stdList; + std::list::iterator it; + UINT32 i = 0; + for (i = 0; i < gMAXATTACHMENTS_READ; i++) + { + stdList.push_back(Attachment[i]); + AttachmentBackmap.insert(std::make_pair(Attachment[i].itemIndex, Attachment[i])); + } + + stdList.sort(); + + for (it = stdList.begin(), i = 0; it != stdList.end(); it++, i++) + { + Attachment[i] = *it; + } +} BOOLEAN ReadInAttachmentStats(STR fileName) { @@ -171,7 +191,6 @@ BOOLEAN ReadInAttachmentStats(STR fileName) XML_SetUserData(parser, &pData); - if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE)) { CHAR8 errorBuf[511]; @@ -183,13 +202,15 @@ BOOLEAN ReadInAttachmentStats(STR fileName) return FALSE; } + gMAXATTACHMENTS_READ = pData.curIndex + 1; + MapAttachments(); + MemFree(lpcBuffer); - - XML_ParserFree(parser); return( TRUE ); } + BOOLEAN WriteAttachmentStats() { HWFILE hFile; @@ -208,10 +229,10 @@ BOOLEAN WriteAttachmentStats() { FilePrintf(hFile,"\t\r\n"); - FilePrintf(hFile,"\t\t%d\r\n", Attachment[cnt][0]); - FilePrintf(hFile,"\t\t%d\r\n", Attachment[cnt][1]); - FilePrintf(hFile,"\t\t%d\r\n", Attachment[cnt][2]); - FilePrintf(hFile,"\t\t%d\r\n", Attachment[cnt][3]); + FilePrintf(hFile,"\t\t%d\r\n", Attachment[cnt].attachmentIndex); + FilePrintf(hFile,"\t\t%d\r\n", Attachment[cnt].itemIndex); + FilePrintf(hFile,"\t\t%d\r\n", Attachment[cnt].APCost); + FilePrintf(hFile,"\t\t%d\r\n", Attachment[cnt].NASOnly); FilePrintf(hFile,"\t\r\n"); } diff --git a/Tactical/XML_Launchable.cpp b/Tactical/XML_Launchable.cpp index bec05f33..26994d2d 100644 --- a/Tactical/XML_Launchable.cpp +++ b/Tactical/XML_Launchable.cpp @@ -19,6 +19,8 @@ struct } typedef launchableParseData; +UINT32 gMAXLAUNCHABLES_READ = 0; + static void XMLCALL launchableStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts) { @@ -168,9 +170,9 @@ BOOLEAN ReadInLaunchableStats(STR fileName) return FALSE; } + gMAXLAUNCHABLES_READ = pData.curIndex + 1; + MemFree(lpcBuffer); - - XML_ParserFree(parser); return( TRUE ); From 556641377c5651e5ddc51ee279d339564d5c2bdd Mon Sep 17 00:00:00 2001 From: zwwooooo Date: Sun, 10 Sep 2023 22:31:47 +0800 Subject: [PATCH 029/120] Chinese translation update(by TBS) --- Utils/_ChineseText.cpp | 52 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/Utils/_ChineseText.cpp b/Utils/_ChineseText.cpp index e587df2d..30fd7ce4 100644 --- a/Utils/_ChineseText.cpp +++ b/Utils/_ChineseText.cpp @@ -3568,8 +3568,8 @@ STR16 gpStrategicString[] = L"僵尸", //L"Zombie", L"土匪", //L"Bandit", L"土匪杀死了%d名平民,在%s分区。", //注:这里的%d和%s不可以随意放前面或后面,一定要按英文顺序,不然会出错。(%d和%s 在中文中不能反过来。) L"Bandits attack and kill %d civilians in sector %s.", - L"Transport group", - L"Transport group en route", + L"运输队", //L"Transport group", + L"运输队已出发", //L"Transport group en route", }; STR16 gpGameClockString[] = @@ -6264,7 +6264,7 @@ STR16 z113FeaturesToggleText[] = L"天气功能:暴风雪", //L"Weather: Snow", L"随机事件功能", //L"Mini Events", L"反抗军司令部功能", //L"Arulco Rebel Command", - L"Strategic Transport Groups", + L"战略运输队", //L"Strategic Transport Groups", }; STR16 z113FeaturesHelpText[] = @@ -6312,7 +6312,7 @@ STR16 z113FeaturesHelpText[] = L"|天|气|功|能|:|暴|风|雪\n \n覆盖 [Tactical Weather Settings] ALLOW_SNOW\n \n暴风雪降低了能见度。\n \n配置选项:\nSNOW_EVENTS_PER_DAY\nSNOW_CHANCE_PER_DAY\nSNOW_MIN_LENGTH_IN_MINUTES\nSNOW_MAX_LENGTH_IN_MINUTES\nWEAPON_RELIABILITY_REDUCTION_SNOW\nBREATH_GAIN_REDUCTION_SNOW\nVISUAL_DISTANCE_DECREASE_SNOW\nHEARING_REDUCTION_SNOW\n \n", //L"|W|e|a|t|h|e|r|: |S|n|o|w\nOverrides [Tactical Weather Settings] ALLOW_SNOW\n \nSnowstorms decrease visibility.\n \nConfigurable Options:\nSNOW_EVENTS_PER_DAY\nSNOW_CHANCE_PER_DAY\nSNOW_MIN_LENGTH_IN_MINUTES\nSNOW_MAX_LENGTH_IN_MINUTES\nWEAPON_RELIABILITY_REDUCTION_SNOW\nBREATH_GAIN_REDUCTION_SNOW\nVISUAL_DISTANCE_DECREASE_SNOW\nHEARING_REDUCTION_SNOW", L"|随|机|事|件|功|能\n \n覆盖 [Mini Events Settings] MINI_EVENTS_ENABLED\n \n可能发生一些随机互动事件。\n \n配置选项:\nMINI_EVENTS_MIN_HOURS_BETWEEN_EVENTS\nMINI_EVENTS_MAX_HOURS_BETWEEN_EVENTS\n \n详细信息请查看MiniEvents.lua。\n \n", //L"|M|i|n|i |E|v|e|n|t|s\nOverrides [Mini Events Settings] MINI_EVENTS_ENABLED\n \nRandom events can occur.\n \nConfigurable Options:\nMINI_EVENTS_MIN_HOURS_BETWEEN_EVENTS\nMINI_EVENTS_MAX_HOURS_BETWEEN_EVENTS\n \nSee MiniEvents.lua for more details.", L"|反|抗|军|司|令|部|功|能\n \n覆盖 [Rebel Command Settings] REBEL_COMMAND_ENABLED\n \n允许你升级占领的城镇,控制反抗军在战略层面上运作。\n \n详细的内容设定请查看RebelCommand_Settings.ini。\n \n", //L"|A|R|C\nOverrides [Rebel Command Settings] REBEL_COMMAND_ENABLED\n \nCommand the rebel movement at the strategic level, and upgrade captured towns.\n \nFor tweakable values, see RebelCommand_Settings.ini.", - L"|S|t|r|a|t|e|g|i|c |T|r|a|n|s|p|o|r|t |G|r|o|u|p|s\nOverrides [Strategic Gameplay Settings] STRATEGIC_TRANSPORT_GROUPS_ENABLED\n \nTransport groups carry valuable equipment across the map.\n \nConfigurable Options:\nMAX_SIMULTANEOUS_STRATEGIC_TRANSPORT_GROUPS", + L"|战|略|运|输|队\n \n覆盖 [Strategic Gameplay Settings] STRATEGIC_TRANSPORT_GROUPS_ENABLED\n \n运输队在地图上运送有价值的装备。\n \n配置选项: \nMAX_SIMULTANEOUS_STRATEGIC_TRANSPORT_GROUPS", //L"|S|t|r|a|t|e|g|i|c |T|r|a|n|s|p|o|r|t |G|r|o|u|p|s\nOverrides [Strategic Gameplay Settings] STRATEGIC_TRANSPORT_GROUPS_ENABLED\n \nTransport groups carry valuable equipment across the map.\n \nConfigurable Options:\nMAX_SIMULTANEOUS_STRATEGIC_TRANSPORT_GROUPS", }; STR16 z113FeaturesPanelText[] = @@ -6360,7 +6360,7 @@ STR16 z113FeaturesPanelText[] = L"启用暴风雪功能。在暴风雪中,更难被看到,武器退化更快,呼吸也更困难。", //L"Toggle snow. In a snowstorm, it is harder to see, weapons degrade faster, and it is a little harder to regain breath.", L"在游戏过程中,可能会弹出简短的事件。您可以从两个选项中选择一个,这可能会产生积极或消极的影响。事件可以影响各种各样的事情,但主要是你的佣兵。", //L"During the course of a campaign, brief events can pop up. You can select one of two responses, which may have positive and/or negative effects. Events can affect a wide variety of things, but mostly your mercs.", L"在完成反抗军食物运送任务后,你可以访问他们的(A.R.C)指挥部网站。在这里你可以设定反抗军的政策,也可以为占领区单独设置地方政策。这将带来丰厚的奖励。作为代价,城镇的民忠会上升得更慢,所以你需要更加努力地让当地人信任你。", //L"After completing the food delivery quest for the rebels, they will grant you access to their command website (A.R.C.). You can set the rebels' country-wide directive there, and capturing towns allows you to enact policies in that region that provide powerful bonuses. This comes at a price - town loyalty will rise slower, so you will need to work harder to have the locals trust you.", - L"The enemy sends groups across the map. If you can find and intercept them, they will probably have valuable gear. However, depending on your difficulty, each group that completes its transport mission provides the AI with strategic resources. Best experienced with Arulco Strategic Division enabled.", + L"敌人会在地图上派遣战略运输队,如果你能找到并截获它们就可能获取有价值的装备。但是,如果让敌人的运输队完成运输任务,那么就会给敌人提供战略资源(具体视难度而定)。要想获得最好体验,建议开启\"敌军战略司令部功能\"。", //L"The enemy sends groups across the map. If you can find and intercept them, they will probably have valuable gear. However, depending on your difficulty, each group that completes its transport mission provides the AI with strategic resources. Best experienced with Arulco Strategic Division enabled.", }; @@ -7672,7 +7672,7 @@ STR16 New113Message[] = L"无线电操作失败!", L"迫击炮弹不足,无法在分区发动密集轰炸!", L"Items.xml里没有定义信号弹物品!", - L"No High-Explosive shell item found in Items.xml!", + L"Items.xml里没有定义高爆弹物品!", //L"No High-Explosive shell item found in Items.xml!", L"未发现迫击炮,无法执行密集轰炸!", L"干扰信号成功,不需要重复操作!", L"正在监听周围声音,无需重复操作!", @@ -8693,7 +8693,7 @@ STR16 szUDBGenSecondaryStatsTooltipText[]= L"|医|用|夹|板", //L"|M|e|d|i|c|a|l |S|p|l|i|n|t", L"|阻|燃|弹|药", //L"|F|i|r|e |R|e|t|a|r|d|a|n|t |A|m|m|o", L"|燃|烧|弹|药", //L"|I|n|c|e|n|d|i|a|r|y |A|m|m|o", - L"|B|e|l|t| |F|e|d", + L"|弹|链|供|弹", //L"|B|e|l|t| |F|e|d", }; STR16 szUDBGenSecondaryStatsExplanationsTooltipText[]= @@ -8749,7 +8749,7 @@ STR16 szUDBGenSecondaryStatsExplanationsTooltipText[]= L"\n \n一旦应用, 这个物品可以提高对你的手臂\n或者腿部重伤的治疗速率。", //L"\n \nOnce applied, this item increases the healing\nspeed of severe wounds to either your arms or legs.", L"\n \n这种弹药可以灭火。", //L"\n \nThis ammo can extinguish fire.", L"\n \n这种弹药会引起燃烧(火灾)。", //L"\n \nThis ammo can cause fire.", - L"\n \nThis gun can be belt fed\nfrom a compatible LBE\nor by another merc.", + L"\n \n这种枪可以使用弹链供弹\n或者由LBE弹链供弹\n又或者由另一位佣兵供弹。", //L"\n \nThis gun can be belt fed\nfrom a compatible LBE\nor by another merc.", }; STR16 szUDBAdvStatsTooltipText[]= @@ -9330,7 +9330,7 @@ STR16 szBackgroundText_Value[]= L" 对某些其他背景的厌恶 \n", //L" dislikes some other backgrounds\n", L" 吸烟者", //L"Smoker", L" 非吸烟者", //L"Nonsmoker", - L" %s%d%% 蹲伏在可靠掩体后面对敌人的命中率 \n", //L" %s%d%% enemy CTH if crouched against thick cover in their direction\n", + L" %s%d%% 敌军对蹲伏在掩体后佣兵的命中率 \n", //L" %s%d%% enemy CTH if crouched against thick cover in their direction\n", L" %s%d%% 建设速度 \n",//L" %s%d%% building speed\n", L" 黑客技能:%s%d ",//L" hacking skill: %s%d ", L" %s%d%% 掩埋尸体速度 \n", //L" %s%d%% burial speed\n", @@ -11655,21 +11655,21 @@ STR16 szLaptopStatText[] = L"威胁对话", //L"Threaten approach", L"招募对话", //L"Recruit approach", - L"Stats will regress.", - L"Fast", - L"Average", - L"Slow", - L"Health growth", - L"Strength growth", - L"Agility growth", - L"Dexterity growth", - L"Wisdom growth", - L"Marksmanship growth", - L"Explosives growth", - L"Leadership growth", - L"Medical growth", - L"Mechanical growth", - L"Experience growth", + L"统计倒退数据。", //L"Stats will regress.", + L"快速", //L"Fast", + L"平均", //L"Average", + L"慢速", //L"Slow", + L"生命成长", //L"Health growth", + L"力量成长", //L"Strength growth", + L"敏捷成长", //L"Agility growth", + L"灵巧成长", //L"Dexterity growth", + L"智慧成长", //L"Wisdom growth", + L"枪法成长", //L"Marksmanship growth", + L"爆破成长", //L"Explosives growth", + L"领导成长", //L"Leadership growth", + L"医疗成长", //L"Medical growth", + L"机械成长", //L"Mechanical growth", + L"等级成长", //L"Experience growth", }; STR16 szGearTemplateText[] = @@ -12111,8 +12111,8 @@ STR16 szRebelCommandAgentMissionsText[] = L"协同行动,悄悄地抵进敌军,但是要小心:这可能会让你部署在劣势区域。当进攻敌军部队时,部署区会更大。", //L"Coordinate efforts to find ways to sneak up on the enemy, but be careful: it's equally possible to put yourself in a disadvantaged deployment area. When attacking enemy forces, the deployment area is much larger.", L"扰乱ASD", //L"Disrupt ASD", L"破坏Arulco特种部门(ASD)的日常行动。临时阻止ASD部署更多的机械化单位,并且大幅度降低他们的每日收入。", //L"Wreak havoc on the day-to-day operations of the Arulco Special Division. Temporarily prevent the ASD from deploying additional mechanised units, and drastically reduce their daily income.", - L"Forge Transport Orders", - L"Create a bogus supply request. An enemy transport group will be ordered to rendezvous at this agent's location.", + L"伪造运输订单", //L"Forge Transport Orders", + L"创建一个虚假的运输请求,敌方的运输队就会在这个地点位置集合。", //L"Create a bogus supply request. An enemy transport group will be ordered to rendezvous at this agent's location.", L"战略情报", //L"Strategic Intel", L"侦听敌人,发现敌军的攻击目标。当在战略地图上观察队伍时,敌军优先进攻的目标区域会被标红。", //L"Intercept plans and discover where enemies intend to strike. When viewing teams on the strategic map, sectors prioritised by the enemy will be marked in red.", L"强化本地商店", //L"Improve Local Shops", From 5bfd19e5a831b7f0eb118fe560616d9c13dd7ff8 Mon Sep 17 00:00:00 2001 From: sun-alf Date: Thu, 14 Sep 2023 01:03:20 +0300 Subject: [PATCH 030/120] [Fix] One of optimizations in (2482234e) commit is not suitable for MOLLE stuff in 1.13 It is revealed, MOLLE things in 1.13 are configured in XMLs using both NAS and OAS (old attachment system) methods even if NAS is enabled in New Game Options. Given this, logic of SetAttachmentSlotsFlag() cannot be splitted onto NAS and OAS parts, and both Attachment[] and AttachmentPoints must be checked disregarding the NAS option. --- Tactical/Items.cpp | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index dd56f7f7..8212c736 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -5667,36 +5667,31 @@ UINT64 SetAttachmentSlotsFlag(OBJECTTYPE* pObj) if (pObj->exists() == false) return 0; - if (UsingNewAttachmentSystem()) + std::pair::iterator, std::multimap::iterator> range; + std::multimap::iterator it; + range = AttachmentBackmap.equal_range(pObj->usItem); + for (it = range.first; it != range.second; it++) { - std::pair::iterator, std::multimap::iterator> range; - std::multimap::iterator it; - range = AttachmentBackmap.equal_range(pObj->usItem); - for (it = range.first; it != range.second; it++) + UINT16 attachmentId = it->second.attachmentIndex; + if (ItemIsLegal(attachmentId, TRUE)) + uiSlotFlag |= Item[attachmentId].nasAttachmentClass; + } + + for (UINT32 i = 0; i < gMAXLAUNCHABLES_READ; i++) + { + if (Launchable[i][1] == pObj->usItem) { - UINT16 attachmentId = it->second.attachmentIndex; + UINT16 attachmentId = Launchable[i][0]; if (ItemIsLegal(attachmentId, TRUE)) uiSlotFlag |= Item[attachmentId].nasAttachmentClass; } - - for (UINT32 i = 0; i < gMAXLAUNCHABLES_READ; i++) - { - if (Launchable[i][1] == pObj->usItem) - { - UINT16 attachmentId = Launchable[i][0]; - if (ItemIsLegal(attachmentId, TRUE)) - uiSlotFlag |= Item[attachmentId].nasAttachmentClass; - } - } } - else + + UINT64 point = GetAvailableAttachmentPoint(pObj, 0); + for (UINT32 itemId = 1; itemId < gMAXITEMS_READ; itemId++) { - UINT64 point = GetAvailableAttachmentPoint(pObj, 0); - for (UINT32 itemId = 1; itemId < gMAXITEMS_READ; itemId++) - { - if (ItemIsLegal(itemId, TRUE) && IsAttachmentPointAvailable(point, itemId, TRUE)) - uiSlotFlag |= Item[itemId].nasAttachmentClass; - } + if (IsAttachmentPointAvailable(point, itemId, TRUE)) + uiSlotFlag |= Item[itemId].nasAttachmentClass; } return uiSlotFlag; From 4ebae982dd194bb26e9a94d9f344aca69c1f9364 Mon Sep 17 00:00:00 2001 From: Xiaoxun92 <32814679+Xiaoxun92@users.noreply.github.com> Date: Fri, 22 Sep 2023 18:10:08 -0700 Subject: [PATCH 031/120] Downgrade startup ini errors to warnings (#229) --- jascreens.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/jascreens.cpp b/jascreens.cpp index f921cb0b..4409a0b4 100644 --- a/jascreens.cpp +++ b/jascreens.cpp @@ -398,7 +398,7 @@ UINT32 InitScreenHandle(void) int y = 40; #ifdef USE_VFS sgp::Logger_ID ini_id = sgp::Logger::instance().createLogger(); - sgp::Logger::instance().connectFile(ini_id, L"ERROR_REPORT.iniErrorMessages.txt", false, sgp::Logger::FLUSH_ON_DELETE); + sgp::Logger::instance().connectFile(ini_id, L"iniErrorReport.txt", false, sgp::Logger::FLUSH_ON_DELETE); sgp::Logger::LogInstance logger = sgp::Logger::instance().logger(ini_id); #endif while (! iniErrorMessages.empty()) { @@ -412,17 +412,17 @@ UINT32 InitScreenHandle(void) if (iniErrorMessage_create_out_file) { #ifndef USE_VFS - fopen_s( &file_pointer, "..\\ERROR_REPORT.iniErrorMessages.txt", "w" ); + fopen_s( &file_pointer, "..\\iniErrorReport.txt", "w" ); #endif y += 25; - swprintf( str, L"%S", "ERROR_REPORT.iniErrorMessages.txt has been created. Please review its content." ); - DisplayWrappedString( 10, y, 560, 2, FONT12ARIAL, FONT_RED, str, FONT_BLACK, TRUE, LEFT_JUSTIFIED ); + swprintf( str, L"%S", "Warning: found the following ini errors. iniErrorReport.txt has been created." ); + DisplayWrappedString( 10, y, 560, 2, FONT12ARIAL, FONT_ORANGE, str, FONT_BLACK, TRUE, LEFT_JUSTIFIED ); iniErrorMessage_create_out_file = FALSE; } else { #ifndef USE_VFS - fopen_s( &file_pointer, "..\\ERROR_REPORT.iniErrorMessages.txt", "a+" ); + fopen_s( &file_pointer, "..\\iniErrorReport.txt", "a+" ); #endif } @@ -434,10 +434,9 @@ UINT32 InitScreenHandle(void) #else logger << iniErrorMessage << sgp::endl; #endif - DisplayWrappedString( 10, y, 560, 2, FONT12ARIAL, FONT_RED, str, FONT_BLACK, TRUE, LEFT_JUSTIFIED ); - iniErrorMessages.pop(); + DisplayWrappedString( 10, y, 560, 2, FONT12ARIAL, FONT_ORANGE, str, FONT_BLACK, TRUE, LEFT_JUSTIFIED ); - if (iniErrorMessages.empty()) {for(int x=0 ; x <= 65535*2 ; x++);} + iniErrorMessages.pop(); } InvalidateScreen( ); From 9033e1097a08fc48e03edf9df81ab4fdc053cf2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Fa=C5=82kowski?= Date: Mon, 2 Oct 2023 18:30:17 +0200 Subject: [PATCH 032/120] Radar and overhead map color variants (#219) --- GameSettings.cpp | 6 ++++ GameSettings.h | 6 ++++ TileEngine/Radar Screen.cpp | 32 +++++++++++++++++-- TileEngine/overhead map.cpp | 62 +++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 3 deletions(-) diff --git a/GameSettings.cpp b/GameSettings.cpp index e8170449..00802dcb 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -1185,6 +1185,12 @@ void LoadGameExternalOptions() // Flugente: additional decals on objects (cracked walls, blood spatters etc.) gGameExternalOptions.fAdditionalDecals = iniReader.ReadBoolean( "Graphics Settings", "ADDITIONAL_DECALS", FALSE ); + // anv: map color variants + gGameExternalOptions.ubRadarMapModeDay = iniReader.ReadInteger("Graphics Settings", "RADAR_MAP_MODE_DAY", 0, 0, 2); + gGameExternalOptions.ubRadarMapModeNight = iniReader.ReadInteger("Graphics Settings", "RADAR_MAP_MODE_NIGHT", 3, 0, 3); + gGameExternalOptions.ubOverheadMapModeDay = iniReader.ReadInteger("Graphics Settings", "OVERHEAD_MAP_MODE_DAY", 0, 0, 2); + gGameExternalOptions.ubOverheadMapModeNight = iniReader.ReadInteger("Graphics Settings", "OVERHEAD_MAP_MODE_NIGHT", 0, 0, 3); + //################# Sound Settings ################# gGameExternalOptions.guiWeaponSoundEffectsVolume = iniReader.ReadInteger("Sound Settings","WEAPON_SOUND_EFFECTS_VOLUME", 0, 0, 1000 /*1000 = 10x?*/); diff --git a/GameSettings.h b/GameSettings.h index 33c87d16..b5df2be5 100644 --- a/GameSettings.h +++ b/GameSettings.h @@ -952,6 +952,12 @@ typedef struct BOOLEAN fAdditionalDecals; // Flugente: show additional decals on objects (cracked walls, blood spatters etc.) + // anv: map color variants + UINT8 ubRadarMapModeDay; + UINT8 ubRadarMapModeNight; + UINT8 ubOverheadMapModeDay; + UINT8 ubOverheadMapModeNight; + //enable ext mouse key BOOLEAN bAltAimEnabled; BOOLEAN bAimedBurstEnabled; diff --git a/TileEngine/Radar Screen.cpp b/TileEngine/Radar Screen.cpp index 6146818e..c485d8ca 100644 --- a/TileEngine/Radar Screen.cpp +++ b/TileEngine/Radar Screen.cpp @@ -167,9 +167,35 @@ BOOLEAN LoadRadarScreenBitmap(CHAR8 * aFilename ) if( GetVideoObject( &hVObject, gusRadarImage ) ) { - // ATE: Add a shade table! - hVObject->pShades[ 0 ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 255, 255, 255, FALSE ); - hVObject->pShades[ 1 ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 100, 100, 100, FALSE ); + // ATE: Add a shade table! + // anv: pShades[ 0 ] is a day radar map, pShades[ 1 ] is a night radar map + switch( gGameExternalOptions.ubRadarMapModeDay ) + { + case 0: + hVObject->pShades[0] = Create16BPPPaletteShaded(hVObject->pPaletteEntry, 255, 255, 255, FALSE); + break; + case 1: + hVObject->pShades[0] = Create16BPPPaletteShaded(hVObject->pPaletteEntry, 352, 352, 352, TRUE); + break; + case 2: + hVObject->pShades[0] = Create16BPPPaletteShaded(hVObject->pPaletteEntry, 160, 255, 160, TRUE); + break; + } + switch( gGameExternalOptions.ubRadarMapModeNight ) + { + case 0: + hVObject->pShades[1] = Create16BPPPaletteShaded(hVObject->pPaletteEntry, 255, 255, 255, FALSE); + break; + case 1: + hVObject->pShades[1] = Create16BPPPaletteShaded(hVObject->pPaletteEntry, 352, 352, 352, TRUE); + break; + case 2: + hVObject->pShades[1] = Create16BPPPaletteShaded(hVObject->pPaletteEntry, 160, 255, 160, TRUE); + break; + case 3: + hVObject->pShades[1] = Create16BPPPaletteShaded(hVObject->pPaletteEntry, 100, 100, 100, FALSE); + break; + } } } diff --git a/TileEngine/overhead map.cpp b/TileEngine/overhead map.cpp index c2b5a052..313161c1 100644 --- a/TileEngine/overhead map.cpp +++ b/TileEngine/overhead map.cpp @@ -2299,6 +2299,68 @@ void CopyOverheadDBShadetablesFromTileset( ) } } + // anv: map color variants + if (NightTime()) + { + switch (gGameExternalOptions.ubOverheadMapModeNight) + { + case 0: + break; + case 1: + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) + { + for (uiLoop2 = 0; uiLoop2 < HVOBJECT_SHADE_TABLES; uiLoop2++) + { + gSmTileSurf[uiLoop].vo->pShades[uiLoop2] = Create16BPPPaletteShaded(gSmTileSurf[uiLoop].vo->pPaletteEntry, 352, 352, 352, TRUE); + } + } + break; + case 2: + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) + { + for (uiLoop2 = 0; uiLoop2 < HVOBJECT_SHADE_TABLES; uiLoop2++) + { + gSmTileSurf[uiLoop].vo->pShades[uiLoop2] = Create16BPPPaletteShaded(gSmTileSurf[uiLoop].vo->pPaletteEntry, 160, 255, 160, TRUE); + } + } + break; + case 3: + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) + { + for (uiLoop2 = 0; uiLoop2 < HVOBJECT_SHADE_TABLES; uiLoop2++) + { + gSmTileSurf[uiLoop].vo->pShades[uiLoop2] = Create16BPPPaletteShaded(gSmTileSurf[uiLoop].vo->pPaletteEntry, 100, 100, 100, FALSE); + } + } + break; + } + } + else + { + switch (gGameExternalOptions.ubOverheadMapModeDay) + { + case 0: + break; + case 1: + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) + { + for (uiLoop2 = 0; uiLoop2 < HVOBJECT_SHADE_TABLES; uiLoop2++) + { + gSmTileSurf[uiLoop].vo->pShades[uiLoop2] = Create16BPPPaletteShaded(gSmTileSurf[uiLoop].vo->pPaletteEntry, 352, 352, 352, TRUE); + } + } + break; + case 2: + for (uiLoop = 0; uiLoop < (UINT32)giNumberOfTileTypes; uiLoop++) + { + for (uiLoop2 = 0; uiLoop2 < HVOBJECT_SHADE_TABLES; uiLoop2++) + { + gSmTileSurf[uiLoop].vo->pShades[uiLoop2] = Create16BPPPaletteShaded(gSmTileSurf[uiLoop].vo->pPaletteEntry, 160, 255, 160, TRUE); + } + } + break; + } + } } void TrashOverheadMap( ) From a3be3ecd7e6132c6ac7c447d4edbf0c00211c95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Fa=C5=82kowski?= Date: Mon, 2 Oct 2023 18:30:59 +0200 Subject: [PATCH 033/120] Specific drug types and drug items for background and facilities. (#226) --- Strategic/Campaign Types.h | 8 ++- Strategic/Facilities.cpp | 23 +++++- Strategic/Hourly Update.cpp | 122 ++++++++++++++++++++++++-------- Strategic/XML_FacilityTypes.cpp | 32 ++++++++- Tactical/Interface.h | 6 ++ Tactical/Soldier Control.cpp | 18 +++++ Tactical/Soldier Control.h | 4 ++ Tactical/XML.h | 5 +- Tactical/XML_Background.cpp | 50 +++++++++++-- 9 files changed, 227 insertions(+), 41 deletions(-) diff --git a/Strategic/Campaign Types.h b/Strategic/Campaign Types.h index af25aa9e..37be5a19 100644 --- a/Strategic/Campaign Types.h +++ b/Strategic/Campaign Types.h @@ -3,6 +3,7 @@ #include "types.h" #include "DEBUG.H" +#include const int MAXIMUM_VALID_X_COORDINATE = 16; const int MINIMUM_VALID_X_COORDINATE = 1; @@ -223,6 +224,11 @@ enum NUM_RISKS, }; +enum class FacilityRiskVectorTypes +{ + RISK_DRUG_ITEMS, +}; + typedef struct FACILITYRISKTYPE { // The risks involved with perfoming an assignment at a specific facility. @@ -231,6 +237,7 @@ typedef struct FACILITYRISKTYPE INT8 bBaseEffect; // Base result. If negative, result will always be negative. If positive, result will always be positive. // If 0, result can be either negative or positive. UINT8 ubRange; // Range of deviation for the base effect. + std::map> valueVectors; // Optional additional data } FACILITYRISKTYPE; @@ -333,7 +340,6 @@ typedef struct FACILITYTYPE std::vector ProductionData; } FACILITYTYPE; -#define FACILITYTYPE_SIZEOF_POD offsetof(FACILITYTYPE, ProductionData) // HEADROCK HAM 3.5: Maximum number of different facility types #define MAX_NUM_FACILITY_TYPES 255 diff --git a/Strategic/Facilities.cpp b/Strategic/Facilities.cpp index cf039a44..52975d1a 100644 --- a/Strategic/Facilities.cpp +++ b/Strategic/Facilities.cpp @@ -34,6 +34,7 @@ #include "Isometric Utils.h" #include "MilitiaSquads.h" #include "Tactical Save.h" +#include INT16 gsSkyriderCostModifier; // HEADROCK HAM 3.6: Strategic info variable, total of income/costs accumulated for the use of facilities today. @@ -1808,9 +1809,25 @@ void HandleRisksForSoldierFacilityAssignment( SOLDIERTYPE *pSoldier, UINT8 ubFac } // Add effects - CreateItem( ALCOHOL, Item[ALCOHOL].usPortionSize, &gTempObject ); - - ApplyConsumable( pSoldier, &gTempObject, TRUE, FALSE ); + { + std::vector& riskDrugItems = + gFacilityTypes[ubFacilityType].AssignmentData[ubAssignmentType].Risk[iCounter].valueVectors[FacilityRiskVectorTypes::RISK_DRUG_ITEMS]; + + if (riskDrugItems.empty()) + { + CreateItem(ALCOHOL, Item[ALCOHOL].usPortionSize, &gTempObject); + + ApplyConsumable(pSoldier, &gTempObject, TRUE, FALSE); + } + else + { + INT16 sItemId = riskDrugItems[std::uniform_int_distribution<>(0, riskDrugItems.size() - 1)(std::mt19937{ std::random_device{}() })]; + + CreateItem(sItemId, Item[sItemId].usPortionSize, &gTempObject); + + ApplyConsumable(pSoldier, &gTempObject, TRUE, FALSE); + } + } //pSoldier->AddDrugValues( DRUG_TYPE_ALCOHOL, Drug[DRUG_TYPE_ALCOHOL].ubDrugEffect, Drug[DRUG_TYPE_ALCOHOL].ubDrugTravelRate, Drug[DRUG_TYPE_ALCOHOL].ubDrugSideEffect ); diff --git a/Strategic/Hourly Update.cpp b/Strategic/Hourly Update.cpp index d9e0ddfa..4cd628c2 100644 --- a/Strategic/Hourly Update.cpp +++ b/Strategic/Hourly Update.cpp @@ -39,8 +39,8 @@ // anv: for hourly heli repair #include "Vehicles.h" #include "Map Screen Helicopter.h" -// anv: transition to save screen in extreme iron man mode -#include "gameloop.h" +#include "gameloop.h" // anv: transition to save screen in extreme iron man mode +#include // anv: shuffle drug items in hourly update void HourlyQuestUpdate(); void HourlyLarryUpdate(); @@ -342,6 +342,7 @@ void HourlyQuestUpdate() } #define BAR_TEMPTATION 4 +#define INVENTORY_DRUG_TEMPTATION 5 // Flugente: abandoned the LarryItems for the new drug system /*#define NUM_LARRY_ITEMS 6 @@ -377,40 +378,105 @@ void HourlyLarryUpdate() { fTookDrugs = FALSE; - if ( pSoldier->bAssignment < ON_DUTY && !pSoldier->flags.fBetweenSectors && pSoldier->bInSector && !( gTacticalStatus.fEnemyInSector || guiCurrentScreen == GAME_SCREEN ) ) + const std::vector drugItems = pSoldier->GetBackgroundValueVector(BackgroundVectorTypes::BG_DRUGUSE_ITEMS); + const std::vector drugTypes = pSoldier->GetBackgroundValueVector(BackgroundVectorTypes::BG_DRUGUSE_TYPES); + + if ( pSoldier->bAssignment < ON_DUTY && !pSoldier->flags.fBetweenSectors && !( gTacticalStatus.fEnemyInSector || guiCurrentScreen == GAME_SCREEN ) ) { // Flugente: reworked this for the new drug system. We now loop over our entire inventory INT8 invsize = (INT8)pSoldier->inv.size(); // remember inventorysize, so we don't call size() repeatedly for ( INT8 bLoop = 0; bLoop < invsize; ++bLoop) // ... for all items in our inventory ... { - if ( pSoldier->inv[bLoop].exists() && Item[ pSoldier->inv[bLoop].usItem ].drugtype > 0 ) + if (pSoldier->inv[bLoop].exists()) { - pObj = &(pSoldier->inv[bLoop]); - - usTemptation = 5; - - // any drug will do... I'm not going to create a new tag for sth minor like this - break; + INT16 sCurrentItemId = pSoldier->inv[bLoop].usItem; + INT16 sCurrentDrugType = Item[sCurrentItemId].drugtype; + if (Item[sCurrentItemId].drugtype > 0 && Item[sCurrentItemId].usItemClass & (IC_KIT | IC_MISC)) + { + // anv: if drug user has no items or types specified, assume any is valid, otherwise check drug item id or type + if ((drugItems.empty() && drugTypes.empty()) || + (!drugItems.empty() && std::find(drugItems.begin(), drugItems.end(), sCurrentItemId) != drugItems.end()) || + (!drugTypes.empty() && std::find(drugTypes.begin(), drugTypes.end(), sCurrentDrugType) != drugTypes.end())) + { + pObj = &(pSoldier->inv[bLoop]); + usTemptation = INVENTORY_DRUG_TEMPTATION; + break; + } + } } } // check to see if we're in a bar sector, if we are, we have access to alcohol // which may be better than anything we've got... - if ( usTemptation < BAR_TEMPTATION && GetCurrentBalance() >= Item[ ALCOHOL ].usPrice ) + INT16 sBarDrugItemId = 0; + if ( usTemptation < BAR_TEMPTATION ) { - if ( pSoldier->bSectorZ == 0 && - ( ( pSoldier->sSectorX == 13 && pSoldier->sSectorY == MAP_ROW_D) || - ( pSoldier->sSectorX == 13 && pSoldier->sSectorY == MAP_ROW_C) || - ( pSoldier->sSectorX == 5 && pSoldier->sSectorY == MAP_ROW_C) || - ( pSoldier->sSectorX == 6 && pSoldier->sSectorY == MAP_ROW_C) || - ( pSoldier->sSectorX == 5 && pSoldier->sSectorY == MAP_ROW_D) || - ( pSoldier->sSectorX == 2 && pSoldier->sSectorY == MAP_ROW_H) - ) - ) + // sevenfm: check facility + if (pSoldier->bSectorZ == 0) { - // in a bar! - fBar = TRUE; - usTemptation = BAR_TEMPTATION; + for (UINT16 usFacilityType = 0; usFacilityType < NUM_FACILITY_TYPES; usFacilityType++) + { + // Is this facility here? + if (gFacilityLocations[SECTOR(pSoldier->sSectorX, pSoldier->sSectorY)][usFacilityType].fFacilityHere) + { + for (UINT16 usFacilityAssignment = 0; usFacilityAssignment < NUM_FACILITY_ASSIGNMENTS; usFacilityAssignment++) + { + // is it a place with risk of getting drunk? + if (gFacilityTypes[usFacilityType].AssignmentData[usFacilityAssignment].Risk[RISK_DRUNK].usChance > 0) + { + // anv: check all items available for this risk + const std::vector& riskDrugItems = + gFacilityTypes[usFacilityType].AssignmentData[usFacilityAssignment].Risk[RISK_DRUNK].valueVectors[FacilityRiskVectorTypes::RISK_DRUG_ITEMS]; + + if (riskDrugItems.empty()) + { + if (GetCurrentBalance() >= Item[ALCOHOL].usPrice) + { + if ((drugItems.empty() && drugTypes.empty()) || + (!drugItems.empty() && std::find(drugItems.begin(), drugItems.end(), sBarDrugItemId) != drugItems.end()) || + (!drugTypes.empty() && std::find(drugTypes.begin(), drugTypes.end(), Item[ALCOHOL].drugtype) != drugTypes.end())) + { + sBarDrugItemId = ALCOHOL; + + // Cool. + fBar = TRUE; + } + } + } + else + { + std::vector shuffledRiskDrugItems = riskDrugItems; + std::shuffle(shuffledRiskDrugItems.begin(), shuffledRiskDrugItems.end(), std::mt19937{ std::random_device{}() }); + for (INT16 sItemId : shuffledRiskDrugItems) + { + if (sItemId < MAXITEMS && Item[sItemId].usItemClass & (IC_KIT | IC_MISC) && GetCurrentBalance() >= Item[sItemId].usPrice) + { + if ((drugItems.empty() && drugTypes.empty()) || + (!drugItems.empty() && std::find(drugItems.begin(), drugItems.end(), sItemId) != drugItems.end()) || + (!drugTypes.empty() && std::find(drugTypes.begin(), drugTypes.end(), Item[sItemId].drugtype) != drugTypes.end())) + { + sBarDrugItemId = sItemId; + + // Cool. + fBar = TRUE; + + // sevenfm: stop searching + break; + } + } + } + } + } + + + if (fBar) + { + usTemptation = BAR_TEMPTATION; + break; + } + } + } + } } } @@ -473,10 +539,10 @@ void HourlyLarryUpdate() bBoozeSlot = FindEmptySlotWithin( pSoldier, HANDPOS, NUM_INV_SLOTS ); if ( bBoozeSlot != NO_SLOT ) { + INVTYPE drugItem = Item[sBarDrugItemId]; // take $ from player's account // silversurfer: changed the price to reflect the changed amount of 25% below - //usCashAmount = Item[ ALCOHOL ].usPrice; - usCashAmount = (UINT16)( Item[ALCOHOL].usPrice / 4.0f ); + usCashAmount = (UINT16)(drugItem.usPrice / 4.0f); AddTransactionToPlayersBook ( TRANSFER_FUNDS_TO_MERC, pSoldier->ubProfile, GetWorldTotalMin(), -( usCashAmount ) ); // give Larry booze here @@ -484,10 +550,10 @@ void HourlyLarryUpdate() // Now the bottle will be fully consumed below and vanishes from inventory before the player even gets to see it. This simulates going to a bar to have a drink there. UINT8 portionsize = 25; - if ( Item[ALCOHOL].usPortionSize > 0 && Item[ALCOHOL].usPortionSize < 25 ) - portionsize = Item[ALCOHOL].usPortionSize; + if (drugItem.usPortionSize > 0 && drugItem.usPortionSize < 25) + portionsize = drugItem.usPortionSize; - CreateItem( ALCOHOL, portionsize, &( pSoldier->inv[bBoozeSlot] ) ); + CreateItem( sBarDrugItemId, portionsize, &( pSoldier->inv[bBoozeSlot] ) ); ApplyConsumable( pSoldier, &( pSoldier->inv[bBoozeSlot] ), TRUE, FALSE ); } diff --git a/Strategic/XML_FacilityTypes.cpp b/Strategic/XML_FacilityTypes.cpp index 33468d38..598cf88c 100644 --- a/Strategic/XML_FacilityTypes.cpp +++ b/Strategic/XML_FacilityTypes.cpp @@ -41,6 +41,7 @@ typedef enum typedef struct { FACILITYTYPE_PARSE_STAGE curElement; + PARSE_STAGE curGenericElement; CHAR8 szCharData[MAX_CHAR_DATA_LENGTH+1]; INT16 curAssignmentType; INT16 curRisk; @@ -168,7 +169,7 @@ facilitytypeStartElementHandle(void *userData, const XML_Char *name, const XML_C pData->curElement = FACILITYTYPE_TYPE; // Set all values to default before applying XML data - memset(&pData->curFacilityTypeData, 0, FACILITYTYPE_SIZEOF_POD); + pData->curFacilityTypeData = FACILITYTYPE(); InitFacilityTypeEntry( pData ); //DebugMsg(TOPIC_JA2, DBG_LEVEL_3,"MergeStartElementHandle: setting memory for curMerge"); @@ -405,6 +406,23 @@ facilitytypeStartElementHandle(void *userData, const XML_Char *name, const XML_C pData->maxReadDepth++; } + else if (pData->curElement == FACILITYTYPE_RISK && + pData->curRisk == RISK_DRUNK && + strcmp(name, "drugitems") == 0) + { + pData->curGenericElement = ELEMENT_VECTOR_OF_NUMBERS; + pData->curElement = FACILITYTYPE_RISK_ELEMENT; + pData->curAssignmentData.Risk[pData->curRisk].valueVectors[FacilityRiskVectorTypes::RISK_DRUG_ITEMS].clear(); + + pData->maxReadDepth++; + } + else if (pData->curGenericElement == ELEMENT_VECTOR_OF_NUMBERS && + strcmp(name, "drugitem") == 0) + { + pData->curGenericElement = ELEMENT_VECTOR_OF_NUMBERS_NUMBER; + pData->maxReadDepth++; + } + else if ( pData->curElement == FACILITYTYPE_PRODUCTION && ( strcmp( name, "szProductionName" ) == 0 || strcmp( name, "szAdditionalRequirementTips" ) == 0 || @@ -530,6 +548,7 @@ facilitytypeEndElementHandle(void *userData, const XML_Char *name) gFacilityTypes[pData->curIndex].AssignmentData[cnt].Risk[cntB].usChance = pData->curFacilityTypeData.AssignmentData[cnt].Risk[cntB].usChance; gFacilityTypes[pData->curIndex].AssignmentData[cnt].Risk[cntB].bBaseEffect = pData->curFacilityTypeData.AssignmentData[cnt].Risk[cntB].bBaseEffect; gFacilityTypes[pData->curIndex].AssignmentData[cnt].Risk[cntB].ubRange = pData->curFacilityTypeData.AssignmentData[cnt].Risk[cntB].ubRange; + gFacilityTypes[pData->curIndex].AssignmentData[cnt].Risk[cntB].valueVectors = pData->curFacilityTypeData.AssignmentData[cnt].Risk[cntB].valueVectors; } } @@ -673,6 +692,7 @@ facilitytypeEndElementHandle(void *userData, const XML_Char *name) pData->curFacilityTypeData.AssignmentData[pData->curAssignmentType].Risk[cnt].usChance = pData->curAssignmentData.Risk[cnt].usChance; pData->curFacilityTypeData.AssignmentData[pData->curAssignmentType].Risk[cnt].bBaseEffect = pData->curAssignmentData.Risk[cnt].bBaseEffect; pData->curFacilityTypeData.AssignmentData[pData->curAssignmentType].Risk[cnt].ubRange = pData->curAssignmentData.Risk[cnt].ubRange; + pData->curFacilityTypeData.AssignmentData[pData->curAssignmentType].Risk[cnt].valueVectors = pData->curAssignmentData.Risk[cnt].valueVectors; } } else @@ -1252,6 +1272,14 @@ facilitytypeEndElementHandle(void *userData, const XML_Char *name) pData->curProductionData.usOptional_PreProducts.push_back( data ); } } + else if (pData->curGenericElement == ELEMENT_VECTOR_OF_NUMBERS_NUMBER && strcmp(name, "drugitem") == 0) + { + pData->curGenericElement = ELEMENT_VECTOR_OF_NUMBERS; + pData->curElement = FACILITYTYPE_RISK; + + INT16 drugValue = (INT16)atol(pData->szCharData); + pData->curAssignmentData.Risk[pData->curRisk].valueVectors[FacilityRiskVectorTypes::RISK_DRUG_ITEMS].push_back(drugValue); + } pData->maxReadDepth--; } @@ -1299,7 +1327,7 @@ BOOLEAN ReadInFacilityTypes(STR fileName, BOOLEAN localizedVersion) XML_SetCharacterDataHandler(parser, facilitytypeCharacterDataHandle); - memset(&pData, 0, FACILITYTYPEPARSEDATA_SIZE_OF_POD); + pData = facilitytypeParseData(); pData.maxArraySize = MAXITEMS; pData.curIndex = 0; diff --git a/Tactical/Interface.h b/Tactical/Interface.h index ff767245..0df8a4c6 100644 --- a/Tactical/Interface.h +++ b/Tactical/Interface.h @@ -211,6 +211,11 @@ enum { BG_MAX, }; +enum class BackgroundVectorTypes { + BG_DRUGUSE_TYPES, + BG_DRUGUSE_ITEMS, +}; + typedef struct { UINT16 uiIndex; @@ -220,6 +225,7 @@ typedef struct UINT64 uiFlags; // this flagmask defines what special properties this background has (on/off behaviour) INT16 value[BG_MAX]; // property values + std::map> valueVectors; // optional additional data } BACKGROUND_VALUES; #define NUM_BACKGROUND 500 diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 271368d0..103ceb66 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -17605,6 +17605,24 @@ INT16 SOLDIERTYPE::GetBackgroundValue( UINT16 aNr ) return 0; } +const std::vector& SOLDIERTYPE::GetBackgroundValueVector(BackgroundVectorTypes backgroundVectorType) const +{ + static const std::vector emptyVector; + + if (UsingBackGroundSystem() && this->ubProfile != NO_PROFILE) + { + const BACKGROUND_VALUES& background = zBackground[gMercProfiles[this->ubProfile].usBackground]; + auto iterator = background.valueVectors.find(backgroundVectorType); + + if (iterator != background.valueVectors.end()) + { + return iterator->second; + } + } + + return emptyVector; +} + INT8 SOLDIERTYPE::GetSuppressionResistanceBonus( ) { INT8 bonus = 0; diff --git a/Tactical/Soldier Control.h b/Tactical/Soldier Control.h index 69745618..5873618d 100644 --- a/Tactical/Soldier Control.h +++ b/Tactical/Soldier Control.h @@ -1070,6 +1070,8 @@ public: INT8 bPathStored; // good for AI to reduct redundancy }; +enum class BackgroundVectorTypes; + class SOLDIERTYPE//last edited at version 102 { public: @@ -1954,6 +1956,8 @@ public: BOOLEAN HasBackgroundFlag( UINT64 aFlag ); INT16 GetBackgroundValue( UINT16 aNr ); + const std::vector& SOLDIERTYPE::GetBackgroundValueVector(BackgroundVectorTypes backgroundVectorType) const; + INT8 GetSuppressionResistanceBonus(); // bonus to resistance against suppression INT16 GetMeleeDamageBonus(); INT16 GetAPBonus(); diff --git a/Tactical/XML.h b/Tactical/XML.h index 03a95811..efa28c25 100644 --- a/Tactical/XML.h +++ b/Tactical/XML.h @@ -44,7 +44,10 @@ enum ELEMENT_DISABILITY_EFFECT, ELEMENT_DISABILITY_EFFECT_PROPERTY, ELEMENT_PERSONALITY_EFFECT, - ELEMENT_PERSONALITY_EFFECT_PROPERTY + ELEMENT_PERSONALITY_EFFECT_PROPERTY, + + ELEMENT_VECTOR_OF_NUMBERS, + ELEMENT_VECTOR_OF_NUMBERS_NUMBER, } typedef PARSE_STAGE; diff --git a/Tactical/XML_Background.cpp b/Tactical/XML_Background.cpp index 347f1442..5caac1cd 100644 --- a/Tactical/XML_Background.cpp +++ b/Tactical/XML_Background.cpp @@ -41,8 +41,13 @@ backgroundStartElementHandle(void *userData, const XML_Char *name, const XML_Cha { pData->curElement = ELEMENT_LIST; - if ( !localizedTextOnly_BG ) - memset(pData->curArray,0,sizeof(BACKGROUND_VALUES)*pData->maxArraySize); + if (!localizedTextOnly_BG) + { + for (UINT32 i = 0; i < pData->maxArraySize; i++) + { + pData->curArray[i] = BACKGROUND_VALUES(); + } + } pData->maxReadDepth++; //we are not skipping this element } @@ -50,8 +55,8 @@ backgroundStartElementHandle(void *userData, const XML_Char *name, const XML_Cha { pData->curElement = ELEMENT; - if ( !localizedTextOnly_BG ) - memset(&pData->curBackground,0,sizeof(BACKGROUND_VALUES)); + if (!localizedTextOnly_BG) + pData->curBackground = BACKGROUND_VALUES(); pData->maxReadDepth++; //we are not skipping this element } @@ -153,6 +158,27 @@ backgroundStartElementHandle(void *userData, const XML_Char *name, const XML_Cha pData->maxReadDepth++; //we are not skipping this element } + else if (strcmp(name, "drugtypes") == 0 && pData->curElement == ELEMENT) + { + pData->curElement = ELEMENT_VECTOR_OF_NUMBERS; + pData->curBackground.valueVectors[BackgroundVectorTypes::BG_DRUGUSE_TYPES].clear(); + + pData->maxReadDepth++; //we are not skipping this element + } + else if (strcmp(name, "drugitems") == 0 && pData->curElement == ELEMENT) + { + pData->curElement = ELEMENT_VECTOR_OF_NUMBERS; + pData->curBackground.valueVectors[BackgroundVectorTypes::BG_DRUGUSE_TYPES].clear(); + + pData->maxReadDepth++; //we are not skipping this element + } + else if (pData->curElement == ELEMENT_VECTOR_OF_NUMBERS && + (strcmp(name, "drugtype") == 0 || + strcmp(name, "drugitem") == 0)) + { + pData->curElement = ELEMENT_VECTOR_OF_NUMBERS_NUMBER; + pData->maxReadDepth++; //we are not skipping this element + } pData->szCharData[0] = '\0'; } @@ -667,7 +693,19 @@ backgroundEndElementHandle(void *userData, const XML_Char *name) pData->curElement = ELEMENT; pData->curBackground.uiFlags |= (UINT16)atol(pData->szCharData) ? BACKGROUND_CIVGROUPLOYAL : 0; } - + else if (strcmp(name, "drugtype") == 0) + { + pData->curElement = ELEMENT_VECTOR_OF_NUMBERS; + INT16 drugValue = (INT16)atol(pData->szCharData); + pData->curBackground.valueVectors[BackgroundVectorTypes::BG_DRUGUSE_TYPES].push_back(drugValue); + } + else if (strcmp(name, "drugitem") == 0) + { + pData->curElement = ELEMENT_VECTOR_OF_NUMBERS; + INT16 drugValue = (INT16)atol(pData->szCharData); + pData->curBackground.valueVectors[BackgroundVectorTypes::BG_DRUGUSE_ITEMS].push_back(drugValue); + } + pData->maxReadDepth--; } pData->currentDepth--; @@ -711,7 +749,7 @@ BOOLEAN ReadInBackgrounds(STR fileName, BOOLEAN localizedVersion) XML_SetCharacterDataHandler(parser, backgroundCharacterDataHandle); - memset(&pData,0,sizeof(pData)); + pData = enemyRankParseData(); pData.curArray = zBackground; pData.maxArraySize = NUM_BACKGROUND; From 14ec138fc7348c9cf6b0fbef22d178729c52e304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Fa=C5=82kowski?= Date: Mon, 2 Oct 2023 18:32:15 +0200 Subject: [PATCH 034/120] Fixed UI movement mode not switching to crawl on character collapse, leading to deadlocks (#231) --- Tactical/Points.cpp | 2 +- Tactical/Soldier Control.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Tactical/Points.cpp b/Tactical/Points.cpp index f16aacc8..81597a60 100644 --- a/Tactical/Points.cpp +++ b/Tactical/Points.cpp @@ -3214,7 +3214,7 @@ BOOLEAN CheckForMercContMove( SOLDIERTYPE *pSoldier ) return( FALSE ); } - if( pSoldier->stats.bLife >= OKLIFE ) + if( pSoldier->stats.bLife >= OKLIFE && !(pSoldier->bCollapsed && pSoldier->bBreath < OKBREATH) ) { if( pSoldier->sGridNo != pSoldier->pathing.sFinalDestination || pSoldier->bGoodContPath ) { diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 103ceb66..d41c63a4 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -21855,6 +21855,8 @@ void SoldierCollapse( SOLDIERTYPE *pSoldier ) pSoldier->bCollapsed = TRUE; + pSoldier->usUIMovementMode = CRAWLING; + pSoldier->ReceivingSoldierCancelServices( ); // CC has requested - handle sight here... From 8d49e74df457e52771a5f553212a7db3e80659a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Fa=C5=82kowski?= Date: Tue, 3 Oct 2023 14:20:36 +0200 Subject: [PATCH 035/120] Face gear render fixes (#232) * Face gear is shaded the same as a face * Render continue button above icons and facegear * Face gear rendered below "hatch" (inactivity overlay) * Consistent naming --- Tactical/Faces.cpp | 586 +++++++++++++++++++++++---------------------- 1 file changed, 305 insertions(+), 281 deletions(-) diff --git a/Tactical/Faces.cpp b/Tactical/Faces.cpp index 059ba827..a1647353 100644 --- a/Tactical/Faces.cpp +++ b/Tactical/Faces.cpp @@ -62,7 +62,8 @@ void NewEye( FACETYPE *pFace ); void NewMouth( FACETYPE *pFace ); INT32 GetFreeFace(void); void RecountFaces(void); -void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLEAN fUseExternBuffer, UINT32 uiBuffer, INT16 sFaceX, INT16 sFaceY, UINT16 usEyesX, UINT16 usEyesY ); +UINT32 GetFaceShade(SOLDIERTYPE *pSoldier, FACETYPE *pFace, BOOLEAN fExternBlit); +void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLEAN fUseExternBuffer, UINT32 uiBuffer, INT16 sFaceX, INT16 sFaceY, UINT16 usEyesX, UINT16 usEyesY, UINT32 uiFaceShade); extern BOOLEAN gfInItemPickupMenu; @@ -157,6 +158,32 @@ INT32 InitFace( UINT8 usMercProfileID, UINT8 ubSoldierID, UINT32 uiInitFlags ) } +void SetPalettes(HVOBJECT *hVObject, UINT32 uiIndex) +{ + SGPPaletteEntry Pal[256]; + + // Build a grayscale palette! ( for testing different looks ) + for (UINT32 uiCount = 0; uiCount < 256; uiCount++) + { + Pal[uiCount].peRed = 255; + Pal[uiCount].peGreen = 255; + Pal[uiCount].peBlue = 255; + } + + (*hVObject)->pShades[FLASH_PORTRAIT_NOSHADE] = Create16BPPPaletteShaded((*hVObject)->pPaletteEntry, 255, 255, 255, FALSE); + (*hVObject)->pShades[FLASH_PORTRAIT_STARTSHADE] = Create16BPPPaletteShaded(Pal, 255, 255, 255, FALSE); + (*hVObject)->pShades[FLASH_PORTRAIT_ENDSHADE] = Create16BPPPaletteShaded((*hVObject)->pPaletteEntry, 250, 25, 25, TRUE); + (*hVObject)->pShades[FLASH_PORTRAIT_DARKSHADE] = Create16BPPPaletteShaded((*hVObject)->pPaletteEntry, 100, 100, 100, TRUE); + (*hVObject)->pShades[FLASH_PORTRAIT_LITESHADE] = Create16BPPPaletteShaded((*hVObject)->pPaletteEntry, 100, 100, 100, FALSE); + + for (UINT32 uiCount = 0; uiCount < 256; uiCount++) + { + Pal[uiCount].peRed = (UINT8)(uiCount % 128) + 128; + Pal[uiCount].peGreen = (UINT8)(uiCount % 128) + 128; + Pal[uiCount].peBlue = (UINT8)(uiCount % 128) + 128; + } + (*hVObject)->pShades[FLASH_PORTRAIT_GRAYSHADE] = Create16BPPPaletteShaded(Pal, 255, 255, 255, FALSE); +} INT32 InternalInitFace( UINT8 usMercProfileID, UINT8 ubSoldierID, UINT32 uiInitFlags, INT32 iFaceFileID, UINT32 uiBlinkFrequency, UINT32 uiExpressionFrequency ) { @@ -167,7 +194,6 @@ INT32 InternalInitFace( UINT8 usMercProfileID, UINT8 ubSoldierID, UINT32 uiInitF ETRLEObject ETRLEObject; HVOBJECT hVObject; UINT32 uiCount; - SGPPaletteEntry Pal[256]; if( ( iFaceIndex = GetFreeFace() )==(-1) ) return(-1); @@ -436,33 +462,11 @@ INT32 InternalInitFace( UINT8 usMercProfileID, UINT8 ubSoldierID, UINT32 uiInitF // Set palette - if( GetVideoObject( &hVObject, uiVideoObject ) ) + if (GetVideoObject(&hVObject, uiVideoObject)) { - // Build a grayscale palette! ( for testing different looks ) - for(uiCount=0; uiCount < 256; uiCount++) - { - Pal[uiCount].peRed=255; - Pal[uiCount].peGreen=255; - Pal[uiCount].peBlue=255; - } - - hVObject->pShades[ FLASH_PORTRAIT_NOSHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 255, 255, 255, FALSE ); - hVObject->pShades[ FLASH_PORTRAIT_STARTSHADE ] = Create16BPPPaletteShaded( Pal, 255, 255, 255, FALSE ); - hVObject->pShades[ FLASH_PORTRAIT_ENDSHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 250, 25, 25, TRUE ); - hVObject->pShades[ FLASH_PORTRAIT_DARKSHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 100, 100, 100, TRUE ); - hVObject->pShades[ FLASH_PORTRAIT_LITESHADE ] = Create16BPPPaletteShaded( hVObject->pPaletteEntry, 100, 100, 100, FALSE ); - - for(uiCount=0; uiCount < 256; uiCount++) - { - Pal[uiCount].peRed=(UINT8)(uiCount%128)+128; - Pal[uiCount].peGreen=(UINT8)(uiCount%128)+128; - Pal[uiCount].peBlue=(UINT8)(uiCount%128)+128; - } - hVObject->pShades[ FLASH_PORTRAIT_GRAYSHADE ] = Create16BPPPaletteShaded( Pal, 255, 255, 255, FALSE ); - + SetPalettes(&hVObject, uiVideoObject); } - // Get FACE height, width if( GetVideoObjectETRLEPropertiesFromIndex( uiVideoObject, &ETRLEObject, 0 ) == FALSE ) { @@ -942,9 +946,13 @@ void BlinkAutoFace( INT32 iFaceIndex ) { pFace = &gFacesData[ iFaceIndex ]; + UINT32 uiFaceShade = FLASH_PORTRAIT_NOSHADE; + // CHECK IF BUDDY IS DEAD, UNCONSCIOUS, ASLEEP, OR POW! if ( pFace->ubSoldierID != NOBODY ) { + uiFaceShade = GetFaceShade(MercPtrs[pFace->ubSoldierID], pFace, FALSE); + if ( ( MercPtrs[ pFace->ubSoldierID ]->stats.bLife < OKLIFE ) || ( MercPtrs[ pFace->ubSoldierID ]->flags.fMercAsleep == TRUE ) || ( MercPtrs[ pFace->ubSoldierID ]->bAssignment == ASSIGNMENT_POW ) ) @@ -1043,8 +1051,7 @@ void BlinkAutoFace( INT32 iFaceIndex ) } - HandleRenderFaceAdjustments( pFace, TRUE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY ); - + HandleRenderFaceAdjustments(pFace, TRUE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY, uiFaceShade); } } @@ -1228,7 +1235,15 @@ void MouthAutoFace( INT32 iFaceIndex ) } - HandleRenderFaceAdjustments( pFace, TRUE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY ); + UINT32 uiFaceShade = FLASH_PORTRAIT_NOSHADE; + + // Set shade + if (pFace->ubSoldierID != NOBODY) + { + uiFaceShade = GetFaceShade(MercPtrs[pFace->ubSoldierID], pFace, FALSE); + } + + HandleRenderFaceAdjustments( pFace, TRUE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY, uiFaceShade); } } @@ -1317,32 +1332,38 @@ void HandleTalkingAutoFace( INT32 iFaceIndex ) // Local function - uses these variables because they have already been validated -void SetFaceShade( SOLDIERTYPE *pSoldier, FACETYPE *pFace, BOOLEAN fExternBlit ) +void SetFaceShade(FACETYPE *pFace, UINT32 uiFaceShade) { // Set to default - SetObjectHandleShade( pFace->uiVideoObject, FLASH_PORTRAIT_NOSHADE ); + SetObjectHandleShade(pFace->uiVideoObject, uiFaceShade); +} - if ( pFace->iVideoOverlay == -1 && !fExternBlit ) +UINT32 GetFaceShade(SOLDIERTYPE *pSoldier, FACETYPE *pFace, BOOLEAN fExternBlit) +{ + if (pFace->iVideoOverlay == -1 && !fExternBlit) { - if ( ( pSoldier->bActionPoints == 0 ) && !( gTacticalStatus.uiFlags & REALTIME ) && (gTacticalStatus.uiFlags & INCOMBAT ) ) + if ((pSoldier->bActionPoints == 0) && !(gTacticalStatus.uiFlags & REALTIME) && (gTacticalStatus.uiFlags & INCOMBAT)) { - SetObjectHandleShade( pFace->uiVideoObject, FLASH_PORTRAIT_LITESHADE ); + return FLASH_PORTRAIT_LITESHADE; } } - if ( pSoldier->stats.bLife < OKLIFE ) + if (pSoldier->stats.bLife < OKLIFE) { - SetObjectHandleShade( pFace->uiVideoObject, FLASH_PORTRAIT_DARKSHADE ); + return FLASH_PORTRAIT_DARKSHADE; } // ATE: Don't shade for damage if blitting extern face... - if ( !fExternBlit ) + if (!fExternBlit) { - if ( pSoldier->flags.fFlashPortrait == FLASH_PORTRAIT_START ) + if (pSoldier->flags.fFlashPortrait == FLASH_PORTRAIT_START) { - SetObjectHandleShade( pFace->uiVideoObject, pSoldier->bFlashPortraitFrame ); + return pSoldier->bFlashPortraitFrame; } } + + // Set to default + return FLASH_PORTRAIT_NOSHADE; } BOOLEAN RenderAutoFaceFromSoldier( UINT8 ubSoldierID ) @@ -1450,45 +1471,46 @@ void DoRightIcon_legion_GAS_MASK( UINT32 uiRenderBuffer, FACETYPE *pFace, INT16 } */ -void GetXYForRightIconPlacement_FaceGera( FACETYPE *pFace, UINT16 ubIndex, INT16 sFaceX, INT16 sFaceY, INT16 *psX, INT16 *psY, INT8 bNumIcons , UINT32 uIDFaceGear, BOOLEAN isIMP) +void GetXYForRightIconPlacement_FaceGear(FACETYPE *pFace, UINT16 ubIndex, INT16 sFaceX, INT16 sFaceY, INT16 *psX, INT16 *psY, INT8 bNumIcons, UINT32 uiFaceGearIndex, UINT32 uiFaceShade) { INT16 sX, sY; UINT16 usWidth, usHeight; - ETRLEObject *pTrav; - HVOBJECT hVObject; + ETRLEObject *pTrav; + HVOBJECT hVObject = nullptr; // Get height, width of icon... - if (isIMP) - GetVideoObject( &hVObject, zNewFaceGearIMP[uIDFaceGear].uiIndex ); - else - GetVideoObject( &hVObject, zNewFaceGear[uIDFaceGear].uiIndex ); - - pTrav = &(hVObject->pETRLEObject[ ubIndex ] ); - usHeight = pTrav->usHeight; - usWidth = pTrav->usWidth; + if (GetVideoObject(&hVObject, uiFaceGearIndex)) + { + SetPalettes(&hVObject, uiFaceGearIndex); + } - sX = sFaceX + ( usWidth * bNumIcons ); + SetObjectShade(hVObject, uiFaceShade); + + pTrav = &(hVObject->pETRLEObject[ubIndex]); + usHeight = pTrav->usHeight; + usWidth = pTrav->usWidth; + + sX = sFaceX + (usWidth * bNumIcons); sY = sFaceY + pFace->usFaceHeight - usHeight; *psX = sX; *psY = sY; } -void DoRightIcon_FaceGear( UINT32 uiRenderBuffer, FACETYPE *pFace, INT16 sFaceX, INT16 sFaceY, INT8 bNumIcons, UINT8 sIconIndex , UINT32 uIDFaceGear, BOOLEAN isIMP) +void DoRightIcon_FaceGear(UINT32 uiRenderBuffer, FACETYPE *pFace, INT16 sFaceX, INT16 sFaceY, INT8 bNumIcons, UINT8 sIconIndex, UINT32 uIDFaceGear, BOOLEAN isIMP, UINT32 uiFaceShade) { - INT16 sIconX, sIconY; + INT16 sIconX, sIconY; // Find X, y for placement - if (isIMP) { - GetXYForRightIconPlacement_FaceGera( pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons , uIDFaceGear,isIMP); - BltVideoObjectFromIndex( uiRenderBuffer, zNewFaceGearIMP[uIDFaceGear].uiIndex, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL ); + GetXYForRightIconPlacement_FaceGear(pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons, zNewFaceGearIMP[uIDFaceGear].uiIndex, uiFaceShade); + BltVideoObjectFromIndex(uiRenderBuffer, zNewFaceGearIMP[uIDFaceGear].uiIndex, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL); } else { - GetXYForRightIconPlacement_FaceGera( pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons , uIDFaceGear,isIMP); - BltVideoObjectFromIndex( uiRenderBuffer, zNewFaceGear[uIDFaceGear].uiIndex, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL ); + GetXYForRightIconPlacement_FaceGear(pFace, sIconIndex, sFaceX, sFaceY, &sIconX, &sIconY, bNumIcons, zNewFaceGear[uIDFaceGear].uiIndex, uiFaceShade); + BltVideoObjectFromIndex(uiRenderBuffer, zNewFaceGear[uIDFaceGear].uiIndex, sIconIndex, sIconX, sIconY, VO_BLT_SRCTRANSPARENCY, NULL); } } //---------------------------------------------------------------- @@ -1548,7 +1570,7 @@ void DoRightIcon( UINT32 uiRenderBuffer, FACETYPE *pFace, INT16 sFaceX, INT16 sF } -void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLEAN fUseExternBuffer, UINT32 uiBuffer, INT16 sFaceX, INT16 sFaceY, UINT16 usEyesX, UINT16 usEyesY ) +void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLEAN fUseExternBuffer, UINT32 uiBuffer, INT16 sFaceX, INT16 sFaceY, UINT16 usEyesX, UINT16 usEyesY, UINT32 uiFaceShade) { INT16 sIconX, sIconY; INT16 sIconIndex = -1; @@ -1612,6 +1634,190 @@ void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLE { pSoldier = MercPtrs[ pFace->ubSoldierID ]; + UINT8 faceProfileId = gMercProfiles[pSoldier->ubProfile].ubFaceIndex; + BOOLEAN isIMP = gMercProfiles[pSoldier->ubProfile].Type == PROFILETYPE_IMP; + + if (gGameSettings.fOptions[TOPTION_SHOW_TACTICAL_FACE_GEAR] && MercPtrs[pFace->ubSoldierID]->stats.bLife > 0 && !(pFace->uiFlags & FACE_BIGFACE)) + { + if (MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem > 0) + { + uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem; + + if (uiFaceItemOne != NONE && zNewFaceGear[uiFaceItemOne].Type == 1) //back + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceItemOne, isIMP, uiFaceShade); + } + } + + // this section chooses the pictures for gas mask and NV goggles if the ini setting "SHOW_TACTICAL_FACE_GEAR" is TRUE + // and the merc actually wears something to be shown + if (MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem + MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem > 0) + { + // WANNE: Removed the limitation + // silversurfer: don't overwrite icons if they shall be shown! + //if ( !gGameSettings.fOptions[ SHOW_TACTICAL_FACE_ICONS ] ) + { + uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem; + uiFaceItemTwo = MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem; + + uiFaceOne = MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem; + uiFaceTwo = MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem; + + // check first face slot + if (uiFaceItemOne != NONE) + { + if (zNewFaceGear[uiFaceOne].Type == 3) + { + uiFaceItemOne = 1; + } + else if (zNewFaceGear[uiFaceOne].Type == 4) + { + uiFaceItemOne = 2; + } + else uiFaceItemOne = 0; + } + + // check second face slot + if (uiFaceItemTwo != NONE) + { + if (zNewFaceGear[uiFaceTwo].Type == 3) + { + uiFaceItemTwo = 21; + } + else if (zNewFaceGear[uiFaceTwo].Type == 4) + { + uiFaceItemTwo = 42; + } + else uiFaceItemTwo = 0; + } + + + // Now select the correct picture. This uses a matrix from uiFaceOneItem and uiFaceTwoItem (simple addition) + // the numbers on the outer border are used if that is the only item worn in that slot + // + // 21 42 63 84 + // face slot 1 \ slot 2 gas mask | NV goggles | sun goggles | extended ear + // 1 gas mask -- 43 64 85 + // 2 NV goggles 23 -- -- 86 + // 3 sun goggles 24 -- -- 87 + // 4 extended ear 25 46 67 -- + // + // this matrix leaves room for expansion + // we only need a few of the matrix' values this time because we only show gas mask or NV goggles pictures + ubFaceItemsCombined = uiFaceItemOne + uiFaceItemTwo; + } + + // WANNE: Removed silversurfers limitation, because it is too complex for the players :) + // silversurfer: we don't want to display icons for gas mask or NV goggles because you can actually see the merc wearing the gear + // in case of gas mask together with NV we display the picture of the item in face slot 1 and the icon of the item + // in face slot 2 (if icons are allowed) + + //Type : 3 - gas mask ; 4 - NV googles + // gas mask only + + if (ubFaceItemsCombined == 1 || ubFaceItemsCombined == 21) + { + if (zNewFaceGear[uiFaceOne].Type == 3) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade); + } + else if (zNewFaceGear[uiFaceTwo].Type == 3) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade); + } + } + + // NV goggles only + if (ubFaceItemsCombined == 2 || ubFaceItemsCombined == 42) + { + if (zNewFaceGear[uiFaceOne].Type == 4) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade); + } + else if (zNewFaceGear[uiFaceTwo].Type == 4) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade); + } + } + + // NV goggles + gas mask + if (ubFaceItemsCombined == 23) + { + if (zNewFaceGear[uiFaceOne].Type == 4 && zNewFaceGear[uiFaceTwo].Type == 3) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade); + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade); + } + } + + // gas mask + NV goggles + if (ubFaceItemsCombined == 43) + { + if (zNewFaceGear[uiFaceOne].Type == 3 && zNewFaceGear[uiFaceTwo].Type == 4) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade); + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade); + } + } + + // gas mask + extended ear + if (ubFaceItemsCombined == 24 || ubFaceItemsCombined == 64) + { + if (zNewFaceGear[uiFaceOne].Type == 3) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade); + } + else if (zNewFaceGear[uiFaceTwo].Type == 3) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade); + } + } + + // gas mask + extended ear + if (ubFaceItemsCombined == 25 || ubFaceItemsCombined == 85) + { + if (zNewFaceGear[uiFaceOne].Type == 3) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade); + } + else if (zNewFaceGear[uiFaceTwo].Type == 3) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade); + } + } + + // NV goggles + extended ear + if (ubFaceItemsCombined == 46 || ubFaceItemsCombined == 86) + { + if (zNewFaceGear[uiFaceOne].Type == 4) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP, uiFaceShade); + } + else if (zNewFaceGear[uiFaceTwo].Type == 4) + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP, uiFaceShade); + } + } + } + + if (MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem > 0) + // dirty hack for IMPs because they don't have pictures for face gear + // && ( MercPtrs[ pFace->ubSoldierID ]->ubProfile < 51 || MercPtrs[ pFace->ubSoldierID ]->ubProfile > 56 ) + { + uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem; + + if (uiFaceItemOne != NONE) + { + if (uiFaceItemOne != NONE && zNewFaceGear[uiFaceItemOne].Type == 2) //front + { + DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceItemOne, isIMP, uiFaceShade); + } + } + } + + //------------------------------------end of tactical face gear----------------------------- + } + if ( (MercPtrs[pFace->ubSoldierID]->stats.bLife < CONSCIOUSNESS || MercPtrs[pFace->ubSoldierID]->flags.fDeadPanel ) ) { // Blit Closed eyes here! @@ -1707,34 +1913,6 @@ void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLE // Blit hatch! BltVideoObjectFromIndex( uiRenderBuffer, guiHATCH, 0, sFaceX, sFaceY, VO_BLT_SRCTRANSPARENCY, NULL ); } - - if ( !pFace->fDisabled && !pFace->fInvalidAnim ) - { - // Render text above here if that's what was asked for - if ( pFace->fDisplayTextOver != FACE_NO_TEXT_OVER ) - { - SetFont( TINYFONT1 ); - SetFontBackground( FONT_MCOLOR_BLACK ); - SetFontForeground( FONT_MCOLOR_WHITE ); - - SetFontDestBuffer( uiRenderBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE ); - - VarFindFontCenterCoordinates( sFaceX, sFaceY, pFace->usFaceWidth, pFace->usFaceHeight, TINYFONT1, &sFontX, &sFontY, pFace->zDisplayText ); - - if ( pFace->fDisplayTextOver == FACE_DRAW_TEXT_OVER ) - { - gprintfinvalidate( sFontX, sFontY, pFace->zDisplayText ); - mprintf( sFontX, sFontY, pFace->zDisplayText ); - } - else if ( pFace->fDisplayTextOver == FACE_ERASE_TEXT_OVER ) - { - gprintfRestore( sFontX, sFontY, pFace->zDisplayText ); - pFace->fDisplayTextOver = FACE_NO_TEXT_OVER; - } - - SetFontDestBuffer( FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE ); - } - } } // sevenfm: only show for alive soldiers, no face icons for big faces @@ -1760,15 +1938,6 @@ void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLE //------------------------------------Legion 2 by jazz-------------------------------- - UINT8 faceProfileId = gMercProfiles[MercPtrs[pFace->ubSoldierID]->ubProfile].ubFaceIndex; - BOOLEAN isIMP = FALSE; - - //IMP - if (gMercProfiles[MercPtrs[pFace->ubSoldierID]->ubProfile].Type == PROFILETYPE_IMP) - { - isIMP = TRUE; - } - // rewritten by silversurfer // this section chooses the icons for face gear if the ini setting "SHOW_TACTICAL_FACE_ICONS" is TRUE // and the merc actually wears something to be shown @@ -1883,187 +2052,6 @@ void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLE } } - if (gGameSettings.fOptions[TOPTION_SHOW_TACTICAL_FACE_GEAR]) - { - if (MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem > 0) - { - uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem; - - if (uiFaceItemOne != NONE && zNewFaceGear[uiFaceItemOne].Type == 1) //back - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceItemOne, isIMP); - } - } - - // this section chooses the pictures for gas mask and NV goggles if the ini setting "SHOW_TACTICAL_FACE_GEAR" is TRUE - // and the merc actually wears something to be shown - if (MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem + MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem > 0) - { - // WANNE: Removed the limitation - // silversurfer: don't overwrite icons if they shall be shown! - //if ( !gGameSettings.fOptions[ SHOW_TACTICAL_FACE_ICONS ] ) - { - uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem; - uiFaceItemTwo = MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem; - - uiFaceOne = MercPtrs[pFace->ubSoldierID]->inv[HEAD1POS].usItem; - uiFaceTwo = MercPtrs[pFace->ubSoldierID]->inv[HEAD2POS].usItem; - - // check first face slot - if (uiFaceItemOne != NONE) - { - if (zNewFaceGear[uiFaceOne].Type == 3) - { - uiFaceItemOne = 1; - } - else if (zNewFaceGear[uiFaceOne].Type == 4) - { - uiFaceItemOne = 2; - } - else uiFaceItemOne = 0; - } - - // check second face slot - if (uiFaceItemTwo != NONE) - { - if (zNewFaceGear[uiFaceTwo].Type == 3) - { - uiFaceItemTwo = 21; - } - else if (zNewFaceGear[uiFaceTwo].Type == 4) - { - uiFaceItemTwo = 42; - } - else uiFaceItemTwo = 0; - } - - - // Now select the correct picture. This uses a matrix from uiFaceOneItem and uiFaceTwoItem (simple addition) - // the numbers on the outer border are used if that is the only item worn in that slot - // - // 21 42 63 84 - // face slot 1 \ slot 2 gas mask | NV goggles | sun goggles | extended ear - // 1 gas mask -- 43 64 85 - // 2 NV goggles 23 -- -- 86 - // 3 sun goggles 24 -- -- 87 - // 4 extended ear 25 46 67 -- - // - // this matrix leaves room for expansion - // we only need a few of the matrix' values this time because we only show gas mask or NV goggles pictures - ubFaceItemsCombined = uiFaceItemOne + uiFaceItemTwo; - } - - // WANNE: Removed silversurfers limitation, because it is too complex for the players :) - // silversurfer: we don't want to display icons for gas mask or NV goggles because you can actually see the merc wearing the gear - // in case of gas mask together with NV we display the picture of the item in face slot 1 and the icon of the item - // in face slot 2 (if icons are allowed) - - //Type : 3 - gas mask ; 4 - NV googles - // gas mask only - - if (ubFaceItemsCombined == 1 || ubFaceItemsCombined == 21) - { - if (zNewFaceGear[uiFaceOne].Type == 3) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP); - } - else if (zNewFaceGear[uiFaceTwo].Type == 3) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP); - } - } - - // NV goggles only - if (ubFaceItemsCombined == 2 || ubFaceItemsCombined == 42) - { - if (zNewFaceGear[uiFaceOne].Type == 4) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP); - } - else if (zNewFaceGear[uiFaceTwo].Type == 4) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP); - } - } - - // NV goggles + gas mask - if (ubFaceItemsCombined == 23) - { - if (zNewFaceGear[uiFaceOne].Type == 4 && zNewFaceGear[uiFaceTwo].Type == 3) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP); - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP); - } - } - - // gas mask + NV goggles - if (ubFaceItemsCombined == 43) - { - if (zNewFaceGear[uiFaceOne].Type == 3 && zNewFaceGear[uiFaceTwo].Type == 4) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP); - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP); - } - } - - // gas mask + extended ear - if (ubFaceItemsCombined == 24 || ubFaceItemsCombined == 64) - { - if (zNewFaceGear[uiFaceOne].Type == 3) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP); - } - else if (zNewFaceGear[uiFaceTwo].Type == 3) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP); - } - } - - // gas mask + extended ear - if (ubFaceItemsCombined == 25 || ubFaceItemsCombined == 85) - { - if (zNewFaceGear[uiFaceOne].Type == 3) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP); - } - else if (zNewFaceGear[uiFaceTwo].Type == 3) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP); - } - } - - // NV goggles + extended ear - if (ubFaceItemsCombined == 46 || ubFaceItemsCombined == 86) - { - if (zNewFaceGear[uiFaceOne].Type == 4) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceOne, isIMP); - } - else if (zNewFaceGear[uiFaceTwo].Type == 4) - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceTwo, isIMP); - } - } - } - - if (MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem > 0) - // dirty hack for IMPs because they don't have pictures for face gear - // && ( MercPtrs[ pFace->ubSoldierID ]->ubProfile < 51 || MercPtrs[ pFace->ubSoldierID ]->ubProfile > 56 ) - { - uiFaceItemOne = MercPtrs[pFace->ubSoldierID]->inv[HELMETPOS].usItem; - - if (uiFaceItemOne != NONE) - { - if (uiFaceItemOne != NONE && zNewFaceGear[uiFaceItemOne].Type == 2) //front - { - DoRightIcon_FaceGear(uiRenderBuffer, pFace, sFaceX, sFaceY, bNumRightIcons_legion, faceProfileId, uiFaceItemOne, isIMP); - } - } - } - - //------------------------------------end of tactical face gear----------------------------- - } - // If blind... if (MercPtrs[pFace->ubSoldierID]->bBlindedCounter > 0) { @@ -2542,6 +2530,37 @@ void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLE } } } + + if (!(pFace->uiFlags & FACE_INACTIVE_HANDLED_ELSEWHERE) || fUseExternBuffer) + { + if (!pFace->fDisabled && !pFace->fInvalidAnim) + { + // Render text above here if that's what was asked for + if (pFace->fDisplayTextOver != FACE_NO_TEXT_OVER) + { + SetFont(TINYFONT1); + SetFontBackground(FONT_MCOLOR_BLACK); + SetFontForeground(FONT_MCOLOR_WHITE); + + SetFontDestBuffer(uiRenderBuffer, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE); + + VarFindFontCenterCoordinates(sFaceX, sFaceY, pFace->usFaceWidth, pFace->usFaceHeight, TINYFONT1, &sFontX, &sFontY, pFace->zDisplayText); + + if (pFace->fDisplayTextOver == FACE_DRAW_TEXT_OVER) + { + gprintfinvalidate(sFontX, sFontY, pFace->zDisplayText); + mprintf(sFontX, sFontY, pFace->zDisplayText); + } + else if (pFace->fDisplayTextOver == FACE_ERASE_TEXT_OVER) + { + gprintfRestore(sFontX, sFontY, pFace->zDisplayText); + pFace->fDisplayTextOver = FACE_NO_TEXT_OVER; + } + + SetFontDestBuffer(FRAME_BUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, FALSE); + } + } + } } else { @@ -2601,10 +2620,13 @@ BOOLEAN RenderAutoFace( INT32 iFaceIndex ) // Check for disabled guy! CHECKF( pFace->fDisabled != TRUE ); + UINT32 uiFaceShade = FLASH_PORTRAIT_NOSHADE; + // Set shade if ( pFace->ubSoldierID != NOBODY ) { - SetFaceShade( MercPtrs[ pFace->ubSoldierID ], pFace, FALSE ); + uiFaceShade = GetFaceShade(MercPtrs[pFace->ubSoldierID], pFace, FALSE); + SetFaceShade(pFace, uiFaceShade); } // Blit face to save buffer! @@ -2620,7 +2642,7 @@ BOOLEAN RenderAutoFace( INT32 iFaceIndex ) } } - HandleRenderFaceAdjustments( pFace, FALSE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY ); + HandleRenderFaceAdjustments(pFace, FALSE, FALSE, 0, pFace->usFaceX, pFace->usFaceY, pFace->usEyesX, pFace->usEyesY, uiFaceShade); // Restore extern rect if ( pFace->uiAutoRestoreBuffer == guiSAVEBUFFER ) @@ -2664,9 +2686,11 @@ BOOLEAN ExternRenderFace( UINT32 uiBuffer, INT32 iFaceIndex, INT16 sX, INT16 sY // Here, any face can be rendered, even if disabled // Set shade + UINT32 uiFaceShade = FLASH_PORTRAIT_NOSHADE; if ( pFace->ubSoldierID != NOBODY ) { - SetFaceShade( MercPtrs[ pFace->ubSoldierID ], pFace , TRUE ); + uiFaceShade = GetFaceShade(MercPtrs[pFace->ubSoldierID], pFace, TRUE); + SetFaceShade(pFace, uiFaceShade); } // Blit face to save buffer! @@ -2674,7 +2698,7 @@ BOOLEAN ExternRenderFace( UINT32 uiBuffer, INT32 iFaceIndex, INT16 sX, INT16 sY GetFaceRelativeCoordinates( pFace, &usEyesX, &usEyesY, &usMouthX, &usMouthY ); - HandleRenderFaceAdjustments( pFace, FALSE, TRUE, uiBuffer, sX, sY, ( UINT16)( sX + usEyesX ), ( UINT16)( sY + usEyesY ) ); + HandleRenderFaceAdjustments(pFace, FALSE, TRUE, uiBuffer, sX, sY, (UINT16)(sX + usEyesX), ( UINT16)(sY + usEyesY), uiFaceShade); // Restore extern rect if ( uiBuffer == guiSAVEBUFFER ) From b68f206969e14c03a9c7deac2a45d84375a6fafa Mon Sep 17 00:00:00 2001 From: Marco Antonio Jaguaribe Costa Date: Sat, 7 Oct 2023 08:29:59 -0300 Subject: [PATCH 036/120] remove annoying warning on MSVC 19.37.32822 `register` keyword does exactly nothing: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5033?view=msvc-170 --- Tactical/BinaryHeap.hpp | 6 +++--- Tactical/DisplayCover.cpp | 16 ++++++++-------- Tactical/Items.cpp | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Tactical/BinaryHeap.hpp b/Tactical/BinaryHeap.hpp index 8d1697fe..c4b5df1b 100644 --- a/Tactical/BinaryHeap.hpp +++ b/Tactical/BinaryHeap.hpp @@ -102,7 +102,7 @@ public: return (returnHeap); } - int moveUp(register int index, KEY newKey) + int moveUp(int index, KEY newKey) { while (index > 1) { int current2 = index>>1;//divided by 2 @@ -120,7 +120,7 @@ public: int moveDown(int index, KEY currentKey) { - register int current2 = index+index; + int current2 = index+index; while (current2 < heapCount) { if (current2+1 < heapCount) { //choose child to possibly move @@ -314,7 +314,7 @@ insert: int findData(const T data) const { - register int current; + int current; for (current = heapCount-1; current > 0; --current) { if (BinaryHeap[current].data == data) { break; diff --git a/Tactical/DisplayCover.cpp b/Tactical/DisplayCover.cpp index 3d35841d..7d1a3676 100644 --- a/Tactical/DisplayCover.cpp +++ b/Tactical/DisplayCover.cpp @@ -373,7 +373,7 @@ BOOLEAN HasAdjTile( const INT32& ubX, const INT32& ubY, const INT32& ubZ ) void AddCoverObjectsToViewArea() { - register INT32 ubX, ubY, ubZ; + INT32 ubX, ubY, ubZ; BOOLEAN fChanged = FALSE; BOOLEAN fNightTime = NightTime( ); @@ -406,7 +406,7 @@ void RemoveCoverObjectsFromViewArea() return; // Go through the whole gCoverViewArea when removing cover objects. Otherwise we don't clean up tiles that are not in the viewport which results in an annoying visual bug. - register INT32 ubX, ubY, ubZ; + INT32 ubX, ubY, ubZ; BOOLEAN fChanged = FALSE; for ( ubX = 0; ubX < COVER_X_CELLS; ++ubX ) @@ -669,8 +669,8 @@ static void CalculateCoverFromEnemies() void CalculateCover() { - register INT32 ubX, ubY; - register INT8 ubZ; + INT32 ubX, ubY; + INT8 ubZ; SOLDIERTYPE* pSoldier; if (gusSelectedSoldier == NOBODY) @@ -1144,7 +1144,7 @@ void AddMinesObjectsToViewArea() if ( gsMaxCellY < 0 ) return; - register INT32 ubX, ubY, ubZ; + INT32 ubX, ubY, ubZ; BOOLEAN fChanged = FALSE; BOOLEAN fNightTime = NightTime( ); @@ -1503,7 +1503,7 @@ void AddTraitObjectsToViewArea() if ( gsMaxCellY < 0 ) return; - register INT32 ubX, ubY, ubZ; + INT32 ubX, ubY, ubZ; BOOLEAN fChanged = FALSE; BOOLEAN fNightTime = NightTime( ); @@ -1657,7 +1657,7 @@ void AddTrackerObjectsToViewArea( ) if ( gsMaxCellY < 0 ) return; - register INT32 ubX, ubY, ubZ; + INT32 ubX, ubY, ubZ; BOOLEAN fChanged = FALSE; BOOLEAN fNightTime = NightTime(); @@ -1731,7 +1731,7 @@ void CalculateFortify( ) if ( gsMaxCellY < 0 ) return; - register INT32 ubX, ubY, ubZ; + INT32 ubX, ubY, ubZ; BOOLEAN fChanged = FALSE; BOOLEAN fNightTime = NightTime( ); diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 8212c736..e61c326c 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -15271,7 +15271,7 @@ BOOLEAN HasItemFlag( UINT16 usItem, UINT64 aFlag ) // Flugente: get first item number that has this flag. Use with caution, as we search in all items BOOLEAN GetFirstItemWithFlag( UINT16* pusItem, UINT64 aFlag ) { - register UINT16 i; + UINT16 i; for ( i = 1; i < gMAXITEMS_READ; ++i ) { if ( HasItemFlag(i, aFlag) ) @@ -15537,7 +15537,7 @@ BOOLEAN GetFirstClothesItemWithSpecificData( UINT16* pusItem, PaletteRepID aPalV UINT32 bestclothestype = 999999; UINT16 bestitem = 0; - register UINT16 i; + UINT16 i; for ( i = 1; i < gMAXITEMS_READ; ++i ) { if ( Item[i].clothestype > 0 ) From b8a870df02183b89ce8e5ead39e1248f24ac20f4 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 7 Oct 2023 15:14:15 +0300 Subject: [PATCH 037/120] Reduce code duplication (#233) * Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY * Add direction utility function We have a lot of places in the code that calculate direction based on center cell coordinates, but lack a utility function for it similar to other direction methods. * Use utility function for calculating direction * Use ConvertGridNoToCenterCellXY * Use utility function for direction * Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY * Use ConvertGridNoToCenterCellXY instead of CenterX & CenterY * Remove CenterX & CenterY functions Use ConvertGridNoToCenterCellXY instead * Remove CenterX & CenterY calls from UB configuration * Address review feedback * Remove duplicate function ConvertGridNoToCenterCellXY and ConvertMapPosToWorldTileCenter do the exact same thing * Use PythSpacesAway instead of GetRangeFromGridNoDiff Both functions calculate the same thing * Remove GetRangeFromGridNoDiff * Remove calls to abs() The values end up being squared anyways making these unnecessary --- Multiplayer/client.cpp | 11 +- Strategic/Strategic Movement.cpp | 24 ++--- Strategic/strategicmap.cpp | 4 +- Tactical/Air Raid.cpp | 22 ++-- Tactical/Handle Items.cpp | 5 +- Tactical/Handle UI.cpp | 4 +- Tactical/Interface Dialogue.cpp | 14 ++- Tactical/Interface Items.cpp | 2 +- Tactical/Interface.cpp | 14 +-- Tactical/Items.cpp | 11 +- Tactical/Keys.cpp | 7 +- Tactical/LOS.cpp | 151 ++++++++++++++++------------ Tactical/Rotting Corpses.cpp | 14 +-- Tactical/ShopKeeper Interface.cpp | 4 +- Tactical/Soldier Add.cpp | 33 ++---- Tactical/Soldier Ani.cpp | 5 +- Tactical/Soldier Control.cpp | 55 ++++++---- Tactical/Soldier Control.h | 3 +- Tactical/Soldier Find.cpp | 28 +++--- Tactical/Soldier Tile.cpp | 3 +- Tactical/Tactical Save.cpp | 21 ++-- Tactical/UI Cursors.cpp | 24 +++-- Tactical/Vehicles.cpp | 8 +- Tactical/Weapons.cpp | 77 +++++++++----- Tactical/opplist.cpp | 10 +- TacticalAI/AIUtils.cpp | 12 +-- TacticalAI/Attacks.cpp | 9 +- TacticalAI/CreatureDecideAction.cpp | 6 +- TacticalAI/DecideAction.cpp | 54 +++++----- TileEngine/Explosion Control.cpp | 35 +++++-- TileEngine/Isometric Utils.cpp | 67 +----------- TileEngine/Isometric Utils.h | 13 +-- TileEngine/LightEffects.cpp | 5 +- TileEngine/SmokeEffects.cpp | 8 +- TileEngine/environment.cpp | 4 +- TileEngine/physics.cpp | 2 +- TileEngine/renderworld.cpp | 2 +- 37 files changed, 389 insertions(+), 382 deletions(-) diff --git a/Multiplayer/client.cpp b/Multiplayer/client.cpp index d66e0f8b..05803259 100644 --- a/Multiplayer/client.cpp +++ b/Multiplayer/client.cpp @@ -815,10 +815,8 @@ void recievePATH(RPCParameters *rpcParameters) SendGetNewSoldierPathEvent( pSoldier, SNetPath->sDestGridNo, SNetPath->ubNewState ); INT16 sCellX, sCellY; - - sCellX = CenterX( SNetPath->sAtGridNo ); - sCellY = CenterY( SNetPath->sAtGridNo ); - + ConvertGridNoToCenterCellXY(SNetPath->sAtGridNo, &sCellX, &sCellY); + if (( gAnimControl[ pSoldier->usAnimState ].uiFlags & ( ANIM_MOVING | ANIM_SPECIALMOVE ) ) && !(pSoldier->flags.fNoAPToFinishMove ) ) { } @@ -4251,8 +4249,7 @@ void UpdateSoldierFromNetwork (RPCParameters *rpcParameters) pSoldier->stats.bLife=SUpdateNetworkSoldier->bLife; INT16 sCellX, sCellY; - sCellX = CenterX( SUpdateNetworkSoldier->sAtGridNo ); - sCellY = CenterY( SUpdateNetworkSoldier->sAtGridNo ); + ConvertGridNoToCenterCellXY(SUpdateNetworkSoldier->sAtGridNo, &sCellX, &sCellY); if( pSoldier->sGridNo != SUpdateNetworkSoldier->sAtGridNo) { @@ -5281,4 +5278,4 @@ void ChatCallback( UINT8 ubResult ) void OpenChatMsgBox( void ) { DoChatBox((guiCurrentScreen == GAME_SCREEN? true : false),gzMPChatboxText[1],guiCurrentScreen,ChatCallback,NULL); -} \ No newline at end of file +} diff --git a/Strategic/Strategic Movement.cpp b/Strategic/Strategic Movement.cpp index cbabfed6..e8969d4f 100644 --- a/Strategic/Strategic Movement.cpp +++ b/Strategic/Strategic Movement.cpp @@ -1757,30 +1757,30 @@ void AddCorpsesToBloodcatLair( INT16 sSectorX, INT16 sSectorY ) Corpse.usFlags = ROTTING_CORPSE_FIND_SWEETSPOT_FROM_GRIDNO; // 1st gridno - Corpse.sGridNo = 14319; //dnl!!! - ConvertGridNoToXY( Corpse.sGridNo, &sXPos, &sYPos ); - Corpse.dXPos = (FLOAT)( CenterX( sXPos ) ); - Corpse.dYPos = (FLOAT)( CenterY( sYPos ) ); + Corpse.sGridNo = 14319; //dnl!!! + ConvertGridNoToCenterCellXY(Corpse.sGridNo, &sXPos, &sYPos); + Corpse.dXPos = (FLOAT)( sXPos ); + Corpse.dYPos = (FLOAT)( sYPos ); //Add the rotting corpse info to the sectors unloaded rotting corpse file AddRottingCorpseToUnloadedSectorsRottingCorpseFile( sSectorX, sSectorY, 0, &Corpse); // 2nd gridno - Corpse.sGridNo = 9835; //dnl!!! - ConvertGridNoToXY( Corpse.sGridNo, &sXPos, &sYPos ); - Corpse.dXPos = (FLOAT)( CenterX( sXPos ) ); - Corpse.dYPos = (FLOAT)( CenterY( sYPos ) ); + Corpse.sGridNo = 9835; //dnl!!! + ConvertGridNoToCenterCellXY(Corpse.sGridNo, &sXPos, &sYPos); + Corpse.dXPos = (FLOAT)(sXPos); + Corpse.dYPos = (FLOAT)(sYPos); //Add the rotting corpse info to the sectors unloaded rotting corpse file AddRottingCorpseToUnloadedSectorsRottingCorpseFile( sSectorX, sSectorY, 0, &Corpse); // 3rd gridno - Corpse.sGridNo = 11262; //dnl!!! - ConvertGridNoToXY( Corpse.sGridNo, &sXPos, &sYPos ); - Corpse.dXPos = (FLOAT)( CenterX( sXPos ) ); - Corpse.dYPos = (FLOAT)( CenterY( sYPos ) ); + Corpse.sGridNo = 11262; //dnl!!! + ConvertGridNoToCenterCellXY(Corpse.sGridNo, &sXPos, &sYPos); + Corpse.dXPos = (FLOAT)(sXPos); + Corpse.dYPos = (FLOAT)(sYPos); //Add the rotting corpse info to the sectors unloaded rotting corpse file AddRottingCorpseToUnloadedSectorsRottingCorpseFile( sSectorX, sSectorY, 0, &Corpse); diff --git a/Strategic/strategicmap.cpp b/Strategic/strategicmap.cpp index e1dd54c4..9fa2cff6 100644 --- a/Strategic/strategicmap.cpp +++ b/Strategic/strategicmap.cpp @@ -4773,8 +4773,8 @@ void DoneFadeOutAdjacentSector( ) curr->pSoldier->ubWaitActionToDo = 1; // OK, here we have been given a position, a gridno has been given to use as well.... sOldGridNo = curr->pSoldier->sGridNo; - sWorldX = CenterX( sGridNo ); - sWorldY = CenterY( sGridNo ); + ConvertGridNoToCenterCellXY(sGridNo, &sWorldX, &sWorldY); + curr->pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY ); if ( sGridNo != sOldGridNo ) { diff --git a/Tactical/Air Raid.cpp b/Tactical/Air Raid.cpp index 20ede367..120ad3d7 100644 --- a/Tactical/Air Raid.cpp +++ b/Tactical/Air Raid.cpp @@ -352,9 +352,8 @@ INT32 PickRandomLocationAtMinSpacesAway( INT32 sGridNo, INT16 sMinValue, INT16 s DebugMsg(TOPIC_JA2,DBG_LEVEL_3,"PickRandomLocationAtMinSpacesAway"); - sX = CenterX( sGridNo ); - sY = CenterY( sGridNo ); - + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); + while(TileIsOutOfBounds(sNewGridNo)) { sNewX = sX + sMinValue + (INT16)Random( sRandomVar ); @@ -596,8 +595,7 @@ void BeginBombing( ) sGridNo = PickRandomLocationAtMinSpacesAway( gsDiveTargetLocation , 300, 200 ); // Save X, y: - gsDiveX = CenterX( sGridNo ); - gsDiveY = CenterY( sGridNo ); + ConvertGridNoToCenterCellXY(sGridNo, &gsDiveX, &gsDiveY); RESETTIMECOUNTER( giTimerAirRaidUpdate, RAID_DELAY ); @@ -657,8 +655,7 @@ void BeginDive( ) sGridNo = PickRandomLocationAtMinSpacesAway( gsDiveTargetLocation, 300, 200 ); // Save X, y: - gsDiveX = CenterX( sGridNo ); - gsDiveY = CenterY( sGridNo ); + ConvertGridNoToCenterCellXY(sGridNo, &gsDiveX, &gsDiveY); RESETTIMECOUNTER( giTimerAirRaidUpdate, RAID_DELAY ); giNumTurnsSinceDiveStarted = 0; @@ -760,8 +757,7 @@ void DoDive( ) DebugMsg(TOPIC_JA2,DBG_LEVEL_3,"DoDive: move towards target"); // Move Towards target.... - sTargetX = CenterX( gsDiveTargetLocation ); - sTargetY = CenterY( gsDiveTargetLocation ); + ConvertGridNoToCenterCellXY(gsDiveTargetLocation, &sTargetX, &sTargetY); // Determine deltas dDeltaX = (FLOAT)( sTargetX - gsDiveX ); @@ -886,7 +882,7 @@ void DoBombing( ) INT16 sRange; INT32 sGridNo, sOldGridNo, sBombGridNo; - INT16 sTargetX, sTargetY; + INT16 sTargetX, sTargetY, sBombX, sBombY; UINT16 usItem; INT16 sStrafeX, sStrafeY; FLOAT dDeltaX, dDeltaY, dAngle, dDeltaXPos, dDeltaYPos; @@ -933,8 +929,7 @@ void DoBombing( ) RESETTIMECOUNTER( giTimerAirRaidUpdate, RAID_DELAY ); // Move Towards target.... - sTargetX = CenterX( gsDiveTargetLocation ); - sTargetY = CenterY( gsDiveTargetLocation ); + ConvertGridNoToCenterCellXY(gsDiveTargetLocation, &sTargetX, &sTargetY); // Determine deltas dDeltaX = (FLOAT)( sTargetX - gsDiveX ); @@ -1002,7 +997,8 @@ void DoBombing( ) } // Drop bombs... - InternalIgniteExplosion( NOBODY, CenterX( sBombGridNo ), CenterY( sBombGridNo ), 0, sBombGridNo, usItem, fLocate , (UINT8)IsRoofPresentAtGridNo( sBombGridNo ) ); + ConvertGridNoToCenterCellXY(sBombGridNo, &sBombX, &sBombY); + InternalIgniteExplosion( NOBODY, sBombX, sBombY, 0, sBombGridNo, usItem, fLocate , (UINT8)IsRoofPresentAtGridNo( sBombGridNo ) ); } diff --git a/Tactical/Handle Items.cpp b/Tactical/Handle Items.cpp index a865d703..6eb448ad 100644 --- a/Tactical/Handle Items.cpp +++ b/Tactical/Handle Items.cpp @@ -2187,7 +2187,7 @@ void HandleSoldierThrowItem( SOLDIERTYPE *pSoldier, INT32 sGridNo ) pSoldier->usPendingAnimation = LOB_ITEM; } // Draw item depending on distance from buddy - else if ( GetRangeFromGridNoDiff( sGridNo, pSoldier->sGridNo ) < MIN_LOB_RANGE ) + else if (PythSpacesAway( sGridNo, pSoldier->sGridNo ) < MIN_LOB_RANGE ) { //ddd maybe need to add check for throwing item class - grenade if( (pSoldier->pThrowParams->ubActionCode == THROW_ARM_ITEM) && @@ -5919,8 +5919,7 @@ void SetOffBoobyTrap( ITEM_POOL * pItemPool ) if ( pItemPool ) { INT16 sX, sY; - sX = CenterX( pItemPool->sGridNo ); - sY = CenterY( pItemPool->sGridNo ); + ConvertGridNoToCenterCellXY(pItemPool->sGridNo, &sX, &sY); IgniteExplosion( NOBODY, sX, sY, (INT16) (gpWorldLevelData[pItemPool->sGridNo].sHeight + pItemPool->bRenderZHeightAboveLevel), pItemPool->sGridNo, MINI_GRENADE, 0 ); RemoveItemFromPool( pItemPool->sGridNo, pItemPool->iItemIndex, pItemPool->ubLevel ); } diff --git a/Tactical/Handle UI.cpp b/Tactical/Handle UI.cpp index 86a50e13..e4243381 100644 --- a/Tactical/Handle UI.cpp +++ b/Tactical/Handle UI.cpp @@ -5619,7 +5619,7 @@ UINT32 UIHandleTOnTerrain( UI_EVENT *pUIEvent ) sTargetGridNo = MercPtrs[ ubTargID ]->sGridNo; } - uiRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, sTargetGridNo ); + uiRange = PythSpacesAway( pSoldier->sGridNo, sTargetGridNo ); if ( uiRange <= NPC_TALK_RADIUS ) @@ -6610,7 +6610,7 @@ BOOLEAN HandleTalkInit( ) } // Check distance - uiRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, usMapPos ); + uiRange = PythSpacesAway( pSoldier->sGridNo, usMapPos ); // Double check path if ( GetCivType( pTSoldier ) != CIV_TYPE_NA ) diff --git a/Tactical/Interface Dialogue.cpp b/Tactical/Interface Dialogue.cpp index 00e4334a..d805af37 100644 --- a/Tactical/Interface Dialogue.cpp +++ b/Tactical/Interface Dialogue.cpp @@ -1827,7 +1827,7 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum EXITGRID ExitGrid; INT32 iRandom = 0; UINT8 ubMineIndex; - + INT16 sX, sY, sX2, sY2; pSoldier2 = NULL; //ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Handling %s, action %d at %ld", gMercProfiles[ ubTargetNPC ].zNickname, usActionCode, GetJA2Clock() ); @@ -1840,7 +1840,9 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum if (pSoldier && pSoldier2) { // see if we are facing this person - ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(pSoldier2->sGridNo),CenterY(pSoldier2->sGridNo)); + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + ConvertGridNoToCenterCellXY(pSoldier2->sGridNo, &sX2, &sY2); + ubDesiredMercDir = atan8(sX, sY, sX2, sY2); // if not already facing in that direction, if (pSoldier->ubDirection != ubDesiredMercDir) { @@ -2317,7 +2319,9 @@ void HandleNPCDoAction( UINT8 ubTargetNPC, UINT16 usActionCode, UINT8 ubQuoteNum if (!TileIsOutOfBounds(sGridNo)) { // see if we are facing this person - ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sGridNo),CenterY(sGridNo)); + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + ConvertGridNoToCenterCellXY(sGridNo, &sX2, &sY2); + ubDesiredMercDir = atan8(sX, sY, sX2, sY2); // if not already facing in that direction, if (pSoldier->ubDirection != ubDesiredMercDir) { @@ -5632,7 +5636,9 @@ void HandleRaulBlowingHimselfUp() //blow himself up with, hmmm, lets say TNT. :) usItem = HAND_GRENADE; - IgniteExplosion( RAUL_UB, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, usItem, pSoldier->pathing.bLevel ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + IgniteExplosion( RAUL_UB, sX, sY, 0, pSoldier->sGridNo, usItem, pSoldier->pathing.bLevel ); SetJa25GeneralFlag( JA_GF__RAUL_BLOW_HIMSELF_UP ); } diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index 9b783204..b021c47a 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -9570,7 +9570,7 @@ BOOLEAN HandleItemPointerClick( INT32 usMapPos ) BOOLEAN ItemCursorInLobRange( INT32 usMapPos ) { // Draw item depending on distance from buddy - if ( GetRangeFromGridNoDiff( usMapPos, gpItemPointerSoldier->sGridNo ) > MIN_LOB_RANGE ) + if (PythSpacesAway( usMapPos, gpItemPointerSoldier->sGridNo ) > MIN_LOB_RANGE ) { return( FALSE ); } diff --git a/Tactical/Interface.cpp b/Tactical/Interface.cpp index 8ac35471..5ab36750 100644 --- a/Tactical/Interface.cpp +++ b/Tactical/Interface.cpp @@ -2478,14 +2478,16 @@ BOOLEAN DrawCTHIndicator() ////////////////////////////////// // Calculate Aperture - + INT16 sX, sY; // Calculate the center point of the shooter, in world coordinates. - FLOAT dStartX = (FLOAT) CenterX( gCTHDisplay.iShooterGridNo ); - FLOAT dStartY = (FLOAT) CenterY( gCTHDisplay.iShooterGridNo ); + ConvertGridNoToCenterCellXY(gCTHDisplay.iShooterGridNo, &sX, &sY); + FLOAT dStartX = (FLOAT) sX; + FLOAT dStartY = (FLOAT) sY; // Calculate the center point of the target, in world coordinates. - FLOAT dEndX = (FLOAT) CenterX( gCTHDisplay.iTargetGridNo ); - FLOAT dEndY = (FLOAT) CenterY( gCTHDisplay.iTargetGridNo ); + ConvertGridNoToCenterCellXY(gCTHDisplay.iTargetGridNo, &sX, &sY); + FLOAT dEndX = (FLOAT) sX; + FLOAT dEndY = (FLOAT) sY; // Calculate a delta: the difference between the shooter and target. FLOAT dDeltaX = dEndX - dStartX; @@ -6647,4 +6649,4 @@ INT16 GetBackgroundValue( UINT8 usProfile, UINT16 aNr ) } return 0; -} \ No newline at end of file +} diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index e61c326c..6e353552 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -9262,13 +9262,16 @@ void CheckEquipmentForDamage( SOLDIERTYPE *pSoldier, INT32 iDamage ) if (fBlowsUp) { // blow it up! + INT16 sX, sY; + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + if ( gTacticalStatus.ubAttackBusyCount ) { - IgniteExplosion( pSoldier->ubAttackerID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] ); + IgniteExplosion( pSoldier->ubAttackerID, sX, sY, 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] ); } else { - IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] ); + IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, pSoldier->inv[ bSlot ].usItem, pSoldier->pathing.bLevel, pSoldier->ubDirection, &pSoldier->inv[ bSlot ] ); } //ADB when something in a stack blows up the whole stack goes, so no need to worry about number of items @@ -9333,7 +9336,9 @@ BOOLEAN DamageItemOnGround( OBJECTTYPE * pObject, INT32 sGridNo, INT8 bLevel, IN if ( fBlowsUp ) { // OK, Ignite this explosion! - IgniteExplosion( ubOwner, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, pObject->usItem, bLevel, DIRECTION_IRRELEVANT, pObject ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); + IgniteExplosion( ubOwner, sX, sY, 0, sGridNo, pObject->usItem, bLevel, DIRECTION_IRRELEVANT, pObject ); // SANDRO - merc records if ( (pObject->fFlags & OBJECT_ARMED_BOMB) && ((*pObject)[0]->data.misc.ubBombOwner > 1) ) diff --git a/Tactical/Keys.cpp b/Tactical/Keys.cpp index b5e9c0c3..b8dc66e4 100644 --- a/Tactical/Keys.cpp +++ b/Tactical/Keys.cpp @@ -669,7 +669,9 @@ void HandleDoorTrap( SOLDIERTYPE * pSoldier, DOOR * pDoor ) { case EXPLOSION: // cause damage as a regular hand grenade - IgniteExplosion( NOBODY, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 25, pSoldier->sGridNo, HAND_GRENADE, 0 ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + IgniteExplosion( NOBODY, sX, sY, 25, pSoldier->sGridNo, HAND_GRENADE, 0 ); break; case SIREN: @@ -760,8 +762,7 @@ BOOLEAN AttemptToBlowUpLock(SOLDIERTYPE * pSoldier, DOOR * pDoor) sGridNo = pDoor->sGridNo; // Get sX, sy; - sX = CenterX(sGridNo); - sY = CenterY(sGridNo); + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); // Get Z position, based on orientation.... sZ = 20; diff --git a/Tactical/LOS.cpp b/Tactical/LOS.cpp index 1911493e..ac2605a3 100644 --- a/Tactical/LOS.cpp +++ b/Tactical/LOS.cpp @@ -2380,12 +2380,15 @@ INT32 SoldierToSoldierLineOfSightTest( SOLDIERTYPE * pStartSoldier, SOLDIERTYPE UINT8 ubNumberOfTiles = pBase->pDBStructureRef->pDBStructure->ubNumberOfTiles; INT32 sStructGridNo; + INT16 sX, sY, sX2, sY2; + ConvertGridNoToCenterCellXY(pStartSoldier->sGridNo, &sX, &sY); // loop through all tiles for (UINT8 ubLoop = BASE_TILE; ubLoop < ubNumberOfTiles; ubLoop++) { sStructGridNo = AddPosRelToBase(pBase->sGridNo, ppTile[ubLoop]); - if( LineOfSightTest( (FLOAT) CenterX( pStartSoldier->sGridNo ), (FLOAT) CenterY( pStartSoldier->sGridNo ), dStartZPos, (FLOAT) CenterX( sStructGridNo ), (FLOAT) CenterY( sStructGridNo ), dEndZPos, iTileSightLimit, bAware, fSmell, NULL, adjustForSight, cthCalc ) ) + ConvertGridNoToCenterCellXY(sStructGridNo, &sX2, &sY2); + if( LineOfSightTest( (FLOAT) sX, (FLOAT) sY, dStartZPos, (FLOAT) sX2, (FLOAT) sY2, dEndZPos, iTileSightLimit, bAware, fSmell, NULL, adjustForSight, cthCalc ) ) { return( TRUE ); } @@ -2393,14 +2396,18 @@ INT32 SoldierToSoldierLineOfSightTest( SOLDIERTYPE * pStartSoldier, SOLDIERTYPE return( FALSE ); } - return( LineOfSightTest( (FLOAT) CenterX( pStartSoldier->sGridNo ), (FLOAT) CenterY( pStartSoldier->sGridNo ), dStartZPos, (FLOAT) CenterX( pEndSoldier->sGridNo ), (FLOAT) CenterY( pEndSoldier->sGridNo ), dEndZPos, iTileSightLimit, bAware, fSmell, NULL, adjustForSight, cthCalc ) ); + INT16 sX, sY, sX2, sY2; + ConvertGridNoToCenterCellXY(pStartSoldier->sGridNo, &sX, &sY); + ConvertGridNoToCenterCellXY(pEndSoldier->sGridNo, &sX2, &sY2); + + return( LineOfSightTest( (FLOAT) sX, (FLOAT) sY, dStartZPos, (FLOAT) sX2, (FLOAT) sY2, dEndZPos, iTileSightLimit, bAware, fSmell, NULL, adjustForSight, cthCalc ) ); } INT32 SoldierToLocationWindowTest( SOLDIERTYPE * pStartSoldier, INT32 sEndGridNo ) { // figure out if there is a SINGLE window between the looker and target FLOAT dStartZPos, dEndZPos; - INT16 sXPos, sYPos; + INT16 sX, sY, sX2, sY2; INT32 sWindowGridNo = NOWHERE; INT32 iRet; @@ -2413,24 +2420,23 @@ INT32 SoldierToLocationWindowTest( SOLDIERTYPE * pStartSoldier, INT32 sEndGridNo dStartZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[pStartSoldier->sGridNo].sHeight ); dEndZPos = dStartZPos; - ConvertGridNoToXY( sEndGridNo, &sXPos, &sYPos ); - sXPos = sXPos * CELL_X_SIZE + (CELL_X_SIZE / 2); - sYPos = sYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2); + ConvertGridNoToCenterCellXY(pStartSoldier->sGridNo, &sX, &sY); + ConvertGridNoToCenterCellXY(sEndGridNo, &sX2, &sY2); //ADB changed from 255 to 511 to handle new LOS test // We don't want to consider distance limits here so pass in tile sight limit of 255( + 256) // and consider trees as little as possible - iRet = LineOfSightTest( (FLOAT) CenterX( pStartSoldier->sGridNo ), (FLOAT) CenterY( pStartSoldier->sGridNo ), dStartZPos, (FLOAT) sXPos, (FLOAT) sYPos, dEndZPos, 511, TRUE, FALSE, &sWindowGridNo ); + iRet = LineOfSightTest( (FLOAT) sX, (FLOAT) sY, dStartZPos, (FLOAT) sX2, (FLOAT) sY2, dEndZPos, 511, TRUE, FALSE, &sWindowGridNo ); return( sWindowGridNo ); } INT32 SoldierTo3DLocationLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32 sGridNo, INT8 bLevel, INT8 bCubeLevel, INT8 bAware, int iTileSightLimit, bool adjustForSight ) { - FLOAT dStartZPos, dEndZPos; - INT16 sXPos, sYPos; - UINT8 ubTargetID; - BOOLEAN fOk; + FLOAT dStartZPos, dEndZPos; + INT16 sX, sY, sX2, sY2; + UINT8 ubTargetID; + BOOLEAN fOk; CHECKF( pStartSoldier ); @@ -2457,9 +2463,6 @@ INT32 SoldierTo3DLocationLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32 sGr dEndZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[ sGridNo ].sHeight ); } - ConvertGridNoToXY( sGridNo, &sXPos, &sYPos ); - sXPos = sXPos * CELL_X_SIZE + (CELL_X_SIZE / 2); - sYPos = sYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2); if (iTileSightLimit == CALC_FROM_ALL_DIRS || iTileSightLimit == CALC_FROM_WANTED_DIR) { iTileSightLimit = pStartSoldier->GetMaxDistanceVisible( sGridNo, bLevel, iTileSightLimit ); @@ -2468,14 +2471,17 @@ INT32 SoldierTo3DLocationLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32 sGr iTileSightLimit = 255 + pStartSoldier->GetMaxDistanceVisible( sGridNo, bLevel, CALC_FROM_ALL_DIRS ); } - return( LineOfSightTest( (FLOAT) CenterX( pStartSoldier->sGridNo ), (FLOAT) CenterY( pStartSoldier->sGridNo ), dStartZPos, (FLOAT) sXPos, (FLOAT) sYPos, dEndZPos, iTileSightLimit, bAware, HasThermalOptics( pStartSoldier), NULL, adjustForSight ) ); + ConvertGridNoToCenterCellXY(pStartSoldier->sGridNo, &sX, &sY); + ConvertGridNoToCenterCellXY(sGridNo, &sX2, &sY2); + + return( LineOfSightTest( (FLOAT) sX, (FLOAT) sY, dStartZPos, (FLOAT) sX2, (FLOAT) sY2, dEndZPos, iTileSightLimit, bAware, HasThermalOptics( pStartSoldier), NULL, adjustForSight ) ); } INT32 SoldierToVirtualSoldierLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32 sGridNo, INT8 bLevel, INT8 bStance, INT8 bAware, int iTileSightLimit ) { - FLOAT dStartZPos, dEndZPos; - INT16 sXPos, sYPos; - BOOLEAN fOk; + FLOAT dStartZPos, dEndZPos; + INT16 endXPos, endYPos, startXPos, startYPos; + BOOLEAN fOk; CHECKF( pStartSoldier ); @@ -2504,10 +2510,6 @@ INT32 SoldierToVirtualSoldierLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32 } - ConvertGridNoToXY( sGridNo, &sXPos, &sYPos ); - sXPos = sXPos * CELL_X_SIZE + (CELL_X_SIZE / 2); - sYPos = sYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2); - if (iTileSightLimit == CALC_FROM_ALL_DIRS || iTileSightLimit == CALC_FROM_WANTED_DIR) { iTileSightLimit = pStartSoldier->GetMaxDistanceVisible( sGridNo, bLevel, iTileSightLimit ); } @@ -2515,13 +2517,15 @@ INT32 SoldierToVirtualSoldierLineOfSightTest( SOLDIERTYPE * pStartSoldier, INT32 iTileSightLimit = 255 + pStartSoldier->GetMaxDistanceVisible( sGridNo, bLevel, CALC_FROM_ALL_DIRS ); } - return( LineOfSightTest( (FLOAT) CenterX( pStartSoldier->sGridNo ), (FLOAT) CenterY( pStartSoldier->sGridNo ), dStartZPos, (FLOAT) sXPos, (FLOAT) sYPos, dEndZPos, iTileSightLimit, bAware, HasThermalOptics( pStartSoldier), NULL, false ) ); + ConvertGridNoToCenterCellXY(pStartSoldier->sGridNo, &startXPos, &startYPos); + ConvertGridNoToCenterCellXY(sGridNo, &endXPos, &endYPos); + return(LineOfSightTest((FLOAT)startXPos, (FLOAT)startYPos, dStartZPos, (FLOAT)endXPos, (FLOAT)endYPos, dEndZPos, iTileSightLimit, bAware, HasThermalOptics(pStartSoldier), NULL, false)); } INT32 LocationToLocationLineOfSightTest( INT32 sStartGridNo, INT8 bStartLevel, INT32 sEndGridNo, INT8 bEndLevel, INT8 bAware, int iTileSightLimit, FLOAT dStartPos, FLOAT dEndPos ) { - FLOAT dStartZPos, dEndZPos; - INT16 sStartXPos, sStartYPos, sEndXPos, sEndYPos; + FLOAT dStartZPos, dEndZPos; + INT16 sStartXPos, sStartYPos, sEndXPos, sEndYPos; // Bob: prevent access violation if (sStartGridNo < 0) { @@ -2544,19 +2548,11 @@ INT32 LocationToLocationLineOfSightTest( INT32 sStartGridNo, INT8 bStartLevel, I // add in ground height dStartZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[ sStartGridNo ].sHeight ); - ConvertGridNoToXY( sStartGridNo, &sStartXPos, &sStartYPos ); - sStartXPos = sStartXPos * CELL_X_SIZE + (CELL_X_SIZE / 2); - sStartYPos = sStartYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2); - // sevenfm: use height argument dEndZPos = dEndPos + bEndLevel * HEIGHT_UNITS; // add in ground height dEndZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[ sEndGridNo ].sHeight ); - ConvertGridNoToXY( sEndGridNo, &sEndXPos, &sEndYPos ); - sEndXPos = sEndXPos * CELL_X_SIZE + (CELL_X_SIZE / 2); - sEndYPos = sEndYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2); - if (iTileSightLimit == CALC_FROM_ALL_DIRS || iTileSightLimit == CALC_FROM_WANTED_DIR) { iTileSightLimit = MaxNormalDistanceVisible(); @@ -2565,6 +2561,10 @@ INT32 LocationToLocationLineOfSightTest( INT32 sStartGridNo, INT8 bStartLevel, I { iTileSightLimit = 255 + MaxNormalDistanceVisible(); } + + ConvertGridNoToCenterCellXY(sStartGridNo, &sStartXPos, &sStartYPos); + ConvertGridNoToCenterCellXY(sEndGridNo, &sEndXPos, &sEndYPos); + return( LineOfSightTest( (FLOAT)sStartXPos, (FLOAT)sStartYPos, dStartZPos, (FLOAT) sEndXPos, (FLOAT) sEndYPos, dEndZPos, iTileSightLimit, bAware, FALSE, NULL ) ); } @@ -2931,20 +2931,24 @@ BOOLEAN BulletHitMerc( BULLET * pBullet, STRUCTURE * pStructure, BOOLEAN fIntend // Flugente: we measure the distance of the bullet's location to the location of the soldier, and to the 2 gridnos his head and leg occupy // From this we can decide what body part was hit - FLOAT bodycenterX = (FLOAT)CenterX( pTarget->sGridNo ); - FLOAT bodycenterY = (FLOAT)CenterY( pTarget->sGridNo ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(pTarget->sGridNo, &sX, &sY); + FLOAT bodycenterX = (FLOAT) sX; + FLOAT bodycenterY = (FLOAT) sY; FLOAT difftobodycenter = sqrt( (bodycenterX - x) * (bodycenterX - x) + (bodycenterY - y) * (bodycenterY - y) ); INT32 viewdirectiongridno = NewGridNo( pTarget->sGridNo, DirectionInc( pTarget->ubDirection ) ); - FLOAT nextgridnocenterX = (FLOAT)CenterX( viewdirectiongridno ); - FLOAT nextgridnocenterY = (FLOAT)CenterY( viewdirectiongridno ); + ConvertGridNoToCenterCellXY(viewdirectiongridno, &sX, &sY); + FLOAT nextgridnocenterX = (FLOAT) sX; + FLOAT nextgridnocenterY = (FLOAT) sY; FLOAT difftonextgridno = sqrt( (nextgridnocenterX - x) * (nextgridnocenterX - x) + (nextgridnocenterY - y) * (nextgridnocenterY - y) ); INT32 oppositeviewdirectiongridno = NewGridNo( pTarget->sGridNo, DirectionInc( gOppositeDirection[pTarget->ubDirection] ) ); - FLOAT oppositenextgridnocenterX = (FLOAT)CenterX( oppositeviewdirectiongridno ); - FLOAT oppositenextgridnocenterY = (FLOAT)CenterY( oppositeviewdirectiongridno ); + ConvertGridNoToCenterCellXY(oppositeviewdirectiongridno, &sX, &sY); + FLOAT oppositenextgridnocenterX = (FLOAT) sX; + FLOAT oppositenextgridnocenterY = (FLOAT) sY; FLOAT difftooppositenextgridno = sqrt( (oppositenextgridnocenterX - x) * (oppositenextgridnocenterX - x) + (oppositenextgridnocenterY - y) * (oppositenextgridnocenterY - y) ); @@ -4319,8 +4323,9 @@ UINT8 CalcChanceToGetThrough( BULLET * pBullet ) UINT8 SoldierToSoldierChanceToGetThrough( SOLDIERTYPE * pStartSoldier, SOLDIERTYPE * pEndSoldier ) { - FLOAT dEndZPos; - BOOLEAN fOk; + INT16 sX, sY; + FLOAT dEndZPos; + BOOLEAN fOk; if (pStartSoldier == pEndSoldier) { @@ -4337,15 +4342,18 @@ UINT8 SoldierToSoldierChanceToGetThrough( SOLDIERTYPE * pStartSoldier, SOLDIERTY // set startsoldier's target ID ... need an ID stored in case this // is the AI calculating cover to a location where he might not be any more pStartSoldier->ubCTGTTargetID = pEndSoldier->ubID; - return( ChanceToGetThrough( pStartSoldier, (FLOAT) CenterX( pEndSoldier->sGridNo ), (FLOAT) CenterY( pEndSoldier->sGridNo ), dEndZPos ) ); + + ConvertGridNoToCenterCellXY(pEndSoldier->sGridNo, &sX, &sY); + return( ChanceToGetThrough( pStartSoldier, (FLOAT) sX, (FLOAT) sY, dEndZPos ) ); } UINT8 SoldierToSoldierBodyPartChanceToGetThrough( SOLDIERTYPE * pStartSoldier, SOLDIERTYPE * pEndSoldier, UINT8 ubAimLocation ) { // does like StS-CTGT but with a particular body part in mind - FLOAT dEndZPos; - BOOLEAN fOk; - UINT8 ubPosType; + INT16 sX, sY; + FLOAT dEndZPos; + BOOLEAN fOk; + UINT8 ubPosType; if (pStartSoldier == pEndSoldier) { @@ -4378,7 +4386,8 @@ UINT8 SoldierToSoldierBodyPartChanceToGetThrough( SOLDIERTYPE * pStartSoldier, S // set startsoldier's target ID ... need an ID stored in case this // is the AI calculating cover to a location where he might not be any more pStartSoldier->ubCTGTTargetID = pEndSoldier->ubID; - return( ChanceToGetThrough( pStartSoldier, (FLOAT) CenterX( pEndSoldier->sGridNo ), (FLOAT) CenterY( pEndSoldier->sGridNo ), dEndZPos ) ); + ConvertGridNoToCenterCellXY(pEndSoldier->sGridNo, &sX, &sY); + return( ChanceToGetThrough( pStartSoldier, (FLOAT) sX, (FLOAT) sY, dEndZPos ) ); } UINT8 SoldierToLocationChanceToGetThrough( SOLDIERTYPE * pStartSoldier, INT32 sGridNo, INT8 bLevel, INT8 bCubeLevel, UINT8 ubTargetID ) @@ -4423,9 +4432,7 @@ UINT8 SoldierToLocationChanceToGetThrough( SOLDIERTYPE * pStartSoldier, INT32 sG } dEndZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[sGridNo].sHeight ); - ConvertGridNoToXY( sGridNo, &sXPos, &sYPos ); - sXPos = sXPos * CELL_X_SIZE + (CELL_X_SIZE / 2); - sYPos = sYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2); + ConvertGridNoToCenterCellXY(sGridNo, &sXPos, &sYPos); // set startsoldier's target ID ... need an ID stored in case this // is the AI calculating cover to a location where he might not be any more @@ -4437,6 +4444,7 @@ UINT8 SoldierToLocationChanceToGetThrough( SOLDIERTYPE * pStartSoldier, INT32 sG UINT8 AISoldierToSoldierChanceToGetThrough( SOLDIERTYPE * pStartSoldier, SOLDIERTYPE * pEndSoldier ) { // Like a standard CTGT algorithm BUT fakes the start soldier at standing height + INT16 sX, sY; FLOAT dEndZPos; BOOLEAN fOk; UINT8 ubChance; @@ -4460,7 +4468,8 @@ UINT8 AISoldierToSoldierChanceToGetThrough( SOLDIERTYPE * pStartSoldier, SOLDIER // is the AI calculating cover to a location where he might not be any more pStartSoldier->ubCTGTTargetID = NOBODY; - ubChance = ChanceToGetThrough( pStartSoldier, (FLOAT) CenterX( pEndSoldier->sGridNo ), (FLOAT) CenterY( pEndSoldier->sGridNo ), dEndZPos ); + ConvertGridNoToCenterCellXY(pEndSoldier->sGridNo, &sX, &sY); + ubChance = ChanceToGetThrough( pStartSoldier, (FLOAT) sX, (FLOAT) sY, dEndZPos ); pStartSoldier->usAnimState = usTrueState; return( ubChance ); } @@ -4510,9 +4519,7 @@ UINT8 AISoldierToLocationChanceToGetThrough( SOLDIERTYPE * pStartSoldier, INT32 } dEndZPos += CONVERT_PIXELS_TO_HEIGHTUNITS( gpWorldLevelData[sGridNo].sHeight ); - ConvertGridNoToXY( sGridNo, &sXPos, &sYPos ); - sXPos = sXPos * CELL_X_SIZE + (CELL_X_SIZE / 2); - sYPos = sYPos * CELL_Y_SIZE + (CELL_Y_SIZE / 2); + ConvertGridNoToCenterCellXY(sGridNo, &sXPos, &sYPos); // set startsoldier's target ID ... need an ID stored in case this // is the AI calculating cover to a location where he might not be any more @@ -4788,6 +4795,7 @@ INT8 FireBulletGivenTargetNCTH( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, UINT8 ubSpreadIndex = 0; UINT16 usBulletFlags = 0; int n=0; + INT16 sXPos, sYPos; OBJECTTYPE* pObjAttHand = pFirer->GetUsedWeapon( &(pFirer->inv[pFirer->ubAttackingHand]) ); @@ -4799,8 +4807,9 @@ INT8 FireBulletGivenTargetNCTH( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, CalculateSoldierZPos( pFirer, FIRING_POS, &dStartZ ); - dStartX = (FLOAT) CenterX( pFirer->sGridNo ); - dStartY = (FLOAT) CenterY( pFirer->sGridNo ); + ConvertGridNoToCenterCellXY(pFirer->sGridNo, &sXPos, &sYPos); + dStartX = (FLOAT) sXPos; + dStartY = (FLOAT) sYPos; dDeltaX = dEndX - dStartX; dDeltaY = dEndY - dStartY; @@ -5279,6 +5288,7 @@ INT8 FireBulletGivenTarget( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOA UINT8 ubSpreadIndex = 0; UINT16 usBulletFlags = 0; int n=0; + INT16 sXPos, sYPos; OBJECTTYPE* pObjAttHand = pFirer->GetUsedWeapon( &(pFirer->inv[pFirer->ubAttackingHand]) ); @@ -5290,8 +5300,9 @@ INT8 FireBulletGivenTarget( SOLDIERTYPE * pFirer, FLOAT dEndX, FLOAT dEndY, FLOA CalculateSoldierZPos( pFirer, FIRING_POS, &dStartZ ); - dStartX = (FLOAT) CenterX( pFirer->sGridNo ); - dStartY = (FLOAT) CenterY( pFirer->sGridNo ); + ConvertGridNoToCenterCellXY(pFirer->sGridNo, &sXPos, &sYPos); + dStartX = (FLOAT) sXPos; + dStartY = (FLOAT) sYPos; dDeltaX = dEndX - dStartX; dDeltaY = dEndY - dStartY; @@ -5954,6 +5965,7 @@ INT8 FireBulletGivenTargetTrapOnly( SOLDIERTYPE* pThrower, OBJECTTYPE* pObj, INT UINT8 ubSpreadIndex = 0; UINT16 usBulletFlags = 0; int n=0; + INT16 sXPos, sYPos; UINT16 usItem = pObj->usItem; UINT8 ammotype = ( *pObj )[0]->data.gun.ubGunAmmoType; @@ -5962,8 +5974,9 @@ INT8 FireBulletGivenTargetTrapOnly( SOLDIERTYPE* pThrower, OBJECTTYPE* pObj, INT if ( AmmoTypes[ammotype].numberOfBullets > 1 ) fBuckshot = TRUE; - dStartX = (FLOAT) CenterX( gridno ); - dStartY = (FLOAT) CenterY( gridno ); + ConvertGridNoToCenterCellXY(gridno, &sXPos, &sYPos); + dStartX = (FLOAT) sXPos; + dStartY = (FLOAT) sYPos; dDeltaX = dEndX - dStartX; dDeltaY = dEndY - dStartY; @@ -6541,13 +6554,15 @@ INT8 FireBulletGivenTarget_NoObjectNoSoldier( UINT16 usItem, UINT8 ammotype, UIN UINT8 ubSpreadIndex = 0; UINT16 usBulletFlags = 0; int n = 0; - + INT16 sXPos, sYPos; + BOOLEAN fBuckshot = FALSE; if ( AmmoTypes[ammotype].numberOfBullets > 1 ) fBuckshot = TRUE; - dStartX = (FLOAT)CenterX( gridno ); - dStartY = (FLOAT)CenterY( gridno ); + ConvertGridNoToCenterCellXY(gridno, &sXPos, &sYPos); + dStartX = (FLOAT)sXPos; + dStartY = (FLOAT)sYPos; dDeltaX = dEndX - dStartX; dDeltaY = dEndY - dStartY; @@ -8537,8 +8552,10 @@ void AdjustTargetCenterPoint( SOLDIERTYPE *pShooter, INT32 iTargetGridNo, FLOAT CalculateSoldierZPos( pShooter, FIRING_POS, &dStartZ ); // Locate absolute center X,Y of the shooter - dStartX = (FLOAT) CenterX( pShooter->sGridNo ); - dStartY = (FLOAT) CenterY( pShooter->sGridNo ); + INT16 sXPos, sYPos; + ConvertGridNoToCenterCellXY(pShooter->sGridNo, &sXPos, &sYPos); + dStartX = (FLOAT) sXPos; + dStartY = (FLOAT) sYPos; //////////////////////////////////////////////////////////////////////////// // Calculate difference (Delta) between start and end point of bullet flight @@ -9157,8 +9174,10 @@ void CalcTargetMovementOffset( SOLDIERTYPE *pShooter, SOLDIERTYPE *pTarget, OBJE { // HEADROCK HAM 4: Hopefully the right spot for this: This soldier has no "old" coordinates, so just set them // to wherever he/she is currently standing. - pTarget->sOldXPos = CenterX( pTarget->sGridNo ); - pTarget->sOldYPos = CenterY( pTarget->sGridNo ); + INT16 sXPos, sYPos; + ConvertGridNoToCenterCellXY(pTarget->sGridNo, &sXPos, &sYPos); + pTarget->sOldXPos = sXPos; + pTarget->sOldYPos = sYPos; // Since movement is now nonexistent, break the formula here without adjusting coordinates. return; } diff --git a/Tactical/Rotting Corpses.cpp b/Tactical/Rotting Corpses.cpp index 35c4101b..2293bfa6 100644 --- a/Tactical/Rotting Corpses.cpp +++ b/Tactical/Rotting Corpses.cpp @@ -561,8 +561,7 @@ INT32 AddRottingCorpse( ROTTING_CORPSE_DEFINITION *pCorpseDef ) } else { - AniParams.sX = CenterX(pCorpse->def.sGridNo); - AniParams.sY = CenterY(pCorpse->def.sGridNo); + ConvertGridNoToCenterCellXY(pCorpse->def.sGridNo, &AniParams.sX, &AniParams.sY); } AniParams.sZ = (INT16)pCorpse->def.sHeightAdjustment; @@ -1588,8 +1587,7 @@ void VaporizeCorpse( INT32 sGridNo, INT8 asLevel, UINT16 usStructureID ) AniParams.sDelay = (INT16)( 80 ); AniParams.sStartFrame = 0; AniParams.uiFlags = ANITILE_CACHEDTILE | ANITILE_FORWARD; - AniParams.sX = CenterX( sBaseGridNo ); - AniParams.sY = CenterY( sBaseGridNo ); + ConvertGridNoToCenterCellXY(sBaseGridNo, &AniParams.sX, &AniParams.sY); AniParams.sZ = (INT16)pCorpse->def.sHeightAdjustment; strcpy( AniParams.zCachedFile, "TILECACHE\\GEN_BLOW.STI" ); @@ -2284,10 +2282,12 @@ BOOLEAN AddCorpseFromObject(OBJECTTYPE* pObj, INT32 sGridNo, INT8 bLevel ) Corpse.ubBodyType = REGMALE; } + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); + Corpse.sGridNo = sGridNo; - - Corpse.dXPos = CenterX(Corpse.sGridNo); - Corpse.dYPos = CenterY(Corpse.sGridNo); + Corpse.dXPos = sX; + Corpse.dYPos = sY; Corpse.sHeightAdjustment = 0; diff --git a/Tactical/ShopKeeper Interface.cpp b/Tactical/ShopKeeper Interface.cpp index 32af6e28..427a0fc5 100644 --- a/Tactical/ShopKeeper Interface.cpp +++ b/Tactical/ShopKeeper Interface.cpp @@ -776,7 +776,7 @@ BOOLEAN EnterShopKeeperInterface() else pShopkeeper = FindSoldierByProfileID( armsDealerInfo[gbSelectedArmsDealerID].ubShopKeeperID, FALSE ); - if ( GetRangeFromGridNoDiff( pSoldier->sGridNo, pShopkeeper->sGridNo ) > NPC_TALK_RADIUS ) + if (PythSpacesAway( pSoldier->sGridNo, pShopkeeper->sGridNo ) > NPC_TALK_RADIUS ) { //so now we know we are too far away to trade, so instead of just quitting, //either post a message or run to the guy like HandleTalkInit does @@ -6668,7 +6668,7 @@ BOOLEAN CanMercInteractWithSelectedShopkeeper( SOLDIERTYPE *pSoldier ) if ( SoldierTo3DLocationLineOfSightTest( pSoldier, sDestGridNo, bDestLevel, 3, TRUE, CALC_FROM_ALL_DIRS ) ) { // Get range to shopkeeper - uiRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, sDestGridNo ); + uiRange = PythSpacesAway( pSoldier->sGridNo, sDestGridNo ); // and is close enough to talk to the shopkeeper (use this define INSTEAD of PASSING_ITEM_DISTANCE_OKLIFE!) if ( uiRange <= NPC_TALK_RADIUS ) diff --git a/Tactical/Soldier Add.cpp b/Tactical/Soldier Add.cpp index 40c31c81..64a83a0c 100644 --- a/Tactical/Soldier Add.cpp +++ b/Tactical/Soldier Add.cpp @@ -1367,11 +1367,9 @@ void InternalSoldierInSectorSleep( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN usAnim = STANDING; } - // OK, look for sutable placement.... + // OK, look for suitable placement.... sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, usAnim, sGridNo, 5, &ubNewDirection, FALSE ); - - sWorldX = CenterX( sGoodGridNo ); - sWorldY = CenterY( sGoodGridNo ); + ConvertGridNoToCenterCellXY(sGoodGridNo, &sWorldX, &sWorldY); pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY ); @@ -1408,11 +1406,9 @@ void SoldierInSectorIncompaciated( SOLDIERTYPE *pSoldier, INT32 sGridNo ) return; } - // OK, look for sutable placement.... + // OK, look for suitable placement.... sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, STAND_FALLFORWARD_STOP, sGridNo, 5, &ubNewDirection, FALSE ); - - sWorldX = CenterX( sGoodGridNo ); - sWorldY = CenterY( sGoodGridNo ); + ConvertGridNoToCenterCellXY(sGoodGridNo, &sWorldX, &sWorldY); pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY ); @@ -1444,11 +1440,9 @@ void SoldierInSectorPatient( SOLDIERTYPE *pSoldier, INT32 sGridNo ) return; } - // OK, look for sutable placement.... + // OK, look for suitable placement.... sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, BEING_PATIENT, sGridNo, 5, &ubNewDirection, FALSE ); - - sWorldX = CenterX( sGoodGridNo ); - sWorldY = CenterY( sGoodGridNo ); + ConvertGridNoToCenterCellXY(sGoodGridNo, &sWorldX, &sWorldY); pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY ); @@ -1479,11 +1473,9 @@ void SoldierInSectorDoctor( SOLDIERTYPE *pSoldier, INT32 sGridNo ) return; } - // OK, look for sutable placement.... + // OK, look for suitable placement.... sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, BEING_DOCTOR, sGridNo, 5, &ubNewDirection, FALSE ); - - sWorldX = CenterX( sGoodGridNo ); - sWorldY = CenterY( sGoodGridNo ); + ConvertGridNoToCenterCellXY(sGoodGridNo, &sWorldX, &sWorldY); pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY ); @@ -1514,11 +1506,9 @@ void SoldierInSectorRepair( SOLDIERTYPE *pSoldier, INT32 sGridNo ) return; } - // OK, look for sutable placement.... + // OK, look for suitable placement.... sGoodGridNo = FindGridNoFromSweetSpotWithStructData( pSoldier, BEING_REPAIRMAN, sGridNo, 5, &ubNewDirection, FALSE ); - - sWorldX = CenterX( sGoodGridNo ); - sWorldY = CenterY( sGoodGridNo ); + ConvertGridNoToCenterCellXY(sGoodGridNo, &sWorldX, &sWorldY); pSoldier->EVENT_SetSoldierPosition( sWorldX, sWorldY ); @@ -1550,8 +1540,7 @@ void AddSoldierToSectorGridNo( SOLDIERTYPE *pSoldier, INT32 sGridNo, UINT8 ubDir DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("AddSoldierToSectorGridNo")); // Add merc to gridno - sWorldX = CenterX( sGridNo ); - sWorldY = CenterY( sGridNo ); + ConvertGridNoToCenterCellXY(sGridNo, &sWorldX, &sWorldY); // Set reserved location! pSoldier->sReservedMovementGridNo = NOWHERE; diff --git a/Tactical/Soldier Ani.cpp b/Tactical/Soldier Ani.cpp index e60f7bec..eda237d2 100644 --- a/Tactical/Soldier Ani.cpp +++ b/Tactical/Soldier Ani.cpp @@ -280,7 +280,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier ) INT16 sXPos, sYPos; //sNewGridNo = NewGridNo( pSoldier->sGridNo, (UINT16)DirectionInc( pSoldier->ubDirection ) ); - ConvertMapPosToWorldTileCenter( pSoldier->sTempNewGridNo, &sXPos, &sYPos ); + ConvertGridNoToCenterCellXY( pSoldier->sTempNewGridNo, &sXPos, &sYPos ); pSoldier->EVENT_SetSoldierPosition( (FLOAT)sXPos, (FLOAT)sYPos ); } @@ -717,8 +717,7 @@ BOOLEAN AdjustToNextAnimationFrame( SOLDIERTYPE *pSoldier ) // CODE: End Hop Fence // MOVE TO FORCASTED GRIDNO - sX = CenterX( pSoldier->sForcastGridno ); - sY = CenterY( pSoldier->sForcastGridno ); + ConvertGridNoToCenterCellXY(pSoldier->sForcastGridno, &sX, &sY); pSoldier->EVENT_InternalSetSoldierPosition( (FLOAT) sX, (FLOAT) sY, FALSE, FALSE, FALSE ); pSoldier->EVENT_SetSoldierDirection( gTwoCDirection[ pSoldier->ubDirection ] ); diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index d41c63a4..d99e31bd 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -5041,8 +5041,10 @@ void SOLDIERTYPE::EVENT_FireSoldierWeapon( INT32 sTargetGridNo ) } else if (!TileIsOutOfBounds(sTargetGridNo) && !GridNoOnScreen(sTargetGridNo)) { - INT16 sNewCenterWorldX = CenterX(sTargetGridNo); - INT16 sNewCenterWorldY = CenterY(sTargetGridNo); + INT16 sNewCenterWorldX; + INT16 sNewCenterWorldY; + ConvertGridNoToCenterCellXY(sTargetGridNo, &sNewCenterWorldX, &sNewCenterWorldY); + SetRenderCenter(sNewCenterWorldX, sNewCenterWorldY); // Plot new path! @@ -7359,7 +7361,7 @@ void SOLDIERTYPE::EVENT_InternalSetSoldierDestination( UINT16 usNewDirection, BO // Get dest gridno, convert to center coords sNewGridNo = NewGridNo( this->sGridNo, DirectionInc( (UINT8)usNewDirection ) ); - ConvertMapPosToWorldTileCenter( sNewGridNo, &sXPos, &sYPos ); + ConvertGridNoToCenterCellXY( sNewGridNo, &sXPos, &sYPos ); // Save new dest gridno, x, y this->pathing.sDestination = sNewGridNo; @@ -11544,7 +11546,7 @@ void SOLDIERTYPE::MoveMerc( FLOAT dMovementChange, FLOAT dAngle, BOOLEAN fCheckR { INT16 this_base_x = 0; INT16 this_base_y = 0; - ConvertMapPosToWorldTileCenter( this->sGridNo, &this_base_x, &this_base_y ); + ConvertGridNoToCenterCellXY( this->sGridNo, &this_base_x, &this_base_y ); dx = this->dXPos - this_base_x; dy = this->dYPos - this_base_y; @@ -11552,7 +11554,7 @@ void SOLDIERTYPE::MoveMerc( FLOAT dMovementChange, FLOAT dAngle, BOOLEAN fCheckR INT16 base_x = 0; INT16 base_y = 0; - ConvertMapPosToWorldTileCenter( gridnotouse, &base_x, &base_y ); + ConvertGridNoToCenterCellXY( gridnotouse, &base_x, &base_y ); pSoldier->EVENT_InternalSetSoldierPosition( base_x + dx, base_y + dy, FALSE, FALSE, FALSE ); } @@ -11586,27 +11588,33 @@ void SOLDIERTYPE::MoveMerc( FLOAT dMovementChange, FLOAT dAngle, BOOLEAN fCheckR // adjust both gridno and x,y coordinates if (sOldGridNo != this->sGridNo) { - CorpseDef.sGridNo = sOldGridNo; - CorpseDef.dXPos = CenterX(CorpseDef.sGridNo); - CorpseDef.dYPos = CenterY(CorpseDef.sGridNo); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sOldGridNo, &sX, &sY); + + CorpseDef.sGridNo = sOldGridNo; + CorpseDef.dXPos = sX; + CorpseDef.dYPos = sY; } else { // move corpse a bit INT16 this_base_x = 0; INT16 this_base_y = 0; - ConvertMapPosToWorldTileCenter(this->sGridNo, &this_base_x, &this_base_y); + ConvertGridNoToCenterCellXY(this->sGridNo, &this_base_x, &this_base_y); FLOAT dx = this->dXPos - this_base_x; FLOAT dy = this->dYPos - this_base_y; INT16 base_x = 0; INT16 base_y = 0; - ConvertMapPosToWorldTileCenter(pCorpse->def.sGridNo, &base_x, &base_y); + ConvertGridNoToCenterCellXY(pCorpse->def.sGridNo, &base_x, &base_y); + + INT16 sX, sY; + ConvertGridNoToCenterCellXY(pCorpse->def.sGridNo, &sX, &sY); CorpseDef.sGridNo = pCorpse->def.sGridNo; - CorpseDef.dXPos = CenterX(CorpseDef.sGridNo) + dx; - CorpseDef.dYPos = CenterY(CorpseDef.sGridNo) + dy; + CorpseDef.dXPos = sX + dx; + CorpseDef.dYPos = sY + dy; } CorpseDef.usFlags |= ROTTING_CORPSE_USE_XY_PROVIDED; @@ -11768,6 +11776,17 @@ UINT8 GetDirectionFromXY( INT16 sXPos, INT16 sYPos, SOLDIERTYPE *pSoldier ) return(atan8( sXPos2, sYPos2, sXPos, sYPos )); } +INT16 GetDirectionFromCenterCellXYGridNo(INT32 EndGridNo, INT32 StartGridNo) +{ + INT16 sXPos2, sYPos2; + INT16 sXPos, sYPos; + + ConvertGridNoToCenterCellXY(StartGridNo, &sXPos, &sYPos); + ConvertGridNoToCenterCellXY(EndGridNo, &sXPos2, &sYPos2); + + return(atan8(sXPos2, sYPos2, sXPos, sYPos)); +} + //#if 0 UINT8 atan8( INT16 sXPos, INT16 sYPos, INT16 sXPos2, INT16 sYPos2 ) @@ -12261,8 +12280,7 @@ void SOLDIERTYPE::ReviveSoldier( void ) this->BeginSoldierGetup( ); // Makesure center of tile - sX = CenterX( this->sGridNo ); - sY = CenterY( this->sGridNo ); + ConvertGridNoToCenterCellXY(this->sGridNo, &sX, &sY); this->EVENT_SetSoldierPosition( (FLOAT)sX, (FLOAT)sY ); @@ -13962,8 +13980,7 @@ void SOLDIERTYPE::EVENT_StopMerc( INT32 sGridNo, INT8 bDirection ) // MOVE GUY TO GRIDNO--- SHOULD BE THE SAME UNLESS IN MULTIPLAYER // Makesure center of tile - sX = CenterX( sGridNo ); - sY = CenterY( sGridNo ); + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); //Cancel pending events if ( !this->flags.fDelayedMovement ) @@ -15862,7 +15879,7 @@ BOOLEAN SOLDIERTYPE::SeemsLegit( UINT8 ubObserverID ) } UINT8 covertlevel = NUM_SKILL_TRAITS( this, COVERT_NT ); // our level in covert operations - INT32 distance = GetRangeFromGridNoDiff( this->sGridNo, pSoldier->sGridNo ); + INT32 distance = PythSpacesAway( this->sGridNo, pSoldier->sGridNo ); // if we are closer than this, our cover will always break if we do not have the skill // if we have the skill, our cover will blow if we dress up as a soldier, but not if we are dressed like a civilian @@ -20865,7 +20882,7 @@ void SOLDIERTYPE::CancelDrag() { INT16 base_x = 0; INT16 base_y = 0; - ConvertMapPosToWorldTileCenter(pSoldier->sGridNo, &base_x, &base_y); + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &base_x, &base_y); pSoldier->EVENT_InternalSetSoldierPosition(base_x, base_y, FALSE, FALSE, FALSE); } @@ -23199,7 +23216,7 @@ BOOLEAN SOLDIERTYPE::PlayerSoldierStartTalking( UINT8 ubTargetID, BOOLEAN fValid return(FALSE); } - uiRange = GetRangeFromGridNoDiff( this->sGridNo, pTSoldier->sGridNo ); + uiRange = PythSpacesAway( this->sGridNo, pTSoldier->sGridNo ); if ( uiRange > (NPC_TALK_RADIUS * 2) ) { diff --git a/Tactical/Soldier Control.h b/Tactical/Soldier Control.h index 5873618d..f461f30d 100644 --- a/Tactical/Soldier Control.h +++ b/Tactical/Soldier Control.h @@ -2204,7 +2204,8 @@ BOOLEAN GetDirectionChangeAmount( INT32 sGridNo, SOLDIERTYPE *pSoldier, UINT8 ui UINT8 GetDirectionFromGridNo( INT32 sGridNo, SOLDIERTYPE *pSoldier ); UINT8 atan8( INT16 sXPos, INT16 sYPos, INT16 sXPos2, INT16 sYPos2 ); UINT8 atan8FromAngle( DOUBLE dAngle ); -INT16 GetDirectionToGridNoFromGridNo( INT32 sGridNoDest, INT32 sGridNoSrc ); +INT16 GetDirectionToGridNoFromGridNo(INT32 sGridNoDest, INT32 sGridNoSrc); +INT16 GetDirectionFromCenterCellXYGridNo(INT32 EndGridNo, INT32 StartGridNo); // This function is now obsolete. Call ReduceAttackBusyCount instead. // void ReleaseSoldiersAttacker( SOLDIERTYPE *pSoldier ); diff --git a/Tactical/Soldier Find.cpp b/Tactical/Soldier Find.cpp index 6b9ada5f..c45b35c0 100644 --- a/Tactical/Soldier Find.cpp +++ b/Tactical/Soldier Find.cpp @@ -814,8 +814,7 @@ BOOLEAN SoldierLocationRelativeToScreen( INT32 sGridNo, UINT16 usReasonID, INT8 *puiScrollFlags = 0; - sX = CenterX( sGridNo ); - sY = CenterY( sGridNo ); + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); // Get screen coordinates for current position of soldier GetWorldXYAbsoluteScreenXY( (INT16)(sX/CELL_X_SIZE), (INT16)(sY/CELL_Y_SIZE), &sWorldX, &sWorldY); @@ -954,25 +953,28 @@ BOOLEAN FindRelativeSoldierPosition( SOLDIERTYPE *pSoldier, UINT16 *usFlags, INT // Then, depending on whether this is the gridno we are looking at, this will be head or legs if ( gGameExternalOptions.fAllowTargetHeadAndLegIfProne ) { - INT16 sWorldX, sWorldY; + INT16 sWorldX, sWorldY, sX, sY; GetMouseWorldCoords( &sWorldX, &sWorldY ); // Flugente: we measure the distance of the bullet's location to the location of the soldier, and to the 2 gridnos his head and leg occupy // From this we can decide what body part was hit - FLOAT bodycenterX = (FLOAT)CenterX( pSoldier->sGridNo ); - FLOAT bodycenterY = (FLOAT)CenterY( pSoldier->sGridNo ); + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + FLOAT bodycenterX = (FLOAT) sX; + FLOAT bodycenterY = (FLOAT) sY; FLOAT difftobodycenter = sqrt( (bodycenterX - sWorldX) * (bodycenterX - sWorldX) + (bodycenterY - sWorldY) * (bodycenterY - sWorldY) ); INT32 viewdirectiongridno = NewGridNo( pSoldier->sGridNo, DirectionInc( pSoldier->ubDirection ) ); - FLOAT nextgridnocenterX = (FLOAT)CenterX( viewdirectiongridno ); - FLOAT nextgridnocenterY = (FLOAT)CenterY( viewdirectiongridno ); + ConvertGridNoToCenterCellXY(viewdirectiongridno, &sX, &sY); + FLOAT nextgridnocenterX = (FLOAT) sX; + FLOAT nextgridnocenterY = (FLOAT) sY; FLOAT difftonextgridno = sqrt( (nextgridnocenterX - sWorldX) * (nextgridnocenterX - sWorldX) + (nextgridnocenterY - sWorldY) * (nextgridnocenterY - sWorldY) ); INT32 oppositeviewdirectiongridno = NewGridNo( pSoldier->sGridNo, DirectionInc( gOppositeDirection[pSoldier->ubDirection] ) ); - FLOAT oppositenextgridnocenterX = (FLOAT)CenterX( oppositeviewdirectiongridno ); - FLOAT oppositenextgridnocenterY = (FLOAT)CenterY( oppositeviewdirectiongridno ); + ConvertGridNoToCenterCellXY(oppositeviewdirectiongridno, &sX, &sY); + FLOAT oppositenextgridnocenterX = (FLOAT) sX; + FLOAT oppositenextgridnocenterY = (FLOAT) sY; FLOAT difftooppositenextgridno = sqrt( (oppositenextgridnocenterX - sWorldX) * (oppositenextgridnocenterX - sWorldX) + (oppositenextgridnocenterY - sWorldY) * (oppositenextgridnocenterY - sWorldY) ); @@ -1030,13 +1032,15 @@ UINT8 QuickFindSoldier( INT32 sGridNo ) void GetGridNoScreenPos( INT32 sGridNo, UINT8 ubLevel, INT16 *psScreenX, INT16 *psScreenY ) { - INT16 sScreenX, sScreenY; + INT16 sScreenX, sScreenY, sX, sY; FLOAT dOffsetX, dOffsetY; FLOAT dTempX_S, dTempY_S; + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); + // Get 'TRUE' merc position - dOffsetX = (FLOAT)( CenterX( sGridNo ) - gsRenderCenterX ); - dOffsetY = (FLOAT)( CenterY( sGridNo ) - gsRenderCenterY ); + dOffsetX = (FLOAT)( sX - gsRenderCenterX ); + dOffsetY = (FLOAT)( sY - gsRenderCenterY ); // OK, DONT'T ASK... CONVERSION TO PROPER Y NEEDS THIS... dOffsetX -= CELL_Y_SIZE; diff --git a/Tactical/Soldier Tile.cpp b/Tactical/Soldier Tile.cpp index b43c0e47..4a3d7037 100644 --- a/Tactical/Soldier Tile.cpp +++ b/Tactical/Soldier Tile.cpp @@ -738,8 +738,7 @@ BOOLEAN TeleportSoldier( SOLDIERTYPE *pSoldier, INT32 sGridNo, BOOLEAN fForce ) if ( NewOKDestination( pSoldier, sGridNo, TRUE, 0 ) || fForce ) { // TELEPORT TO THIS LOCATION! - sX = CenterX( sGridNo ); - sY = CenterY( sGridNo ); + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); pSoldier->EVENT_SetSoldierPosition( (FLOAT) sX, (FLOAT) sY ); pSoldier->pathing.sFinalDestination = sGridNo; diff --git a/Tactical/Tactical Save.cpp b/Tactical/Tactical Save.cpp index c58a3459..7a503670 100644 --- a/Tactical/Tactical Save.cpp +++ b/Tactical/Tactical Save.cpp @@ -1878,8 +1878,10 @@ BOOLEAN LoadRottingCorpsesFromTempCorpseFile( INT16 sMapX, INT16 sMapY, INT8 bMa def.sGridNo = gMapInformation.sWestGridNo; } //Recalculate the dx,dy info - def.dXPos = CenterX( def.sGridNo ); - def.dYPos = CenterY( def.sGridNo ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(def.sGridNo, &sX, &sY); + def.dXPos = sX; + def.dYPos = sY; // If not from loading a save.... if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) { @@ -2737,15 +2739,14 @@ BOOLEAN AddDeadSoldierToUnLoadedSector( INT16 sMapX, INT16 sMapY, UINT8 bMapZ, S memset( &Corpse, 0, sizeof( ROTTING_CORPSE_DEFINITION ) ); // Setup some values! - Corpse.ubBodyType = pSoldier->ubBodyType; - Corpse.sGridNo = sGridNo; + ConvertGridNoToCenterCellXY(sGridNo, &sXPos, &sYPos); - ConvertGridNoToXY( sGridNo, &sXPos, &sYPos ); - - Corpse.dXPos = (FLOAT)( CenterX( sXPos ) ); - Corpse.dYPos = (FLOAT)( CenterY( sYPos ) ); - Corpse.sHeightAdjustment = pSoldier->sHeightAdjustment; - Corpse.bVisible = TRUE; + Corpse.ubBodyType = pSoldier->ubBodyType; + Corpse.sGridNo = sGridNo; + Corpse.dXPos = (FLOAT)( sXPos ); + Corpse.dYPos = (FLOAT)( sYPos ); + Corpse.sHeightAdjustment = pSoldier->sHeightAdjustment; + Corpse.bVisible = TRUE; SET_PALETTEREP_ID ( Corpse.HeadPal, pSoldier->HeadPal ); SET_PALETTEREP_ID ( Corpse.VestPal, pSoldier->VestPal ); diff --git a/Tactical/UI Cursors.cpp b/Tactical/UI Cursors.cpp index b51cd4ff..241eb810 100644 --- a/Tactical/UI Cursors.cpp +++ b/Tactical/UI Cursors.cpp @@ -676,8 +676,12 @@ UINT8 HandleActivatedTargetCursor( SOLDIERTYPE *pSoldier, INT32 usMapPos, BOOLEA gCTHDisplay.iTargetGridNo = usMapPos; // Calculate distance to target - FLOAT dDeltaX = (FLOAT)(CenterX( pSoldier->sGridNo ) - CenterX( usMapPos )); - FLOAT dDeltaY = (FLOAT)(CenterY( pSoldier->sGridNo ) - CenterY( usMapPos )); + INT16 sX, sY, sXMap, sYMap; + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + ConvertGridNoToCenterCellXY(usMapPos, &sXMap, &sYMap); + + FLOAT dDeltaX = (FLOAT)( sX - sXMap ); + FLOAT dDeltaY = (FLOAT)( sY - sYMap ); FLOAT d2DDistance = sqrt((dDeltaX*dDeltaX)+(dDeltaY*dDeltaY)); CalcMagFactorSimple( pSoldier, d2DDistance, pSoldier->aiData.bShownAimTime, usMapPos ); @@ -782,8 +786,12 @@ UINT8 HandleActivatedTargetCursor( SOLDIERTYPE *pSoldier, INT32 usMapPos, BOOLEA gbCtHBurstCount = 0; // Calculate distance to target - FLOAT dDeltaX = (FLOAT)(CenterX( pSoldier->sGridNo ) - CenterX( usMapPos )); - FLOAT dDeltaY = (FLOAT)(CenterY( pSoldier->sGridNo ) - CenterY( usMapPos )); + INT16 sX, sY, sXMap, sYMap; + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + ConvertGridNoToCenterCellXY(usMapPos, &sXMap, &sYMap); + + FLOAT dDeltaX = (FLOAT)(sX - sXMap); + FLOAT dDeltaY = (FLOAT)(sY - sYMap); FLOAT d2DDistance = sqrt((dDeltaX*dDeltaX)+(dDeltaY*dDeltaY)); CalcMagFactorSimple( pSoldier, d2DDistance, pSoldier->aiData.bShownAimTime, usMapPos ); @@ -884,8 +892,12 @@ UINT8 HandleActivatedTargetCursor( SOLDIERTYPE *pSoldier, INT32 usMapPos, BOOLEA gCTHDisplay.iTargetGridNo = usMapPos; // Calculate distance to target - FLOAT dDeltaX = (FLOAT)(CenterX( pSoldier->sGridNo ) - CenterX( usMapPos )); - FLOAT dDeltaY = (FLOAT)(CenterY( pSoldier->sGridNo ) - CenterY( usMapPos )); + INT16 sX, sY, sXMap, sYMap; + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + ConvertGridNoToCenterCellXY(usMapPos, &sXMap, &sYMap); + + FLOAT dDeltaX = (FLOAT)(sX - sXMap); + FLOAT dDeltaY = (FLOAT)(sY - sYMap); FLOAT d2DDistance = sqrt((dDeltaX*dDeltaX)+(dDeltaY*dDeltaY)); CalcMagFactorSimple( pSoldier, d2DDistance, pSoldier->aiData.bShownAimTime, usMapPos ); diff --git a/Tactical/Vehicles.cpp b/Tactical/Vehicles.cpp index d67d18ae..d954d75a 100644 --- a/Tactical/Vehicles.cpp +++ b/Tactical/Vehicles.cpp @@ -1787,7 +1787,9 @@ BOOLEAN ExitVehicle( SOLDIERTYPE *pSoldier ) pSoldier->aiData.bOppList[ pVehicle->ubID ] = 1; // Add to sector.... - pSoldier->EVENT_SetSoldierPosition( CenterX( sGridNo ), CenterY( sGridNo ) ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + pSoldier->EVENT_SetSoldierPosition( sX, sY ); // anv: since now they can shoot it's important to set passenger to proper stance // namely, back to standing, because we set them to crouching when entering @@ -2064,7 +2066,9 @@ void HandleCriticalHitForVehicleInLocation( UINT8 ubID, INT16 sDmg, INT32 sGridN pVehicleList[ ubID ].fDestroyed = TRUE; // Explode vehicle... - IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, GREAT_BIG_EXPLOSION, 0 ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); + IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, GREAT_BIG_EXPLOSION, 0 ); if ( pSoldier != NULL ) { diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index 667f9be4..cdc60e02 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -1714,7 +1714,7 @@ void GetTargetWorldPositions( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo, FLOAT FLOAT dTargetZ; SOLDIERTYPE* pTargetSoldier = NULL; INT8 bStructHeight; - INT16 sXMapPos, sYMapPos; + INT16 sXMapPos, sYMapPos, sX, sY; UINT32 uiRoll; INT8 bTargetCubeLevel = 0; INT8 bTargetLevel = 0; @@ -1731,8 +1731,9 @@ void GetTargetWorldPositions( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo, FLOAT { // SAVE OPP ID pSoldier->ubOppNum = pTargetSoldier->ubID; - dTargetX = (FLOAT) CenterX( pTargetSoldier->sGridNo ); - dTargetY = (FLOAT) CenterY( pTargetSoldier->sGridNo ); + ConvertGridNoToCenterCellXY(pTargetSoldier->sGridNo, &sX, &sY); + dTargetX = (FLOAT) sX; + dTargetY = (FLOAT) sY; if (pSoldier->bAimShotLocation == AIM_SHOT_RANDOM) { uiRoll = PreRandom( 100 ); @@ -1773,9 +1774,11 @@ void GetTargetWorldPositions( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo, FLOAT if ( gGameExternalOptions.fAllowTargetHeadAndLegIfProne && gAnimControl[pTargetSoldier->usAnimState].ubHeight == ANIM_PRONE ) { INT32 viewdirectiongridno = NewGridNo( pTargetSoldier->sGridNo, DirectionInc( pTargetSoldier->ubDirection ) ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(viewdirectiongridno, &sX, &sY); - dTargetX = (0.3f * dTargetX + 0.7f * (FLOAT)CenterX( viewdirectiongridno )) / 1.0f; - dTargetY = (0.3f * dTargetY + 0.7f * (FLOAT)CenterY( viewdirectiongridno )) / 1.0f; + dTargetX = (0.3f * dTargetX + 0.7f * (FLOAT)sX) / 1.0f; + dTargetY = (0.3f * dTargetY + 0.7f * (FLOAT)sY) / 1.0f; } } break; @@ -1789,9 +1792,11 @@ void GetTargetWorldPositions( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo, FLOAT if ( gGameExternalOptions.fAllowTargetHeadAndLegIfProne && gAnimControl[pTargetSoldier->usAnimState].ubHeight == ANIM_PRONE ) { INT32 viewdirectiongridno = NewGridNo( pTargetSoldier->sGridNo, DirectionInc( gOppositeDirection[pTargetSoldier->ubDirection] ) ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(viewdirectiongridno, &sX, &sY); - dTargetX = (0.3f * dTargetX + 0.7f * (FLOAT)CenterX( viewdirectiongridno )) / 1.0f; - dTargetY = (0.3f * dTargetY + 0.7f * (FLOAT)CenterY( viewdirectiongridno )) / 1.0f; + dTargetX = (0.3f * dTargetX + 0.7f * (FLOAT)sX) / 1.0f; + dTargetY = (0.3f * dTargetY + 0.7f * (FLOAT)sY) / 1.0f; } } break; @@ -2718,11 +2723,14 @@ BOOLEAN UseGunNCTH( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo ) { if ( WillExplosiveWeaponFail( pSoldier, pObjHand ) ) { + INT16 sX, sY; + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + if ( Item[usUBItem].singleshotrocketlauncher ) { CreateItem( Item[usItemNum].discardedlauncheritem , (*pObjHand)[0]->data.objectStatus, pObjHand ); - // Flugente: why would we keep a piece of scrap in our ahnds in the first place? just drop it to the ground + // Flugente: why would we keep a piece of scrap in our hands in the first place? just drop it to the ground AddItemToPool( pSoldier->sGridNo, pObjHand, 1, pSoldier->pathing.bLevel, 0, -1 ); // Delete object @@ -2730,20 +2738,21 @@ BOOLEAN UseGunNCTH( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo ) DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 ); + if ( Item[usUBItem].usBuddyItem != 0 && Item[Item[usUBItem].usBuddyItem].usItemClass & IC_EXPLOSV ) { - IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, Item[usUBItem].usBuddyItem, pSoldier->pathing.bLevel ); + IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, Item[usUBItem].usBuddyItem, pSoldier->pathing.bLevel ); } else { - IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel ); + IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel ); } } else { DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("StructureHit: RPG7 item: %d, Ammo: %d", usUBItem , (*pObjHand)[0]->data.gun.usGunAmmoItem ) ); - IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, (*pObjHand)[0]->data.gun.usGunAmmoItem, pSoldier->pathing.bLevel ); + IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, (*pObjHand)[0]->data.gun.usGunAmmoItem, pSoldier->pathing.bLevel ); pSoldier->inv[pSoldier->ubAttackingHand ][0]->data.gun.usGunAmmoItem = NONE; } // Reduce again for attack end 'cause it has been incremented for a normal attack @@ -2893,8 +2902,8 @@ BOOLEAN UseGunNCTH( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo ) { sTempGridNo = NewGridNo(sTempGridNo, DirectionInc(pSoldier->ubDirection)); } - INT16 sX = CenterX(sTempGridNo); - INT16 sY = CenterY(sTempGridNo); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sTempGridNo, &sX, &sY); AniParams.sGridNo = pSoldier->sGridNo; AniParams.ubLevelID = ANI_TOPMOST_LEVEL; @@ -3643,6 +3652,9 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo ) { if ( WillExplosiveWeaponFail( pSoldier, pObjUsed ) ) { + INT16 sX, sY; + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + if ( Item[usUBItem].singleshotrocketlauncher ) { CreateItem( Item[usUBItem].discardedlauncheritem , (*pObjUsed)[0]->data.objectStatus, pObjUsed ); @@ -3655,20 +3667,21 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo ) DirtyMercPanelInterface( pSoldier, DIRTYLEVEL2 ); + if ( Item[usUBItem].usBuddyItem != 0 && Item[Item[usUBItem].usBuddyItem].usItemClass & IC_EXPLOSV ) { - IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel ); + IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel ); } else { - IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel ); + IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, C1, pSoldier->pathing.bLevel ); } } else { DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("StructureHit: RPG7 item: %d, Ammo: %d", usUBItem , (*pObjUsed)[0]->data.gun.usGunAmmoItem ) ); - IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, (*pObjUsed)[0]->data.gun.usGunAmmoItem, pSoldier->pathing.bLevel ); + IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, (*pObjUsed)[0]->data.gun.usGunAmmoItem, pSoldier->pathing.bLevel ); OBJECTTYPE * pLaunchable = FindLaunchableAttachment( pObjUsed, usUBItem ); if(pLaunchable) @@ -3708,8 +3721,8 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT32 sTargetGridNo ) { sTempGridNo = NewGridNo(sTempGridNo, DirectionInc(pSoldier->ubDirection)); } - INT16 sX = CenterX(sTempGridNo); - INT16 sY = CenterY(sTempGridNo); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sTempGridNo, &sX, &sY); AniParams.sGridNo = pSoldier->sGridNo; AniParams.ubLevelID = ANI_TOPMOST_LEVEL; @@ -5167,7 +5180,9 @@ BOOLEAN UseLauncher( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo ) // So we still should have ABC > 0 // Begin explosion due to failure... - IgniteExplosion( pSoldier->ubID, CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), 0, pSoldier->sGridNo, Launchable.usItem, pSoldier->pathing.bLevel ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + IgniteExplosion( pSoldier->ubID, sX, sY, 0, pSoldier->sGridNo, Launchable.usItem, pSoldier->pathing.bLevel ); // Reduce again for attack end 'cause it has been incremented for a normal attack // Nope, not anymore. @@ -5676,15 +5691,18 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN // HEADROCK HAM 5: Fragments fired by such weapons should not explode. if ( pBullet->fFragment == false) { + INT16 sX, sY; + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + if ( Item[usWeaponIndex].singleshotrocketlauncher ) { if ( Item[usWeaponIndex].usBuddyItem != 0 && Item[Item[usWeaponIndex].usBuddyItem].usItemClass & IC_EXPLOSV ) { - IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, Item[usWeaponIndex].usBuddyItem, bLevel, usDirection ); + IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, Item[usWeaponIndex].usBuddyItem, bLevel, usDirection ); } else { - IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, C1, bLevel, usDirection ); + IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, C1, bLevel, usDirection ); } } // changed too to use 2 flag to determine @@ -5692,7 +5710,7 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN //there shouldn't be a way to enter here with an UnderBarrel weapon, so retaining original code :JMich { DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("StructureHit: RPG7 item: %d, Ammo: %d",pAttacker->inv[HANDPOS].usItem , pAttacker->inv[HANDPOS][0]->data.gun.usGunAmmoItem ) ); - IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, pAttacker->inv[pAttacker->ubAttackingHand][0]->data.gun.usGunAmmoItem, bLevel, usDirection ); + IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, pAttacker->inv[pAttacker->ubAttackingHand][0]->data.gun.usGunAmmoItem, bLevel, usDirection ); //This is just to make multishot launchers work in semi auto. It's not really a permanent solution because it still doesn't allow autofire, but it will do for now. OBJECTTYPE * pLaunchable = FindLaunchableAttachment( &(pAttacker->inv[pAttacker->ubAttackingHand ]), pAttacker->inv[pAttacker->ubAttackingHand ].usItem ); @@ -5708,7 +5726,7 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN else if ( AmmoTypes[(*pObj)[0]->data.gun.ubGunAmmoType].explosionSize > 1) { // re-routed the Highexplosive value to define exposion type - IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, AmmoTypes[(*pObj)[0]->data.gun.ubGunAmmoType].highExplosive, bLevel, usDirection ); + IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, AmmoTypes[(*pObj)[0]->data.gun.ubGunAmmoType].highExplosive, bLevel, usDirection ); // pSoldier->inv[pSoldier->ubAttackingHand ][0]->data.gun.usGunAmmoItem = NONE; } } @@ -5726,7 +5744,9 @@ void StructureHit( INT32 iBullet, UINT16 usWeaponIndex, INT16 bWeaponStatus, UIN //FreeUpAttacker( ubAttackerID ); // HEADROCK HAM 5 TODO: Tank shell!! - IgniteExplosion( ubAttackerID, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, TANK_SHELL, bLevel, usDirection ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); + IgniteExplosion( ubAttackerID, sX, sY, 0, sGridNo, TANK_SHELL, bLevel, usDirection ); //FreeUpAttacker( (UINT8) ubAttackerID ); // Moved here to keep ABC >0 as long as possible @@ -6250,7 +6270,7 @@ UINT32 CalcNewChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTi // Basic defines SOLDIERTYPE * pTarget; INT32 iRange, iSightRange; //, minRange; - + INT16 sX, sY, sX2, sY2; UINT16 usInHand; OBJECTTYPE * pInHand; INT16 sDistVis, sDistVisNoScope; @@ -6270,8 +6290,11 @@ UINT32 CalcNewChanceToHitGun(SOLDIERTYPE *pSoldier, INT32 sGridNo, INT16 ubAimTi // calculate actual range (in units, 10 units = 1 tile) iRange = GetRangeInCellCoordsFromGridNoDiff( pSoldier->sGridNo, sGridNo ); - FLOAT dDeltaX = (FLOAT)(CenterX( pSoldier->sGridNo ) - CenterX( sGridNo )); - FLOAT dDeltaY = (FLOAT)(CenterY( pSoldier->sGridNo ) - CenterY( sGridNo )); + + ConvertGridNoToCenterCellXY(pSoldier->sGridNo, &sX, &sY); + ConvertGridNoToCenterCellXY(sGridNo, &sX2, &sY2); + FLOAT dDeltaX = (FLOAT)( sX - sX2 ); + FLOAT dDeltaY = (FLOAT)( sY - sY2 ); FLOAT d2DDistance = sqrt((dDeltaX*dDeltaX)+(dDeltaY*dDeltaY)); // Find a target in the tile diff --git a/Tactical/opplist.cpp b/Tactical/opplist.cpp index 274413f9..2b8c8cc0 100644 --- a/Tactical/opplist.cpp +++ b/Tactical/opplist.cpp @@ -6130,10 +6130,8 @@ void ProcessNoise(UINT8 ubNoiseMaker, INT32 sGridNo, INT8 bLevel, UINT8 ubTerrTy { // ALL RIGHT! Passed all the tests, this listener hears this noise!!! HearNoise(pSoldier,ubSource,sGridNo,bLevel,ubEffVolume,ubNoiseType, (UINT8 *)&bSeen); - bHeard = TRUE; - - ubNoiseDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sGridNo),CenterY(sGridNo)); + ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sGridNo); // check the 'noise heard & reported' bit for that soldier & direction if ( ubNoiseType != NOISE_MOVEMENT || bTeam != OUR_TEAM || (pSoldier->aiData.bInterruptDuelPts != NO_INTERRUPT) || !(pSoldier->ubMovementNoiseHeard & (1 << ubNoiseDir) ) ) @@ -6441,8 +6439,7 @@ void HearNoise(SOLDIERTYPE *pSoldier, UINT8 ubNoiseMaker, INT32 sGridNo, INT8 bL // ignore muzzle flashes when turning head to see noise if ( ubNoiseType == NOISE_GUNFIRE && ubNoiseMaker != NOBODY && MercPtrs[ ubNoiseMaker ]->flags.fMuzzleFlash ) { - sNoiseX = CenterX(sGridNo); - sNoiseY = CenterY(sGridNo); + ConvertGridNoToCenterCellXY(sGridNo, &sNoiseX, &sNoiseY); bDirection = atan8(pSoldier->sX,pSoldier->sY,sNoiseX,sNoiseY); if ( pSoldier->ubDirection != bDirection && pSoldier->ubDirection != gOneCDirection[ bDirection ] && pSoldier->ubDirection != gOneCCDirection[ bDirection ] ) { @@ -6463,8 +6460,7 @@ void HearNoise(SOLDIERTYPE *pSoldier, UINT8 ubNoiseMaker, INT32 sGridNo, INT8 bL if (PythSpacesAway(pSoldier->sGridNo,sGridNo) <= sDistVisible ) { // just use the XXadjustedXX center of the gridno - sNoiseX = CenterX(sGridNo); - sNoiseY = CenterY(sGridNo); + ConvertGridNoToCenterCellXY(sGridNo, &sNoiseX, &sNoiseY); if (pSoldier->ubDirection != atan8(pSoldier->sX,pSoldier->sY,sNoiseX,sNoiseY)) { diff --git a/TacticalAI/AIUtils.cpp b/TacticalAI/AIUtils.cpp index 2f947a9f..8b42fb29 100644 --- a/TacticalAI/AIUtils.cpp +++ b/TacticalAI/AIUtils.cpp @@ -144,7 +144,7 @@ BOOLEAN ConsiderProne( SOLDIERTYPE * pSoldier ) } // We don't want to go prone if there is a nearby enemy ClosestKnownOpponent( pSoldier, &sOpponentGridNo, &bOpponentLevel ); - iRange = GetRangeFromGridNoDiff( pSoldier->sGridNo, sOpponentGridNo ); + iRange = PythSpacesAway( pSoldier->sGridNo, sOpponentGridNo ); if (iRange > 10) { return( TRUE ); @@ -2724,7 +2724,7 @@ INT32 CalcManThreatValue( SOLDIERTYPE *pEnemy, INT32 sMyGrid, UINT8 ubReduceForC else { // ADD 5% if man's already facing me - if (pEnemy->ubDirection == atan8(CenterX(pEnemy->sGridNo),CenterY(pEnemy->sGridNo),CenterX(sMyGrid),CenterY(sMyGrid))) + if (pEnemy->ubDirection == GetDirectionFromCenterCellXYGridNo(pEnemy->sGridNo, sMyGrid)) { iThreatValue += (iThreatValue / 20); } @@ -3619,13 +3619,13 @@ UINT8 CountFriendsInDirection( SOLDIERTYPE *pSoldier, INT32 sTargetGridNo ) CHECKF(pSoldier); - ubMyDir = atan8(CenterX(sTargetGridNo),CenterY(sTargetGridNo),CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo)); + ubMyDir = GetDirectionFromCenterCellXYGridNo(sTargetGridNo, pSoldier->sGridNo); // Run through each friendly. for ( UINT8 iCounter = gTacticalStatus.Team[ pSoldier->bTeam ].bFirstID ; iCounter <= gTacticalStatus.Team[ pSoldier->bTeam ].bLastID ; iCounter ++ ) { pFriend = MercPtrs[ iCounter ]; - ubFriendDir = atan8(CenterX(sTargetGridNo),CenterY(sTargetGridNo),CenterX(pFriend->sGridNo),CenterY(pFriend->sGridNo)); + ubFriendDir = GetDirectionFromCenterCellXYGridNo(sTargetGridNo, pFriend->sGridNo); if (pFriend != pSoldier && pFriend->bActive && @@ -4811,7 +4811,7 @@ BOOLEAN AnyCoverFromSpot( INT32 sSpot, INT8 bLevel, INT32 sThreatLoc, INT8 bThre return FALSE; } - ubDirection = atan8(CenterX(sSpot), CenterY(sSpot), CenterX(sThreatLoc), CenterY(sThreatLoc)); + ubDirection = GetDirectionFromCenterCellXYGridNo(sSpot, sThreatLoc); sCoverSpot = NewGridNo( sSpot, DirectionInc( ubDirection ) ); if ( TileIsOutOfBounds( sCoverSpot ) ) @@ -5001,7 +5001,7 @@ UINT8 AIDirection(INT32 sSpot1, INT32 sSpot2) return DIRECTION_IRRELEVANT; } - return atan8(CenterX(sSpot1), CenterY(sSpot1), CenterX(sSpot2), CenterY(sSpot2)); + return GetDirectionFromCenterCellXYGridNo(sSpot1, sSpot2); } BOOLEAN AICheckIsSniper(SOLDIERTYPE *pSoldier) diff --git a/TacticalAI/Attacks.cpp b/TacticalAI/Attacks.cpp index c2dc03cd..b3e9f183 100644 --- a/TacticalAI/Attacks.cpp +++ b/TacticalAI/Attacks.cpp @@ -783,7 +783,6 @@ BOOLEAN CloseEnoughForGrenadeToss( INT32 sGridNo, INT32 sGridNo2 ) { INT32 sTempGridNo; UINT8 ubDirection; - INT16 sXPos, sYPos, sXPos2, sYPos2; UINT8 ubMovementCost; if (sGridNo == sGridNo2 ) @@ -815,13 +814,7 @@ BOOLEAN CloseEnoughForGrenadeToss( INT32 sGridNo, INT32 sGridNo2 ) // so we can now do a loop safely sTempGridNo = sGridNo; - - sXPos = CenterX( sGridNo ); - sYPos = CenterY( sGridNo ); - sXPos2 = CenterX( sGridNo2 ); - sYPos2 = CenterY( sGridNo2 ); - ubDirection = atan8( sXPos, sYPos, sXPos2, sYPos2 ); - + ubDirection = GetDirectionFromCenterCellXYGridNo(sGridNo, sGridNo2); // For each step of the loop, we are checking for door or obstacle movement costs. If we // find we're blocked, then this is no good for grenade tossing! do diff --git a/TacticalAI/CreatureDecideAction.cpp b/TacticalAI/CreatureDecideAction.cpp index bb74c226..94fa1e18 100644 --- a/TacticalAI/CreatureDecideAction.cpp +++ b/TacticalAI/CreatureDecideAction.cpp @@ -481,7 +481,7 @@ INT8 CreatureDecideActionYellow( SOLDIERTYPE * pSoldier ) if (pSoldier->aiData.bMobility != CREATURE_IMMOBILE) { // determine direction from this soldier in which the noise lies - ubNoiseDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sNoiseGridNo),CenterY(sNoiseGridNo)); + ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sNoiseGridNo); // if soldier is not already facing in that direction, // and the noise source is close enough that it could possibly be seen @@ -849,7 +849,7 @@ INT8 CreatureDecideActionRed(SOLDIERTYPE *pSoldier, UINT8 ubUnconsciousOK) if (!TileIsOutOfBounds(sClosestOpponent)) { // determine direction from this soldier to the closest opponent - ubOpponentDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent)); + ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent); // if soldier is not already facing in that direction, // and the opponent is close enough that he could possibly be seen @@ -1410,7 +1410,7 @@ INT8 CreatureDecideActionBlack( SOLDIERTYPE * pSoldier ) } else if (GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints) // turn to face enemy { - bDirection = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent)); + bDirection = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent); // if we're not facing towards him if (pSoldier->ubDirection != bDirection && ValidCreatureTurn( pSoldier, bDirection ) ) diff --git a/TacticalAI/DecideAction.cpp b/TacticalAI/DecideAction.cpp index eb421ce8..e4a1e0ad 100644 --- a/TacticalAI/DecideAction.cpp +++ b/TacticalAI/DecideAction.cpp @@ -473,8 +473,7 @@ INT8 DecideActionSchedule( SOLDIERTYPE * pSoldier ) switch( pSoldier->bAIScheduleProgress ) { case 0: - sX = CenterX( pSoldier->sOffWorldGridNo ); - sY = CenterY( pSoldier->sOffWorldGridNo ); + ConvertGridNoToCenterCellXY(pSoldier->sOffWorldGridNo, &sX, &sY); pSoldier->EVENT_SetSoldierPosition( sX, sY ); pSoldier->bInSector = TRUE; MoveSoldierFromAwayToMercSlot( pSoldier ); @@ -565,7 +564,7 @@ INT8 DecideActionBoxerEnteringRing(SOLDIERTYPE *pSoldier) if (!TileIsOutOfBounds(sDesiredMercLoc)) { // see if we are facing this person - ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sDesiredMercLoc),CenterY(sDesiredMercLoc)); + ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sDesiredMercLoc); // if not already facing in that direction, if ( pSoldier->ubDirection != ubDesiredMercDir && pSoldier->InternalIsValidStance( ubDesiredMercDir, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) ) @@ -626,7 +625,7 @@ INT8 DecideActionNamedNPC( SOLDIERTYPE * pSoldier ) } // see if we are facing this person - ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sDesiredMercLoc),CenterY(sDesiredMercLoc)); + ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sDesiredMercLoc); // if not already facing in that direction, if (pSoldier->ubDirection != ubDesiredMercDir && pSoldier->InternalIsValidStance( ubDesiredMercDir, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) ) @@ -782,7 +781,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier) UINT8 ubRingDir; // face ring! - ubRingDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(CENTER_OF_RING),CenterY(CENTER_OF_RING)); + ubRingDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, CENTER_OF_RING); if ( gfTurnBasedAI || GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints ) { if ( pSoldier->ubDirection != ubRingDir ) @@ -966,7 +965,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier) if ( PythSpacesAway(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo) < 2 ) { // see if we are facing this person - UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo)); + UINT8 ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo); // if not already facing in that direction, if ( pSoldier->ubDirection != ubDesiredMercDir ) @@ -1495,8 +1494,7 @@ INT8 DecideActionGreen(SOLDIERTYPE *pSoldier) UINT8 ubNoiseDir; if (TileIsOutOfBounds(sNoiseGridNo) || - (ubNoiseDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sNoiseGridNo),CenterY(sNoiseGridNo)) - ) == pSoldier->ubDirection ) + ( ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sNoiseGridNo) ) == pSoldier->ubDirection ) { pSoldier->aiData.usActionData = PreRandom(8); @@ -1668,7 +1666,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier) if ( PythSpacesAway(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo) < 2 ) { // see if we are facing this person - UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo)); + UINT8 ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo); // if not already facing in that direction, if ( pSoldier->ubDirection != ubDesiredMercDir ) @@ -1721,7 +1719,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier) if ( PythSpacesAway(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo) < 2 ) { // see if we are facing this person - UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo)); + UINT8 ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo); // if not already facing in that direction, if ( pSoldier->ubDirection != ubDesiredMercDir ) @@ -1798,7 +1796,7 @@ INT8 DecideActionYellow(SOLDIERTYPE *pSoldier) //////////////////////////////////////////////////////////////////////////// // determine direction from this soldier in which the noise lies - ubNoiseDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sNoiseGridNo),CenterY(sNoiseGridNo)); + ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sNoiseGridNo); // if soldier is not already facing in that direction, // and the noise source is close enough that it could possibly be seen @@ -3293,7 +3291,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier) if ( PythSpacesAway(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo) < 2 ) { // see if we are facing this person - UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo)); + UINT8 ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo); // if not already facing in that direction, if ( pSoldier->ubDirection != ubDesiredMercDir ) @@ -3341,7 +3339,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier) if ( PythSpacesAway(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo) < 2 ) { // see if we are facing this person - UINT8 ubDesiredMercDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(MercPtrs[ubPerson]->sGridNo),CenterY(MercPtrs[ubPerson]->sGridNo)); + UINT8 ubDesiredMercDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, MercPtrs[ubPerson]->sGridNo); // if not already facing in that direction, if ( pSoldier->ubDirection != ubDesiredMercDir ) @@ -4521,7 +4519,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier) if (!TileIsOutOfBounds(sClosestOpponent)) { // determine direction from this soldier to the closest opponent - ubOpponentDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent)); + ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent); // if soldier is not already facing in that direction, // and the opponent is close enough that he could possibly be seen @@ -4625,7 +4623,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier) if (!TileIsOutOfBounds(sClosestDisturbance)) { - ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestDisturbance ), CenterY( sClosestDisturbance ) ); + ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestDisturbance); if ( pSoldier->ubDirection == ubOpponentDir ) { ubOpponentDir = (UINT8) PreRandom( NUM_WORLD_DIRECTIONS ); @@ -4768,7 +4766,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier) if (!gfTurnBasedAI || (GetAPsToReadyWeapon( pSoldier, READY_RIFLE_CROUCH ) + GetAPsToChangeStance( pSoldier, ANIM_CROUCH )) <= pSoldier->bActionPoints) { // determine direction from this soldier to the closest opponent - ubOpponentDir = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent)); + ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent); if (!WeaponReady(pSoldier) && pSoldier->ubDirection == ubOpponentDir && @@ -4802,7 +4800,7 @@ INT8 DecideActionRed(SOLDIERTYPE *pSoldier) if (!TileIsOutOfBounds(sClosestDisturbance)) { - ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestDisturbance ), CenterY( sClosestDisturbance ) ); + ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestDisturbance); if ( pSoldier->ubDirection != ubOpponentDir ) { if ( !gfTurnBasedAI || GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints ) @@ -6994,7 +6992,7 @@ L_NEWAIM: if(!TileIsOutOfBounds(pSoldier->sLastTarget)) sClosestOpponent = pSoldier->sLastTarget; pSoldier->aiData.bNextAction = AI_ACTION_CHANGE_FACING; - pSoldier->aiData.usNextActionData = atan8(CenterX(sBestCover),CenterY(sBestCover),CenterX(sClosestOpponent),CenterY(sClosestOpponent)); + pSoldier->aiData.usNextActionData = GetDirectionFromCenterCellXYGridNo(sBestCover, sClosestOpponent); } return(AI_ACTION_TAKE_COVER); } @@ -7088,7 +7086,7 @@ L_NEWAIM: // if we have a closest seen opponent if (!TileIsOutOfBounds(sClosestOpponent)) { - bDirection = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent)); + bDirection = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent); // if we're not facing towards him if (pSoldier->ubDirection != bDirection) @@ -7149,7 +7147,7 @@ L_NEWAIM: { if(!TileIsOutOfBounds(pSoldier->sLastTarget))//dnl ch58 150913 sClosestOpponent = pSoldier->sLastTarget; - bDirection = atan8(CenterX(pSoldier->sGridNo),CenterY(pSoldier->sGridNo),CenterX(sClosestOpponent),CenterY(sClosestOpponent)); + bDirection = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent); // if we're not facing towards him if ( pSoldier->ubDirection != bDirection && pSoldier->InternalIsValidStance( bDirection, gAnimControl[ pSoldier->usAnimState ].ubEndHeight ) ) @@ -7801,7 +7799,7 @@ INT8 ArmedVehicleDecideActionGreen( SOLDIERTYPE *pSoldier ) UINT8 ubNoiseDir; if ( TileIsOutOfBounds( sNoiseGridNo ) || - (ubNoiseDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sNoiseGridNo ), CenterY( sNoiseGridNo ) ) + (ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sNoiseGridNo) ) == pSoldier->ubDirection ) { @@ -7904,7 +7902,7 @@ INT8 ArmedVehicleDecideActionYellow( SOLDIERTYPE *pSoldier ) //////////////////////////////////////////////////////////////////////////// // determine direction from this soldier in which the noise lies - ubNoiseDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sNoiseGridNo ), CenterY( sNoiseGridNo ) ); + ubNoiseDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sNoiseGridNo); // if soldier is not already facing in that direction, // and the noise source is close enough that it could possibly be seen @@ -9153,7 +9151,7 @@ INT8 ArmedVehicleDecideActionRed( SOLDIERTYPE *pSoldier) if ( bHighestWatchLoc != -1 ) { // see if we need turn to face that location - ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( gsWatchedLoc[pSoldier->ubID][bHighestWatchLoc] ), CenterY( gsWatchedLoc[pSoldier->ubID][bHighestWatchLoc] ) ); + ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, gsWatchedLoc[pSoldier->ubID][bHighestWatchLoc]); // if soldier is not already facing in that direction, // and the opponent is close enough that he could possibly be seen @@ -9339,7 +9337,7 @@ INT8 ArmedVehicleDecideActionRed( SOLDIERTYPE *pSoldier) if ( !TileIsOutOfBounds( sClosestOpponent ) ) { // determine direction from this soldier to the closest opponent - ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestOpponent ), CenterY( sClosestOpponent ) ); + ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent); // if soldier is not already facing in that direction, // and the opponent is close enough that he could possibly be seen @@ -9384,7 +9382,7 @@ INT8 ArmedVehicleDecideActionRed( SOLDIERTYPE *pSoldier) if ( !TileIsOutOfBounds( sClosestDisturbance ) ) { - ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestDisturbance ), CenterY( sClosestDisturbance ) ); + ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestDisturbance); if ( pSoldier->ubDirection == ubOpponentDir ) { ubOpponentDir = (UINT8)PreRandom( NUM_WORLD_DIRECTIONS ); @@ -9435,7 +9433,7 @@ INT8 ArmedVehicleDecideActionRed( SOLDIERTYPE *pSoldier) if ( !TileIsOutOfBounds( sClosestDisturbance ) ) { - ubOpponentDir = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestDisturbance ), CenterY( sClosestDisturbance ) ); + ubOpponentDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestDisturbance); if ( pSoldier->ubDirection != ubOpponentDir ) { if ( !gfTurnBasedAI || GetAPsToLook( pSoldier ) <= pSoldier->bActionPoints ) @@ -10019,7 +10017,7 @@ INT8 ArmedVehicleDecideActionBlack( SOLDIERTYPE *pSoldier ) if ( gGameExternalOptions.fEnemyTanksCanMoveInTactical ) { // first get the direction, as we will need to pass that in to ShootingStanceChange - bDirection = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( BestAttack.sTarget ), CenterY( BestAttack.sTarget ) ); + bDirection = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, BestAttack.sTarget); // Change facing if ( pSoldier->ubDirection != bDirection && pSoldier->InternalIsValidStance( bDirection, gAnimControl[pSoldier->usAnimState].ubEndHeight ) ) @@ -10306,7 +10304,7 @@ INT8 ArmedVehicleDecideActionBlack( SOLDIERTYPE *pSoldier ) { if ( !TileIsOutOfBounds( pSoldier->sLastTarget ) )//dnl ch58 150913 sClosestOpponent = pSoldier->sLastTarget; - bDirection = atan8( CenterX( pSoldier->sGridNo ), CenterY( pSoldier->sGridNo ), CenterX( sClosestOpponent ), CenterY( sClosestOpponent ) ); + bDirection = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sClosestOpponent); // if we're not facing towards him if ( pSoldier->ubDirection != bDirection && pSoldier->InternalIsValidStance( bDirection, gAnimControl[pSoldier->usAnimState].ubEndHeight ) ) diff --git a/TileEngine/Explosion Control.cpp b/TileEngine/Explosion Control.cpp index 85df4d39..fac8bc3e 100644 --- a/TileEngine/Explosion Control.cpp +++ b/TileEngine/Explosion Control.cpp @@ -698,8 +698,7 @@ INT8 ExplosiveDamageStructureAtGridNo( STRUCTURE * pCurrent, STRUCTURE **ppNextC #endif // Get xy - sX = CenterX( sGridNo ); - sY = CenterY( sGridNo ); + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); // ATE: Continue if we are only looking for walls if ( fOnlyWalls && !( pCurrent->fFlags & STRUCTURE_WALLSTUFF ) ) @@ -1305,7 +1304,9 @@ INT8 ExplosiveDamageStructureAtGridNo( STRUCTURE * pCurrent, STRUCTURE **ppNextC // Make secondary explosion if eplosive.... if ( fExplosive ) { - InternalIgniteExplosion( ubOwner, CenterX( sBaseGridNo ), CenterY( sBaseGridNo ), 0, sBaseGridNo, STRUCTURE_EXPLOSION, FALSE, bLevel ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sBaseGridNo, &sX, &sY); + InternalIgniteExplosion( ubOwner, sX, sY, 0, sBaseGridNo, STRUCTURE_EXPLOSION, FALSE, bLevel ); } } @@ -1477,7 +1478,9 @@ void ExplosiveDamageGridNo( INT32 sGridNo, INT16 sWoundAmt, UINT32 uiDist, BOOLE } { - InternalIgniteExplosion( ubOwner, CenterX( sNewGridNo2 ), CenterY( sNewGridNo2 ), 0, sNewGridNo2, RDX, FALSE, bLevel ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sNewGridNo2, &sX, &sY); + InternalIgniteExplosion( ubOwner, sX, sY, 0, sNewGridNo2, RDX, FALSE, bLevel ); } fToBreak = TRUE; @@ -4163,7 +4166,10 @@ void HandleExplosionQueue( void ) // no preplaced (owner=NOBODY) tripwire with explosive attachments allowed if ( gGameExternalOptions.bAllowExplosiveAttachments && (*pObj)[0]->data.misc.ubBombOwner > 1 ) { - fAttFound=HandleAttachedExplosions( (UINT8) ((*pObj)[0]->data.misc.ubBombOwner - 2), CenterX( sGridNo ), CenterY( sGridNo ), 0, + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); + + fAttFound=HandleAttachedExplosions( (UINT8) ((*pObj)[0]->data.misc.ubBombOwner - 2), sX, sY, 0, sGridNo, (*pObj)[0]->data.misc.usBombItem, FALSE, ubLevel, (*pObj)[0]->data.ubDirection, pObj); } } @@ -4236,15 +4242,18 @@ void HandleExplosionQueue( void ) CheckForBuriedBombsAndRemoveFlags( sGridNo, ubLevel); // BOOM! + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); + // bomb objects only store the SIDE who placed the bomb! :-( if ( (*pObj)[0]->data.misc.ubBombOwner > 1 ) { - IgniteExplosion( (UINT8) ((*pObj)[0]->data.misc.ubBombOwner - 2), CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, (*pObj)[0]->data.misc.usBombItem, ubLevel, (*pObj)[0]->data.ubDirection, pObj); + IgniteExplosion( (UINT8) ((*pObj)[0]->data.misc.ubBombOwner - 2), sX, sY, 0, sGridNo, (*pObj)[0]->data.misc.usBombItem, ubLevel, (*pObj)[0]->data.ubDirection, pObj); } else { // pre-placed - IgniteExplosion( NOBODY, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, (*pObj)[0]->data.misc.usBombItem, ubLevel, (*pObj)[0]->data.ubDirection ); + IgniteExplosion( NOBODY, sX, sY, 0, sGridNo, (*pObj)[0]->data.misc.usBombItem, ubLevel, (*pObj)[0]->data.ubDirection ); } } /* if ( FindWorldItemForBuriedBombInGridNo(sGridNo, ubLevel) != -1 ) @@ -5530,8 +5539,8 @@ void FireFragmentsTrapGun( SOLDIERTYPE* pThrower, INT32 gridno, INT16 sZ, OBJECT INT16 horizontalarc = 5; INT16 verticalarc = 0; - INT16 sX = CenterX(gridno); - INT16 sY = CenterY(gridno); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(gridno, &sX, &sY); AssertMsg( ubFragRange > 0 , "Fragmentation data lacks range property!" ); @@ -6331,7 +6340,9 @@ void RoofDestruction( INT32 sGridNo, BOOLEAN fWithExplosion ) static UINT16 usRoofCollapseExplosionIndex = 1727; if ( HasItemFlag( usRoofCollapseExplosionIndex, ROOF_COLLAPSE_ITEM ) || GetFirstItemWithFlag( &usRoofCollapseExplosionIndex, ROOF_COLLAPSE_ITEM ) ) { - InternalIgniteExplosion( NOBODY, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, usRoofCollapseExplosionIndex, FALSE, 0 ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); + InternalIgniteExplosion( NOBODY, sX, sY, 0, sGridNo, usRoofCollapseExplosionIndex, FALSE, 0 ); } if ( Chance( 15 ) ) @@ -6340,7 +6351,9 @@ void RoofDestruction( INT32 sGridNo, BOOLEAN fWithExplosion ) if ( debrissmokeitem ) { - InternalIgniteExplosion( NOBODY, CenterX( sGridNo ), CenterY( sGridNo ), 0, sGridNo, debrissmokeitem, FALSE, 0 ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); + InternalIgniteExplosion( NOBODY, sX, sY, 0, sGridNo, debrissmokeitem, FALSE, 0 ); } } } diff --git a/TileEngine/Isometric Utils.cpp b/TileEngine/Isometric Utils.cpp index 5f68cf49..51d8a986 100644 --- a/TileEngine/Isometric Utils.cpp +++ b/TileEngine/Isometric Utils.cpp @@ -708,27 +708,6 @@ BOOLEAN GetMouseMapPos( INT32 *psMapPos ) } - -BOOLEAN ConvertMapPosToWorldTileCenter( INT32 usMapPos, INT16 *psXPos, INT16 *psYPos ) -{ - INT16 sWorldX, sWorldY; - INT16 sCellX, sCellY; - - // Get X, Y world GRID Coordinates - sWorldY = ( usMapPos / WORLD_COLS ); - sWorldX = usMapPos - ( sWorldY * WORLD_COLS ); - - // Convert into cell coords - sCellY = sWorldY * CELL_Y_SIZE; - sCellX = sWorldX * CELL_X_SIZE; - - // Add center tile positions - *psXPos = sCellX + ( CELL_X_SIZE / 2 ); - *psYPos = sCellY + ( CELL_Y_SIZE / 2 ); - - return( TRUE ); -} - void GetScreenXYWorldCoords( INT16 sScreenX, INT16 sScreenY, INT16 *psWorldX, INT16 *psWorldY ) { INT16 sOffsetX, sOffsetY; @@ -931,7 +910,7 @@ void ConvertGridNoToCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ) *sXPos = ( *sXPos * CELL_X_SIZE ); } -void ConvertGridNoToCenterCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ) +void ConvertGridNoToCenterCellXY( const INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ) { *sYPos = ( sGridNo / WORLD_COLS ); *sXPos = ( sGridNo - ( *sYPos * WORLD_COLS ) ); @@ -940,22 +919,6 @@ void ConvertGridNoToCenterCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ) *sXPos = ( *sXPos * CELL_X_SIZE ) + ( CELL_X_SIZE / 2 ); } -INT32 GetRangeFromGridNoDiff( INT32 sGridNo1, INT32 sGridNo2 ) -{ - INT32 uiDist; - INT16 sXPos, sYPos, sXPos2, sYPos2; - - // Convert our grid-not into an XY - ConvertGridNoToXY( sGridNo1, &sXPos, &sYPos ); - - // Convert our grid-not into an XY - ConvertGridNoToXY( sGridNo2, &sXPos2, &sYPos2 ); - - uiDist = (INT32)(sqrt((double) ( sXPos2 - sXPos )*( sXPos2 - sXPos ) + ( sYPos2 - sYPos ) * ( sYPos2 - sYPos ) )); - - return( uiDist ); -} - INT32 GetRangeInCellCoordsFromGridNoDiff( INT32 sGridNo1, INT32 sGridNo2 ) { INT16 sXPos, sYPos, sXPos2, sYPos2; @@ -1002,8 +965,8 @@ INT16 PythSpacesAway(INT32 sOrigin, INT32 sDest) { INT16 sRows,sCols,sResult; - sRows = abs((sOrigin / MAXCOL) - (sDest / MAXCOL)); - sCols = abs((sOrigin % MAXROW) - (sDest % MAXROW)); + sRows = (sOrigin / MAXCOL) - (sDest / MAXCOL); + sCols = (sOrigin % MAXROW) - (sDest % MAXROW); // apply Pythagoras's theorem for right-handed triangle: @@ -1234,30 +1197,6 @@ INT16 ExtQuickestDirection(INT16 origin, INT16 dest) } -// Returns the (center ) cell coordinates in X -INT16 CenterX( INT32 sGridNo ) -{ - INT32 sYPos, sXPos; - - sYPos = sGridNo / WORLD_COLS; - sXPos = ( sGridNo - ( sYPos * WORLD_COLS ) ); - - return( ( sXPos * CELL_X_SIZE ) + ( CELL_X_SIZE / 2 ) ); -} - - -// Returns the (center ) cell coordinates in Y -INT16 CenterY( INT32 sGridNo ) -{ - INT32 sYPos, sXPos; - - sYPos = sGridNo / WORLD_COLS; - sXPos = ( sGridNo - ( sYPos * WORLD_COLS ) ); - - return( ( sYPos * CELL_Y_SIZE ) + ( CELL_Y_SIZE / 2 ) ); -} - - INT16 MapX( INT32 sGridNo ) { INT32 sYPos, sXPos; diff --git a/TileEngine/Isometric Utils.h b/TileEngine/Isometric Utils.h index 7da2f67e..ad74b6e3 100644 --- a/TileEngine/Isometric Utils.h +++ b/TileEngine/Isometric Utils.h @@ -45,7 +45,7 @@ extern UINT8 gPurpendicularDirection[ NUM_WORLD_DIRECTIONS ][ NUM_WORLD_DIRECTIO void ConvertDirectionToVectorInXY(UINT8 ubDirection, INT16* sXDir, INT16* sYDir); void ConvertGridNoToXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ); void ConvertGridNoToCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ); -void ConvertGridNoToCenterCellXY( INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ); +void ConvertGridNoToCenterCellXY( const INT32 sGridNo, INT16 *sXPos, INT16 *sYPos ); // GRID NO MANIPULATION FUNCTIONS @@ -88,11 +88,8 @@ BOOLEAN GridNoOnVisibleWorldTile( INT32 sGridNo ); BOOLEAN GridNoOnVisibleWorldTileGivenYLimits( INT32 sGridNo ); BOOLEAN GridNoOnEdgeOfMap( INT32 sGridNo, INT8 * pbDirection ); -BOOLEAN ConvertMapPosToWorldTileCenter( INT32 usMapPos, INT16 *psXPos, INT16 *psYPos ); - BOOLEAN CellXYToScreenXY(INT16 sCellX, INT16 sCellY, INT16 *sScreenX, INT16 *sScreenY); -INT32 GetRangeFromGridNoDiff( INT32 sGridNo1, INT32 sGridNo2 ); INT32 GetRangeInCellCoordsFromGridNoDiff( INT32 sGridNo1, INT32 sGridNo2 ); BOOLEAN IsPointInScreenRect( INT16 sXPos, INT16 sYPos, SGPRect *pRect ); @@ -110,12 +107,6 @@ INT16 QuickestDirection(INT16 origin, INT16 dest); INT16 ExtQuickestDirection(INT16 origin, INT16 dest); -// Returns the (center ) cell coordinates in X -INT16 CenterX( INT32 sGridNo ); - -// Returns the (center ) cell coordinates in Y -INT16 CenterY( INT32 sGridNo ); - INT16 MapX( INT32 sGridNo ); INT16 MapY( INT32 sGridNo ); BOOLEAN FindFenceJumpDirection( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bStartingDir, INT8 *pbDirection ); @@ -157,4 +148,4 @@ BOOLEAN FindWindowJumpDirection( SOLDIERTYPE *pSoldier, INT32 sGridNo, INT8 bSta // Flugente: is this gridno near a player merc? BOOLEAN GridNoNearPlayerMercs( INT32 sGridNo, INT16 sRadius ); -#endif \ No newline at end of file +#endif diff --git a/TileEngine/LightEffects.cpp b/TileEngine/LightEffects.cpp index a229f4a6..dcbb1574 100644 --- a/TileEngine/LightEffects.cpp +++ b/TileEngine/LightEffects.cpp @@ -84,7 +84,10 @@ void UpdateLightingSprite( LIGHTEFFECT *pLight ) LightSpritePower( pLight->iLight, TRUE ); // LightSpriteFake( pLight->iLight ); - LightSpritePosition( pLight->iLight, (INT16)( CenterX( pLight->sGridNo ) / CELL_X_SIZE ), (INT16)( CenterY( pLight->sGridNo ) / CELL_Y_SIZE ) ); + INT16 sX, sY; + ConvertGridNoToCenterCellXY(pLight->sGridNo, &sX, &sY); + + LightSpritePosition( pLight->iLight, (INT16)( sX / CELL_X_SIZE ), (INT16)( sY / CELL_Y_SIZE ) ); } // Flugente: create a pure light, worry about updating sight in other functions diff --git a/TileEngine/SmokeEffects.cpp b/TileEngine/SmokeEffects.cpp index 8d6bce9c..4e202318 100644 --- a/TileEngine/SmokeEffects.cpp +++ b/TileEngine/SmokeEffects.cpp @@ -534,9 +534,11 @@ void AddSmokeEffectToTile( INT32 iSmokeEffectID, INT8 bType, INT32 sGridNo, INT8 AniParams.uiFlags = ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_SMOKE_EFFECT | ANITILE_LOOPING | ANITILE_ALWAYS_TRANSLUCENT; } - AniParams.sX = CenterX( sGridNo ); - AniParams.sY = CenterY( sGridNo ); - AniParams.sZ = (INT16)0; + INT16 sX, sY; + ConvertGridNoToCenterCellXY(sGridNo, &sX, &sY); + AniParams.sX = sX; + AniParams.sY = sY; + AniParams.sZ = (INT16)0; // Use the right graphic based on type.. switch( bType ) diff --git a/TileEngine/environment.cpp b/TileEngine/environment.cpp index 54aff33d..ad04fdc9 100644 --- a/TileEngine/environment.cpp +++ b/TileEngine/environment.cpp @@ -1093,7 +1093,6 @@ void AddSnakeAmim( INT32 sGridno, UINT8 usDirection ) if ( !TileIsOutOfBounds( sGridno ) ) { ANITILE_PARAMS AniParams; - memset( &AniParams, 0, sizeof(ANITILE_PARAMS) ); AniParams.sGridNo = sGridno; @@ -1101,8 +1100,7 @@ void AddSnakeAmim( INT32 sGridno, UINT8 usDirection ) AniParams.sDelay = 100; AniParams.sStartFrame = 0; AniParams.uiFlags = ANITILE_CACHEDTILE | ANITILE_FORWARD | ANITILE_USE_DIRECTION_FOR_START_FRAME;//| ANITILE_LOOPING; - AniParams.sX = CenterX( sGridno ); - AniParams.sY = CenterY( sGridno ); + ConvertGridNoToCenterCellXY(sGridno, &AniParams.sX, &AniParams.sY); AniParams.sZ = 0; strcpy( AniParams.zCachedFile, "TILECACHE\\WATERSNAKE_MOVE.sti" ); diff --git a/TileEngine/physics.cpp b/TileEngine/physics.cpp index a08b7236..68c55586 100644 --- a/TileEngine/physics.cpp +++ b/TileEngine/physics.cpp @@ -1995,7 +1995,7 @@ void CalculateLaunchItemBasicParams( SOLDIERTYPE *pSoldier, OBJECTTYPE *pItem, I { // bad news - i can't throw item at myself // so use dir incrementer - UINT8 ubDir = atan8( CenterX(pSoldier->sGridNo), CenterY(pSoldier->sGridNo), CenterX(sGridNo), CenterY(sGridNo) ); + UINT8 ubDir = GetDirectionFromCenterCellXYGridNo(pSoldier->sGridNo, sGridNo); sInterGridNo += DirIncrementer[ubDir]; } } diff --git a/TileEngine/renderworld.cpp b/TileEngine/renderworld.cpp index 5258b73a..85eb7bd9 100644 --- a/TileEngine/renderworld.cpp +++ b/TileEngine/renderworld.cpp @@ -614,7 +614,7 @@ void ShowRiotShield( SOLDIERTYPE* pSoldier, UINT16 *pBuffer, UINT32 uiDestPitchB // try to keep the shield 'moving' alongside the soldier. This won't work perfectly, but it's better than nothing INT16 base_x = 0; INT16 base_y = 0; - ConvertMapPosToWorldTileCenter( pSoldier->sGridNo, &base_x, &base_y ); + ConvertGridNoToCenterCellXY( pSoldier->sGridNo, &base_x, &base_y ); INT16 dx = pSoldier->sX - base_x; INT16 dy = pSoldier->sY - base_y; From eca4086d303f48121f504a7b1c6b2f2d489f8b0c Mon Sep 17 00:00:00 2001 From: Marco Antonio Jaguaribe Costa Date: Sat, 7 Oct 2023 08:53:23 -0300 Subject: [PATCH 038/120] inherit minimum cmake version from ja2 all this does is silence the warning that cmake 2.6 is deprecated, we're never building bfVFS standalone anyway --- ext/VFS/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/ext/VFS/CMakeLists.txt b/ext/VFS/CMakeLists.txt index 23806e84..21f5d1ec 100644 --- a/ext/VFS/CMakeLists.txt +++ b/ext/VFS/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 2.6) - project(bfVFS) set(BFVFS_VERSION_MAJOR 1) From 56a55f1bc49ce119f6709829ea76934f65803b57 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 7 Oct 2023 18:53:39 +0300 Subject: [PATCH 039/120] Use std::queue instead of old custom queue implemented in container.cpp --- Tactical/Dialogue Control.cpp | 563 +++++++++++++++------------------- 1 file changed, 245 insertions(+), 318 deletions(-) diff --git a/Tactical/Dialogue Control.cpp b/Tactical/Dialogue Control.cpp index 16653ffa..b8d9a9a7 100644 --- a/Tactical/Dialogue Control.cpp +++ b/Tactical/Dialogue Control.cpp @@ -52,6 +52,7 @@ #include "qarray.h" #include "Soldier Profile.h" #include +#include #include "Auto Resolve.h" #include "connect.h" @@ -168,8 +169,8 @@ UINT8 gubNumStopTimeQuotes = 2; // QUEUE UP DIALOG! -#define INITIAL_Q_SIZE 10 -HQUEUE ghDialogueQ = NULL; +std::queue ghDialogueQ; + FACETYPE *gpCurrentTalkingFace = NULL; UINT8 gubCurrentTalkingID = NO_PROFILE; INT8 gbUIHandlerID; @@ -283,40 +284,18 @@ BOOLEAN DialogueActive( ) BOOLEAN InitalizeDialogueControl() { - ghDialogueQ = CreateQueue( INITIAL_Q_SIZE, sizeof( DIALOGUE_Q_STRUCT_PTR ) ); - - // Initalize subtitle popup box - // - + EmptyDialogueQueue(); giNPCReferenceCount = 0; - - if ( ghDialogueQ == NULL ) - { - return( FALSE ); - } - else - { - return( TRUE ); - } + return( TRUE ); } void ShutdownDialogueControl() { - if( ghDialogueQ != NULL ) - { - // Empty - EmptyDialogueQueue( ); - - // Delete - DeleteQueue( ghDialogueQ ); - ghDialogueQ=NULL; - } - // shutdown external static NPC faces ShutdownStaticExternalNPCFaces( ); - // gte rid of portraits for cars + // get rid of portraits for cars UnLoadCarPortraits( ); // } @@ -373,49 +352,31 @@ void ShutdownStaticExternalNPCFaces( void ) void EmptyDialogueQueue( ) { // If we have anything left in the queue, remove! - if( ghDialogueQ != NULL ) + while( !ghDialogueQ.empty() ) { -/* -DEF: commented out because the Queue system ?? uses a contiguous memory block ??? for the queue - so you cant delete a single node. The DeleteQueue, below, will free the entire memory block - - numDialogueItems = QueueSize( ghDialogueQ ); - - for ( cnt = numDialogueItems-1; cnt >= 0; cnt-- ) - { - if ( PeekQueue( ghDialogueQ, &QItem ) ) - { - MemFree( QItem ); - } - } -*/ - - // Delete list - DeleteQueue( ghDialogueQ ); - ghDialogueQ=NULL; - - // Recreate list - ghDialogueQ = CreateQueue( INITIAL_Q_SIZE, sizeof( DIALOGUE_Q_STRUCT_PTR ) ); - + ghDialogueQ.pop(); } gfWaitingForTriggerTimer = FALSE; } -BOOLEAN DialogueQueueIsEmpty( ) +inline BOOLEAN DialogueQueueIsEmpty( ) { - if( ghDialogueQ != NULL ) - { - INT32 numDialogueItems = QueueSize( ghDialogueQ ); + return( ghDialogueQ.empty() ); +} - if ( numDialogueItems == 0 ) - { - return( TRUE ); - } + +static bool PopFromDialogueQueue(DIALOGUE_Q_STRUCT_PTR pDialogue) +{ + if (!ghDialogueQ.empty()) + { + *pDialogue = ghDialogueQ.front(); + ghDialogueQ.pop(); + return (true); } - return( FALSE ); + return false; } @@ -434,6 +395,7 @@ BOOLEAN DialogueQueueIsEmptyOrSomebodyTalkingNow( ) return( TRUE ); } + void DialogueAdvanceSpeech( ) { // Shut them up! @@ -507,7 +469,6 @@ void HandleDialogueUIAdjustments( ) void HandleDialogue( ) { INT32 iQSize; - DIALOGUE_Q_STRUCT *QItem; static BOOLEAN fOldEngagedInConvFlagOn = FALSE; BOOLEAN fDoneTalking = FALSE; SOLDIERTYPE *pSoldier = NULL; @@ -520,7 +481,7 @@ void HandleDialogue( ) return; } - iQSize = QueueSize( ghDialogueQ ); + iQSize = ghDialogueQ.size(); if ( iQSize == 0 && gpCurrentTalkingFace == NULL ) { @@ -787,19 +748,18 @@ void HandleDialogue( ) // If here, pick current one from queue and play // Get new one - RemfromQueue( ghDialogueQ, &QItem ); - + DIALOGUE_Q_STRUCT QItem; + PopFromDialogueQueue(&QItem); + // If we are in auto bandage, ignore any quotes! if ( gTacticalStatus.fAutoBandageMode ) { - if( QItem->fPauseTime ) + if( QItem.fPauseTime ) { UnLockPauseState(); UnPauseGame(); } - // Delete memory - MemFree( QItem ); return; } @@ -807,30 +767,27 @@ void HandleDialogue( ) // Alrighty, check if this one is to be delayed until we gain control. // If so, place it back in! - if ( QItem->fDelayed ) + if ( QItem.fDelayed ) { // Are we not in our turn and not interrupted if ( gTacticalStatus.ubCurrentTeam != gbPlayerNum ) { //Place back in! - // Add to queue - ghDialogueQ = AddtoQueue( ghDialogueQ, &QItem ); - + ghDialogueQ.push(QItem); return; } } // ATE: OK: If a battle sound, and delay value was given, set time stamp // now... - if ( QItem->uiSpecialEventFlag == DIALOGUE_SPECIAL_EVENT_DO_BATTLE_SND ) + if ( QItem.uiSpecialEventFlag == DIALOGUE_SPECIAL_EVENT_DO_BATTLE_SND ) { - if ( QItem->uiSpecialEventData2 != 0 ) + if ( QItem.uiSpecialEventData2 != 0 ) { - if ( ( GetJA2Clock( ) - QItem->iTimeStamp ) < QItem->uiSpecialEventData2 ) + if ( ( GetJA2Clock( ) - QItem.iTimeStamp ) < QItem.uiSpecialEventData2 ) { //Place back in! - // Add to queue - ghDialogueQ = AddtoQueue( ghDialogueQ, &QItem ); + ghDialogueQ.push(QItem); return; } @@ -838,26 +795,25 @@ void HandleDialogue( ) } // Try to find soldier... - pSoldier = FindSoldierByProfileID( QItem->ubCharacterNum, TRUE ); + pSoldier = FindSoldierByProfileID( QItem.ubCharacterNum, TRUE ); if ( pSoldier != NULL ) { if ( SoundIsPlaying( pSoldier->uiBattleSoundID ) ) { //Place back in! - // Add to queue - ghDialogueQ = AddtoQueue( ghDialogueQ, &QItem ); + ghDialogueQ.push(QItem); return; } } - if ( (guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) && ( QItem->uiSpecialEventFlag == 0 ) ) + if ( (guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) && ( QItem.uiSpecialEventFlag == 0 ) ) { - QItem->fPauseTime = TRUE; + QItem.fPauseTime = TRUE; } - if( QItem->fPauseTime ) + if( QItem.fPauseTime ) { if( GamePaused( ) == FALSE ) { @@ -869,7 +825,7 @@ void HandleDialogue( ) // Now play first item in queue // If it's not a 'special' dialogue event, continue - if ( QItem->uiSpecialEventFlag == 0 ) + if ( QItem.uiSpecialEventFlag == 0 ) { if( pSoldier ) { @@ -883,43 +839,43 @@ void HandleDialogue( ) fTeamPanelDirty = TRUE; // allow them to go back to sleep - TacticalCharacterDialogueWithSpecialEvent( pSoldier, QItem->usQuoteNum, DIALOGUE_SPECIAL_EVENT_SLEEP, 1,0 ); + TacticalCharacterDialogueWithSpecialEvent( pSoldier, QItem.usQuoteNum, DIALOGUE_SPECIAL_EVENT_SLEEP, 1,0 ); } } - gTacticalStatus.ubLastQuoteSaid = (UINT8)QItem->usQuoteNum; - gTacticalStatus.ubLastQuoteProfileNUm = (UINT8)QItem->ubCharacterNum; + gTacticalStatus.ubLastQuoteSaid = (UINT8)QItem.usQuoteNum; + gTacticalStatus.ubLastQuoteProfileNUm = (UINT8)QItem.ubCharacterNum; // Flugente: only set up face if we can access correctly - if ( QItem->iFaceIndex >= 0 ) + if ( QItem.iFaceIndex >= 0 ) { // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + gpCurrentTalkingFace = &gFacesData[ QItem.iFaceIndex ]; } - gubCurrentTalkingID = QItem->ubCharacterNum; + gubCurrentTalkingID = QItem.ubCharacterNum; #ifdef JA2UB //Ja25: test - if( QItem->ubCharacterNum == MORRIS_UB ) //MORRIS + if( QItem.ubCharacterNum == MORRIS_UB ) //MORRIS { - if( QItem->usQuoteNum == 0 ) + if( QItem.usQuoteNum == 0 ) { } } #endif - ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->fFromSoldier ); + ExecuteCharacterDialogue( QItem.ubCharacterNum, QItem.usQuoteNum, QItem.iFaceIndex, QItem.bUIHandlerID, QItem.fFromSoldier ); } - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SKIP_A_FRAME ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SKIP_A_FRAME ) { } - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_LOCK_INTERFACE ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_LOCK_INTERFACE ) { // locking or unlocking? - if( QItem->uiSpecialEventData ) + if( QItem.uiSpecialEventData ) { - switch( QItem->uiSpecialEventData2 ) + switch( QItem.uiSpecialEventData2 ) { case( MAP_SCREEN ): fLockOutMapScreenInterface = TRUE; @@ -928,7 +884,7 @@ void HandleDialogue( ) } else { - switch( QItem->uiSpecialEventData2 ) + switch( QItem.uiSpecialEventData2 ) { case( MAP_SCREEN ): fLockOutMapScreenInterface = FALSE; @@ -936,61 +892,61 @@ void HandleDialogue( ) } } } - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_REMOVE_EPC ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_REMOVE_EPC ) { - gMercProfiles[ (UINT8) QItem->uiSpecialEventData ].ubMiscFlags &= ~PROFILE_MISC_FLAG_FORCENPCQUOTE; - UnRecruitEPC( (UINT8) QItem->uiSpecialEventData ); + gMercProfiles[ (UINT8) QItem.uiSpecialEventData ].ubMiscFlags &= ~PROFILE_MISC_FLAG_FORCENPCQUOTE; + UnRecruitEPC( (UINT8) QItem.uiSpecialEventData ); ReBuildCharactersList(); } - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CONTRACT_WANTS_TO_RENEW ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CONTRACT_WANTS_TO_RENEW ) { - HandleMercIsWillingToRenew( (UINT8)QItem->uiSpecialEventData ); + HandleMercIsWillingToRenew( (UINT8)QItem.uiSpecialEventData ); } - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CONTRACT_NOGO_TO_RENEW ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CONTRACT_NOGO_TO_RENEW ) { - HandleMercIsNotWillingToRenew( (UINT8)QItem->uiSpecialEventData ); + HandleMercIsNotWillingToRenew( (UINT8)QItem.uiSpecialEventData ); } else { - if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_USE_ALTERNATE_FILES ) + if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_USE_ALTERNATE_FILES ) { gfUseAlternateDialogueFile = TRUE; // Flugente: only set up face if we can access correctly - if ( QItem->iFaceIndex >= 0 ) + if ( QItem.iFaceIndex >= 0 ) { // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + gpCurrentTalkingFace = &gFacesData[ QItem.iFaceIndex ]; } - gubCurrentTalkingID = QItem->ubCharacterNum; + gubCurrentTalkingID = QItem.ubCharacterNum; - ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->fFromSoldier ); + ExecuteCharacterDialogue( QItem.ubCharacterNum, QItem.usQuoteNum, QItem.iFaceIndex, QItem.bUIHandlerID, QItem.fFromSoldier ); gfUseAlternateDialogueFile = FALSE; } // We could have a special flag, but dialogue as well - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_PCTRIGGERNPC ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_PCTRIGGERNPC ) { // Flugente: only set up face if we can access correctly - if ( QItem->iFaceIndex >= 0 ) + if ( QItem.iFaceIndex >= 0 ) { // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + gpCurrentTalkingFace = &gFacesData[ QItem.iFaceIndex ]; } - gubCurrentTalkingID = QItem->ubCharacterNum; + gubCurrentTalkingID = QItem.ubCharacterNum; - ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->fFromSoldier ); + ExecuteCharacterDialogue( QItem.ubCharacterNum, QItem.usQuoteNum, QItem.iFaceIndex, QItem.bUIHandlerID, QItem.fFromSoldier ); // Setup face with data! gpCurrentTalkingFace->uiFlags |= FACE_PCTRIGGER_NPC; - gpCurrentTalkingFace->uiUserData1 = QItem->uiSpecialEventData; - gpCurrentTalkingFace->uiUserData2 = QItem->uiSpecialEventData2; + gpCurrentTalkingFace->uiUserData1 = QItem.uiSpecialEventData; + gpCurrentTalkingFace->uiUserData2 = QItem.uiSpecialEventData2; } - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SHOW_CONTRACT_MENU ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SHOW_CONTRACT_MENU ) { // Setup face pointer // ATE: THis is working with MARK'S STUFF :( @@ -1003,116 +959,116 @@ void HandleDialogue( ) pProcessingSoldier = pSoldier; fProcessingAMerc = TRUE; } - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_DO_BATTLE_SND ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_DO_BATTLE_SND ) { // grab soldier ptr from profile ID - pSoldier = FindSoldierByProfileID( QItem->ubCharacterNum, FALSE ); + pSoldier = FindSoldierByProfileID( QItem.ubCharacterNum, FALSE ); // Do battle snounds...... if ( pSoldier ) { - pSoldier->InternalDoMercBattleSound( (UINT8)QItem->uiSpecialEventData, 0 ); + pSoldier->InternalDoMercBattleSound( (UINT8)QItem.uiSpecialEventData, 0 ); } } - if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SIGNAL_ITEM_LOCATOR_START ) + if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SIGNAL_ITEM_LOCATOR_START ) { // Turn off item lock for locators... gTacticalStatus.fLockItemLocators = FALSE; // Slide to location! - SlideToLocation( 0, QItem->uiSpecialEventData ); + SlideToLocation( 0, QItem.uiSpecialEventData ); // Flugente: only set up face if we can access correctly - if ( QItem->iFaceIndex >= 0 ) + if ( QItem.iFaceIndex >= 0 ) { // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + gpCurrentTalkingFace = &gFacesData[ QItem.iFaceIndex ]; } - gubCurrentTalkingID = QItem->ubCharacterNum; + gubCurrentTalkingID = QItem.ubCharacterNum; - ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->fFromSoldier ); + ExecuteCharacterDialogue( QItem.ubCharacterNum, QItem.usQuoteNum, QItem.iFaceIndex, QItem.bUIHandlerID, QItem.fFromSoldier ); } - if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_ENABLE_AI ) + if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_ENABLE_AI ) { //OK, allow AI to work now.... UnPauseAI(); } - if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_TRIGGERPREBATTLEINTERFACE ) + if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_TRIGGERPREBATTLEINTERFACE ) { UnLockPauseState(); // Flugente: what hideous idiocy is this? We cast a UINT32 as GROUP*? This is likely to return garbage. // Why the hell not use the id instead? - InitPreBattleInterface( (GROUP*)QItem->uiSpecialEventData, TRUE ); + InitPreBattleInterface( (GROUP*)QItem.uiSpecialEventData, TRUE ); - /*GROUP* pGroup = GetGroup( (UINT8)QItem->uiSpecialEventData ); + /*GROUP* pGroup = GetGroup( (UINT8)QItem.uiSpecialEventData ); if ( pGroup ) InitPreBattleInterface( pGroup, TRUE );*/ } - if( QItem->uiSpecialEventFlag & DIALOGUE_ADD_EVENT_FOR_SOLDIER_UPDATE_BOX ) + if( QItem.uiSpecialEventFlag & DIALOGUE_ADD_EVENT_FOR_SOLDIER_UPDATE_BOX ) { INT32 iReason = 0; SOLDIERTYPE *pUpdateSoldier = NULL; - iReason = QItem->uiSpecialEventData; + iReason = QItem.uiSpecialEventData; switch( iReason ) { case( UPDATE_BOX_REASON_ADDSOLDIER ): - pUpdateSoldier = &Menptr[ QItem->uiSpecialEventData2 ]; + pUpdateSoldier = &Menptr[ QItem.uiSpecialEventData2 ]; if( pUpdateSoldier->bActive == TRUE ) { AddSoldierToUpdateBox( pUpdateSoldier ); } break; case( UPDATE_BOX_REASON_SET_REASON ): - SetSoldierUpdateBoxReason( QItem->uiSpecialEventData2 ); + SetSoldierUpdateBoxReason( QItem.uiSpecialEventData2 ); break; case( UPDATE_BOX_REASON_SHOW_BOX ): ShowUpdateBox( ); break; } } - if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_BEGINPREBATTLEINTERFACE ) + if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_BEGINPREBATTLEINTERFACE ) { // Flugente: only set up face if we can access correctly - if ( QItem->iFaceIndex >= 0 ) + if ( QItem.iFaceIndex >= 0 ) { // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + gpCurrentTalkingFace = &gFacesData[ QItem.iFaceIndex ]; } - gubCurrentTalkingID = QItem->ubCharacterNum; + gubCurrentTalkingID = QItem.ubCharacterNum; - ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->fFromSoldier ); + ExecuteCharacterDialogue( QItem.ubCharacterNum, QItem.usQuoteNum, QItem.iFaceIndex, QItem.bUIHandlerID, QItem.fFromSoldier ); // Setup face with data! gpCurrentTalkingFace->uiFlags |= FACE_TRIGGER_PREBATTLE_INT; - gpCurrentTalkingFace->uiUserData1 = QItem->uiSpecialEventData; - gpCurrentTalkingFace->uiUserData2 = QItem->uiSpecialEventData2; + gpCurrentTalkingFace->uiUserData1 = QItem.uiSpecialEventData; + gpCurrentTalkingFace->uiUserData2 = QItem.uiSpecialEventData2; } - if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SHOPKEEPER ) + if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SHOPKEEPER ) { - if( QItem->uiSpecialEventData < 3 ) + if( QItem.uiSpecialEventData < 3 ) { // post a notice if the player wants to withdraw money from thier account to cover the difference? - swprintf( zMoney, L"%d", QItem->uiSpecialEventData2 ); + swprintf( zMoney, L"%d", QItem.uiSpecialEventData2 ); InsertCommasForDollarFigure( zMoney ); InsertDollarSignInToString( zMoney ); } - else if ( QItem->uiSpecialEventData > 7 ) + else if ( QItem.uiSpecialEventData > 7 ) { // post a notice if the player wants to withdraw money from thier account to cover the difference? - swprintf( zMoney, L"%d", QItem->uiSpecialEventData2 ); + swprintf( zMoney, L"%d", QItem.uiSpecialEventData2 ); InsertCommasForDollarFigure( zMoney ); } - switch( QItem->uiSpecialEventData ) + switch( QItem.uiSpecialEventData ) { case( 0 ): swprintf( zText, SkiMessageBoxText[ SKI_SHORT_FUNDS_TEXT ], zMoney ); @@ -1136,7 +1092,7 @@ void HandleDialogue( ) break; case( 3 ): // this means a dialogue event is in progress - giShopKeepDialogueEventinProgress = QItem->uiSpecialEventData2; + giShopKeepDialogueEventinProgress = QItem.uiSpecialEventData2; break; case( 4 ): // this means a dialogue event has ended @@ -1179,107 +1135,107 @@ void HandleDialogue( ) } - if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_EXIT_MAP_SCREEN ) + if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_EXIT_MAP_SCREEN ) { // select sector - ChangeSelectedMapSector( ( INT16 )QItem->uiSpecialEventData, ( INT16 )QItem->uiSpecialEventData2, ( INT8 )QItem->uiSpecialEventData3 ); + ChangeSelectedMapSector( ( INT16 )QItem.uiSpecialEventData, ( INT16 )QItem.uiSpecialEventData2, ( INT8 )QItem.uiSpecialEventData3 ); RequestTriggerExitFromMapscreen( MAP_EXIT_TO_TACTICAL ); } - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_DISPLAY_STAT_CHANGE ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_DISPLAY_STAT_CHANGE ) { // grab soldier ptr from profile ID - pSoldier = FindSoldierByProfileID( QItem->ubCharacterNum, FALSE ); + pSoldier = FindSoldierByProfileID( QItem.ubCharacterNum, FALSE ); if ( pSoldier ) { CHAR16 wTempString[ 128 ]; // tell player about stat increase - BuildStatChangeString( wTempString, pSoldier->name, ( BOOLEAN ) QItem->uiSpecialEventData, ( INT16 ) QItem->uiSpecialEventData2, ( UINT8 ) QItem->uiSpecialEventData3 ); + BuildStatChangeString( wTempString, pSoldier->name, ( BOOLEAN ) QItem.uiSpecialEventData, ( INT16 ) QItem.uiSpecialEventData2, ( UINT8 ) QItem.uiSpecialEventData3 ); ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, wTempString ); } } - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_UNSET_ARRIVES_FLAG ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_UNSET_ARRIVES_FLAG ) { gTacticalStatus.bMercArrivingQuoteBeingUsed = FALSE; } /* - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_DISPLAY_INVASION_MESSAGE ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_DISPLAY_INVASION_MESSAGE ) { - HandlePlayerNotifyInvasionByEnemyForces( (INT16)(QItem->uiSpecialEventData % MAP_WORLD_X), (INT16)(QItem->uiSpecialEventData / MAP_WORLD_X), 0, NULL ); + HandlePlayerNotifyInvasionByEnemyForces( (INT16)(QItem.uiSpecialEventData % MAP_WORLD_X), (INT16)(QItem.uiSpecialEventData / MAP_WORLD_X), 0, NULL ); } */ - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SKYRIDERMAPSCREENEVENT ) { // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; - gubCurrentTalkingID = QItem->ubCharacterNum; + gpCurrentTalkingFace = &gFacesData[ QItem.iFaceIndex ]; + gubCurrentTalkingID = QItem.ubCharacterNum; // handle the monologue event - HandleSkyRiderMonologueEvent( QItem->uiSpecialEventData, QItem->uiSpecialEventData2 ); + HandleSkyRiderMonologueEvent( QItem.uiSpecialEventData, QItem.uiSpecialEventData2 ); } - if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_MINESECTOREVENT ) + if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_MINESECTOREVENT ) { // Flugente: only set up face if we can access correctly - if ( QItem->iFaceIndex >= 0 ) + if ( QItem.iFaceIndex >= 0 ) { // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + gpCurrentTalkingFace = &gFacesData[ QItem.iFaceIndex ]; } - gubCurrentTalkingID = QItem->ubCharacterNum; + gubCurrentTalkingID = QItem.ubCharacterNum; // set up the mine highlgith events - SetUpAnimationOfMineSectors( QItem->uiSpecialEventData ); + SetUpAnimationOfMineSectors( QItem.uiSpecialEventData ); } //Switch on our special events - if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_GIVE_ITEM ) + if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_GIVE_ITEM ) { - if ( QItem->bUIHandlerID == DIALOGUE_NPC_UI ) + if ( QItem.bUIHandlerID == DIALOGUE_NPC_UI ) { - HandleNPCItemGiven( (UINT8)QItem->uiSpecialEventData, (OBJECTTYPE*)QItem->uiSpecialEventData2, (INT8)QItem->uiSpecialEventData3 ); + HandleNPCItemGiven( (UINT8)QItem.uiSpecialEventData, (OBJECTTYPE*)QItem.uiSpecialEventData2, (INT8)QItem.uiSpecialEventData3 ); } } - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_TRIGGER_NPC ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_TRIGGER_NPC ) { - if ( QItem->bUIHandlerID == DIALOGUE_NPC_UI ) + if ( QItem.bUIHandlerID == DIALOGUE_NPC_UI ) { - HandleNPCTriggerNPC( (UINT8)QItem->uiSpecialEventData, (UINT8)QItem->uiSpecialEventData2, (BOOLEAN)QItem->uiSpecialEventData3, (UINT8)QItem->uiSpecialEventData4 ); + HandleNPCTriggerNPC( (UINT8)QItem.uiSpecialEventData, (UINT8)QItem.uiSpecialEventData2, (BOOLEAN)QItem.uiSpecialEventData3, (UINT8)QItem.uiSpecialEventData4 ); } } - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_GOTO_GRIDNO ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_GOTO_GRIDNO ) { - if ( QItem->bUIHandlerID == DIALOGUE_NPC_UI ) + if ( QItem.bUIHandlerID == DIALOGUE_NPC_UI ) { - HandleNPCGotoGridNo( (UINT8)QItem->uiSpecialEventData, (UINT16)QItem->uiSpecialEventData2, (UINT8)QItem->uiSpecialEventData3 );//dnl!!! + HandleNPCGotoGridNo( (UINT8)QItem.uiSpecialEventData, (UINT16)QItem.uiSpecialEventData2, (UINT8)QItem.uiSpecialEventData3 );//dnl!!! } } - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_DO_ACTION ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_DO_ACTION ) { - if ( QItem->bUIHandlerID == DIALOGUE_NPC_UI ) + if ( QItem.bUIHandlerID == DIALOGUE_NPC_UI ) { - HandleNPCDoAction( (UINT8)QItem->uiSpecialEventData, (UINT16)QItem->uiSpecialEventData2, (UINT8)QItem->uiSpecialEventData3 ); + HandleNPCDoAction( (UINT8)QItem.uiSpecialEventData, (UINT16)QItem.uiSpecialEventData2, (UINT8)QItem.uiSpecialEventData3 ); } } - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CLOSE_PANEL ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CLOSE_PANEL ) { - if ( QItem->bUIHandlerID == DIALOGUE_NPC_UI ) + if ( QItem.bUIHandlerID == DIALOGUE_NPC_UI ) { HandleNPCClosePanel( ); } } - else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SHOW_UPDATE_MENU ) + else if ( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SHOW_UPDATE_MENU ) { SetUpdateBoxFlag( TRUE ); } #ifdef JA2UB - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_JERRY_MILO ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_JERRY_MILO ) { //switch on the quote that is being spoken - switch( QItem->uiSpecialEventData ) + switch( QItem.uiSpecialEventData ) { case JM_SE__SHOW_RADIO_LOCATOR: HandleShowingRadioLocatorsInMorrisArea(); @@ -1301,10 +1257,10 @@ void HandleDialogue( ) } } #else //Ja25: removed the flag, no militia - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CONTINUE_TRAINING_MILITIA ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CONTINUE_TRAINING_MILITIA ) { // grab soldier ptr from profile ID - pSoldier = FindSoldierByProfileID( ( UINT8 )( QItem->uiSpecialEventData ), FALSE ); + pSoldier = FindSoldierByProfileID( ( UINT8 )( QItem.uiSpecialEventData ), FALSE ); // if soldier valid... if( pSoldier != NULL ) @@ -1313,7 +1269,7 @@ void HandleDialogue( ) } } #endif - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_ENTER_MAPSCREEN ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_ENTER_MAPSCREEN ) { if( !(guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) ) { @@ -1321,22 +1277,22 @@ void HandleDialogue( ) fEnterMapDueToContract = TRUE; } } - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CONTRACT_ENDING ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CONTRACT_ENDING ) { // grab soldier ptr from profile ID - pSoldier = FindSoldierByProfileID( QItem->ubCharacterNum, FALSE ); + pSoldier = FindSoldierByProfileID( QItem.ubCharacterNum, FALSE ); // if soldier valid... if( pSoldier != NULL ) { // .. remove the fired soldier again - BeginStrategicRemoveMerc( pSoldier, (UINT8)QItem->uiSpecialEventData ); + BeginStrategicRemoveMerc( pSoldier, (UINT8)QItem.uiSpecialEventData ); } } - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CONTRACT_ENDING_NO_ASK_EQUIP ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_CONTRACT_ENDING_NO_ASK_EQUIP ) { // grab soldier ptr from profile ID - pSoldier = FindSoldierByProfileID( QItem->ubCharacterNum, FALSE ); + pSoldier = FindSoldierByProfileID( QItem.ubCharacterNum, FALSE ); // if soldier valid... if( pSoldier != NULL ) @@ -1345,53 +1301,53 @@ void HandleDialogue( ) StrategicRemoveMerc( pSoldier ); } } - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_MULTIPURPOSE ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_MULTIPURPOSE ) { // anv: handle snitch event - if( QItem->uiSpecialEventData & MULTIPURPOSE_SPECIAL_EVENT_SNITCH_DIALOGUE ) + if( QItem.uiSpecialEventData & MULTIPURPOSE_SPECIAL_EVENT_SNITCH_DIALOGUE ) { - gTacticalStatus.ubLastQuoteSaid = (UINT8)QItem->usQuoteNum; - gTacticalStatus.ubLastQuoteProfileNUm = (UINT8)QItem->ubCharacterNum; + gTacticalStatus.ubLastQuoteSaid = (UINT8)QItem.usQuoteNum; + gTacticalStatus.ubLastQuoteProfileNUm = (UINT8)QItem.ubCharacterNum; // Flugente: only set up face if we can access correctly - if ( QItem->iFaceIndex >= 0 ) + if ( QItem.iFaceIndex >= 0 ) { // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + gpCurrentTalkingFace = &gFacesData[ QItem.iFaceIndex ]; } - gubCurrentTalkingID = QItem->iFaceIndex; + gubCurrentTalkingID = QItem.iFaceIndex; - //ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, DIALOGUE_TACTICAL_UI, TRUE ); - ExecuteSnitchCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->uiSpecialEventData2, QItem->uiSpecialEventData3, QItem->uiSpecialEventData4 ); + //ExecuteCharacterDialogue( QItem.ubCharacterNum, QItem.usQuoteNum, QItem.iFaceIndex, DIALOGUE_TACTICAL_UI, TRUE ); + ExecuteSnitchCharacterDialogue( QItem.ubCharacterNum, QItem.usQuoteNum, QItem.iFaceIndex, QItem.bUIHandlerID, QItem.uiSpecialEventData2, QItem.uiSpecialEventData3, QItem.uiSpecialEventData4 ); } // Flugente: additional dialogue - else if ( QItem->uiSpecialEventData & MULTIPURPOSE_SPECIAL_EVENT_ADDITIONAL_DIALOGUE ) + else if ( QItem.uiSpecialEventData & MULTIPURPOSE_SPECIAL_EVENT_ADDITIONAL_DIALOGUE ) { // Flugente: only set up face if we can access correctly - if ( QItem->iFaceIndex >= 0 ) + if ( QItem.iFaceIndex >= 0 ) { // Setup face pointer - gpCurrentTalkingFace = &gFacesData[QItem->iFaceIndex]; + gpCurrentTalkingFace = &gFacesData[QItem.iFaceIndex]; } - gubCurrentTalkingID = QItem->iFaceIndex; + gubCurrentTalkingID = QItem.iFaceIndex; extern BOOLEAN ExecuteAdditionalCharacterDialogue( UINT8 ubProfile, INT32 iFaceIndex, UINT16 usEventNr, UINT32 aData1, UINT32 aData2, UINT32 aData3 ); - ExecuteAdditionalCharacterDialogue( QItem->ubCharacterNum, QItem->iFaceIndex, QItem->usQuoteNum, QItem->uiSpecialEventData2, QItem->uiSpecialEventData3, QItem->uiSpecialEventData4 ); + ExecuteAdditionalCharacterDialogue( QItem.ubCharacterNum, QItem.iFaceIndex, QItem.usQuoteNum, QItem.uiSpecialEventData2, QItem.uiSpecialEventData3, QItem.uiSpecialEventData4 ); } #ifdef JA2UB //JA25 UB - if ( QItem->uiSpecialEventData & MULTIPURPOSE_SPECIAL_EVENT_TEAM_MEMBERS_DONE_TALKING ) + if ( QItem.uiSpecialEventData & MULTIPURPOSE_SPECIAL_EVENT_TEAM_MEMBERS_DONE_TALKING ) { HandleEveryoneDoneTheirEndGameQuotes(); } else { // grab soldier ptr from profile ID - pSoldier = FindSoldierByProfileID( (UINT8)QItem->uiSpecialEventData, FALSE ); + pSoldier = FindSoldierByProfileID( (UINT8)QItem.uiSpecialEventData, FALSE ); // FindSoldier was returning a lot of nullptrs which would crash the game very quickly after Jerry gets up. This check is here to circumvent that. if (pSoldier != nullptr) @@ -1429,17 +1385,17 @@ void HandleDialogue( ) } } #else //Ja25 No queen - if ( QItem->uiSpecialEventData & MULTIPURPOSE_SPECIAL_EVENT_DONE_KILLING_DEIDRANNA ) + if ( QItem.uiSpecialEventData & MULTIPURPOSE_SPECIAL_EVENT_DONE_KILLING_DEIDRANNA ) { HandleDoneLastKilledQueenQuote( ); } - else if ( QItem->uiSpecialEventData & MULTIPURPOSE_SPECIAL_EVENT_TEAM_MEMBERS_DONE_TALKING ) + else if ( QItem.uiSpecialEventData & MULTIPURPOSE_SPECIAL_EVENT_TEAM_MEMBERS_DONE_TALKING ) { HandleDoneLastEndGameQuote( ); } } #endif - else if( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SLEEP ) + else if( QItem.uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_SLEEP ) { // no soldier, leave now if( pSoldier == NULL ) @@ -1448,7 +1404,7 @@ void HandleDialogue( ) } // wake merc up or put them back down? - if( QItem->uiSpecialEventData == 1 ) + if( QItem.uiSpecialEventData == 1 ) { pSoldier->flags.fMercAsleep = TRUE; } @@ -1464,20 +1420,17 @@ void HandleDialogue( ) } // grab soldier ptr from profile ID - pSoldier = FindSoldierByProfileID( QItem->ubCharacterNum, FALSE ); + pSoldier = FindSoldierByProfileID( QItem.ubCharacterNum, FALSE ); if ( pSoldier && pSoldier->bTeam == gbPlayerNum ) { - CheckForStopTimeQuotes( QItem->usQuoteNum ); + CheckForStopTimeQuotes( QItem.usQuoteNum ); } - if( QItem->fPauseTime ) + if( QItem.fPauseTime ) { fWasPausedDuringDialogue = TRUE; } - - // Delete memory - MemFree( QItem ); } BOOLEAN GetDialogue( UINT8 ubCharacterNum, UINT16 usQuoteNum, UINT32 iDataSize, STR16 zDialogueText, UINT32 *puiSoundID, CHAR8 *zSoundString ); @@ -1845,27 +1798,23 @@ void AdditionalTacticalCharacterDialogue_AllInSectorRadiusCall( UINT8 ausIgnoreP BOOLEAN CharacterDialogueWithSpecialEvent( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 iFaceIndex, UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed, UINT32 uiFlag, UINT32 uiData1, UINT32 uiData2 ) { - DIALOGUE_Q_STRUCT *QItem; - - // Allocate new item - QItem = (DIALOGUE_Q_STRUCT *) MemAlloc( sizeof( DIALOGUE_Q_STRUCT ) ); - memset( QItem, 0, sizeof( DIALOGUE_Q_STRUCT ) ); - - QItem->ubCharacterNum = ubCharacterNum; - QItem->usQuoteNum = usQuoteNum; - QItem->iFaceIndex = iFaceIndex; - QItem->bUIHandlerID = bUIHandlerID; - QItem->iTimeStamp = GetJA2Clock( ); - QItem->fFromSoldier = fFromSoldier; - QItem->fDelayed = fDelayed; + DIALOGUE_Q_STRUCT QItem; + memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + QItem.ubCharacterNum = ubCharacterNum; + QItem.usQuoteNum = usQuoteNum; + QItem.iFaceIndex = iFaceIndex; + QItem.bUIHandlerID = bUIHandlerID; + QItem.iTimeStamp = GetJA2Clock( ); + QItem.fFromSoldier = fFromSoldier; + QItem.fDelayed = fDelayed; // Set flag for special event - QItem->uiSpecialEventFlag = uiFlag; - QItem->uiSpecialEventData = uiData1; - QItem->uiSpecialEventData2 = uiData2; + QItem.uiSpecialEventFlag = uiFlag; + QItem.uiSpecialEventData = uiData1; + QItem.uiSpecialEventData2 = uiData2; // Add to queue - ghDialogueQ = AddtoQueue( ghDialogueQ, &QItem ); + ghDialogueQ.push(QItem); // sevenfm: disable FF for dialogues if (IsFastForwardMode()) @@ -1884,28 +1833,24 @@ BOOLEAN CharacterDialogueWithSpecialEvent( UINT8 ubCharacterNum, UINT16 usQuoteN BOOLEAN CharacterDialogueWithSpecialEventEx( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 iFaceIndex, UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed, UINT32 uiFlag, UINT32 uiData1, UINT32 uiData2, UINT32 uiData3 ) { - DIALOGUE_Q_STRUCT *QItem; - - // Allocate new item - QItem = (DIALOGUE_Q_STRUCT *) MemAlloc( sizeof( DIALOGUE_Q_STRUCT ) ); - memset( QItem, 0, sizeof( DIALOGUE_Q_STRUCT ) ); - - QItem->ubCharacterNum = ubCharacterNum; - QItem->usQuoteNum = usQuoteNum; - QItem->iFaceIndex = iFaceIndex; - QItem->bUIHandlerID = bUIHandlerID; - QItem->iTimeStamp = GetJA2Clock( ); - QItem->fFromSoldier = fFromSoldier; - QItem->fDelayed = fDelayed; + DIALOGUE_Q_STRUCT QItem; + memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + QItem.ubCharacterNum = ubCharacterNum; + QItem.usQuoteNum = usQuoteNum; + QItem.iFaceIndex = iFaceIndex; + QItem.bUIHandlerID = bUIHandlerID; + QItem.iTimeStamp = GetJA2Clock( ); + QItem.fFromSoldier = fFromSoldier; + QItem.fDelayed = fDelayed; // Set flag for special event - QItem->uiSpecialEventFlag = uiFlag; - QItem->uiSpecialEventData = uiData1; - QItem->uiSpecialEventData2 = uiData2; - QItem->uiSpecialEventData3 = uiData3; + QItem.uiSpecialEventFlag = uiFlag; + QItem.uiSpecialEventData = uiData1; + QItem.uiSpecialEventData2 = uiData2; + QItem.uiSpecialEventData3 = uiData3; // Add to queue - ghDialogueQ = AddtoQueue( ghDialogueQ, &QItem ); + ghDialogueQ.push(QItem); if ( uiFlag & DIALOGUE_SPECIAL_EVENT_PCTRIGGERNPC ) { @@ -1918,30 +1863,26 @@ BOOLEAN CharacterDialogueWithSpecialEventEx( UINT8 ubCharacterNum, UINT16 usQuot BOOLEAN CharacterDialogue( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 iFaceIndex, UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed ) { - DIALOGUE_Q_STRUCT *QItem; - - // Allocate new item - QItem = (DIALOGUE_Q_STRUCT *) MemAlloc( sizeof( DIALOGUE_Q_STRUCT ) ); - memset( QItem, 0, sizeof( DIALOGUE_Q_STRUCT ) ); - - QItem->ubCharacterNum = ubCharacterNum; - QItem->usQuoteNum = usQuoteNum; - QItem->iFaceIndex = iFaceIndex; - QItem->bUIHandlerID = bUIHandlerID; - QItem->iTimeStamp = GetJA2Clock( ); - QItem->fFromSoldier = fFromSoldier; - QItem->fDelayed = fDelayed; + DIALOGUE_Q_STRUCT QItem; + memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + QItem.ubCharacterNum = ubCharacterNum; + QItem.usQuoteNum = usQuoteNum; + QItem.iFaceIndex = iFaceIndex; + QItem.bUIHandlerID = bUIHandlerID; + QItem.iTimeStamp = GetJA2Clock( ); + QItem.fFromSoldier = fFromSoldier; + QItem.fDelayed = fDelayed; // check if pause already locked, if so, then don't mess with it if( gfLockPauseState == FALSE ) { - QItem->fPauseTime = fPausedTimeDuringQuote; + QItem.fPauseTime = fPausedTimeDuringQuote; } fPausedTimeDuringQuote = FALSE; // Add to queue - ghDialogueQ = AddtoQueue( ghDialogueQ, &QItem ); + ghDialogueQ.push(QItem); // Flugente: additional dialogue // in the dialogue screen, only the merc doing the talking may answer @@ -1973,35 +1914,31 @@ BOOLEAN SnitchCharacterDialogue( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 UINT32 uiSpecialEventData3, UINT32 uiSpecialEventData4, UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed ) { - DIALOGUE_Q_STRUCT *QItem; - - // Allocate new item - QItem = (DIALOGUE_Q_STRUCT *) MemAlloc( sizeof( DIALOGUE_Q_STRUCT ) ); - memset( QItem, 0, sizeof( DIALOGUE_Q_STRUCT ) ); - - QItem->ubCharacterNum = ubCharacterNum; - QItem->usQuoteNum = usQuoteNum; - QItem->uiSpecialEventFlag = uiSpecialEventFlag; - QItem->uiSpecialEventData = uiSpecialEventData1; - QItem->uiSpecialEventData2 = uiSpecialEventData2; - QItem->uiSpecialEventData3 = uiSpecialEventData3; - QItem->uiSpecialEventData4 = uiSpecialEventData4; - QItem->iFaceIndex = iFaceIndex; - QItem->bUIHandlerID = bUIHandlerID; - QItem->iTimeStamp = GetJA2Clock( ); - QItem->fFromSoldier = fFromSoldier; - QItem->fDelayed = fDelayed; + DIALOGUE_Q_STRUCT QItem; + memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + QItem.ubCharacterNum = ubCharacterNum; + QItem.usQuoteNum = usQuoteNum; + QItem.uiSpecialEventFlag = uiSpecialEventFlag; + QItem.uiSpecialEventData = uiSpecialEventData1; + QItem.uiSpecialEventData2 = uiSpecialEventData2; + QItem.uiSpecialEventData3 = uiSpecialEventData3; + QItem.uiSpecialEventData4 = uiSpecialEventData4; + QItem.iFaceIndex = iFaceIndex; + QItem.bUIHandlerID = bUIHandlerID; + QItem.iTimeStamp = GetJA2Clock( ); + QItem.fFromSoldier = fFromSoldier; + QItem.fDelayed = fDelayed; // check if pause already locked, if so, then don't mess with it if( gfLockPauseState == FALSE ) { - QItem->fPauseTime = fPausedTimeDuringQuote; + QItem.fPauseTime = fPausedTimeDuringQuote; } fPausedTimeDuringQuote = FALSE; // Add to queue - ghDialogueQ = AddtoQueue( ghDialogueQ, &QItem ); + ghDialogueQ.push(QItem); return( TRUE ); } @@ -2009,63 +1946,53 @@ BOOLEAN SnitchCharacterDialogue( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 BOOLEAN SpecialCharacterDialogueEvent( UINT32 uiSpecialEventFlag, UINT32 uiSpecialEventData1, UINT32 uiSpecialEventData2, UINT32 uiSpecialEventData3, INT32 iFaceIndex, UINT8 bUIHandlerID ) { - DIALOGUE_Q_STRUCT *QItem; - - // Allocate new item - QItem = (DIALOGUE_Q_STRUCT *) MemAlloc( sizeof( DIALOGUE_Q_STRUCT ) ); - memset( QItem, 0, sizeof( DIALOGUE_Q_STRUCT ) ); - - QItem->uiSpecialEventFlag = uiSpecialEventFlag; - QItem->uiSpecialEventData = uiSpecialEventData1; - QItem->uiSpecialEventData2 = uiSpecialEventData2; - QItem->uiSpecialEventData3 = uiSpecialEventData3; - QItem->iFaceIndex = iFaceIndex; - QItem->bUIHandlerID = bUIHandlerID; - QItem->iTimeStamp = GetJA2Clock( ); + DIALOGUE_Q_STRUCT QItem; + memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + QItem.uiSpecialEventFlag = uiSpecialEventFlag; + QItem.uiSpecialEventData = uiSpecialEventData1; + QItem.uiSpecialEventData2 = uiSpecialEventData2; + QItem.uiSpecialEventData3 = uiSpecialEventData3; + QItem.iFaceIndex = iFaceIndex; + QItem.bUIHandlerID = bUIHandlerID; + QItem.iTimeStamp = GetJA2Clock( ); // if paused state not already locked if( gfLockPauseState == FALSE ) { - QItem->fPauseTime = fPausedTimeDuringQuote; + QItem.fPauseTime = fPausedTimeDuringQuote; } fPausedTimeDuringQuote = FALSE; // Add to queue - ghDialogueQ = AddtoQueue( ghDialogueQ, &QItem ); - + ghDialogueQ.push(QItem); return( TRUE ); } BOOLEAN SpecialCharacterDialogueEventWithExtraParam( UINT32 uiSpecialEventFlag, UINT32 uiSpecialEventData1, UINT32 uiSpecialEventData2, UINT32 uiSpecialEventData3, UINT32 uiSpecialEventData4, INT32 iFaceIndex, UINT8 bUIHandlerID ) { - DIALOGUE_Q_STRUCT *QItem; - - // Allocate new item - QItem = (DIALOGUE_Q_STRUCT *) MemAlloc( sizeof( DIALOGUE_Q_STRUCT ) ); - memset( QItem, 0, sizeof( DIALOGUE_Q_STRUCT ) ); - - QItem->uiSpecialEventFlag = uiSpecialEventFlag; - QItem->uiSpecialEventData = uiSpecialEventData1; - QItem->uiSpecialEventData2 = uiSpecialEventData2; - QItem->uiSpecialEventData3 = uiSpecialEventData3; - QItem->uiSpecialEventData4 = uiSpecialEventData4; - QItem->iFaceIndex = iFaceIndex; - QItem->bUIHandlerID = bUIHandlerID; - QItem->iTimeStamp = GetJA2Clock( ); + DIALOGUE_Q_STRUCT QItem; + memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + QItem.uiSpecialEventFlag = uiSpecialEventFlag; + QItem.uiSpecialEventData = uiSpecialEventData1; + QItem.uiSpecialEventData2 = uiSpecialEventData2; + QItem.uiSpecialEventData3 = uiSpecialEventData3; + QItem.uiSpecialEventData4 = uiSpecialEventData4; + QItem.iFaceIndex = iFaceIndex; + QItem.bUIHandlerID = bUIHandlerID; + QItem.iTimeStamp = GetJA2Clock( ); // if paused state not already locked if( gfLockPauseState == FALSE ) { - QItem->fPauseTime = fPausedTimeDuringQuote; + QItem.fPauseTime = fPausedTimeDuringQuote; } fPausedTimeDuringQuote = FALSE; // Add to queue - ghDialogueQ = AddtoQueue( ghDialogueQ, &QItem ); - + ghDialogueQ.push(QItem); return( TRUE ); } From 4b1de56b016ce375675218ef0ee1fe719ee4e48f Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:45:06 +0300 Subject: [PATCH 040/120] Remove #ifdefs for USE_VFS --- CMakeLists.txt | 2 +- Editor/LoadScreen.cpp | 43 +- Editor/LoadScreen.h | 2 - Editor/Sector Summary.cpp | 176 ----- Laptop/IMP Confirm.cpp | 11 - MainMenuScreen.cpp | 2 - SaveLoadGame.cpp | 28 - SaveLoadScreen.cpp | 2 - Standard Gaming Platform/DEBUG.H | 2 - Standard Gaming Platform/DEBUG.cpp | 2 - Standard Gaming Platform/FileMan.cpp | 902 ------------------------ Standard Gaming Platform/MemMan.cpp | 18 - Standard Gaming Platform/Types.h | 22 +- Standard Gaming Platform/WinFont.cpp | 16 - Standard Gaming Platform/sgp.cpp | 122 ---- Standard Gaming Platform/sgp_logger.cpp | 34 - Standard Gaming Platform/sgp_logger.h | 34 +- Standard Gaming Platform/soundman.cpp | 14 - Standard Gaming Platform/video.cpp | 79 --- Strategic/Campaign Init.cpp | 21 - Strategic/Strategic AI.cpp | 41 -- Strategic/strategicmap.cpp | 75 -- Tactical/Tactical Save.cpp | 26 - TileEngine/SaveLoadMap.cpp | 6 - TileEngine/Shade Table Util.cpp | 31 - TileEngine/WorldDat.cpp | 2 - TileEngine/worlddef.cpp | 8 - Utils/Cinematics Bink.cpp | 16 - Utils/Cinematics.cpp | 18 - Utils/Debug Control.cpp | 20 - Utils/INIReader.cpp | 111 +-- Utils/INIReader.h | 6 +- Utils/message.cpp | 14 - jascreens.cpp | 19 - 34 files changed, 9 insertions(+), 1916 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b196f87e..5a36e848 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set(usingMsBuild $) # TODO: build our own Lua 5.1.2 from source so we can use whichever set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -add_compile_definitions(CINTERFACE XML_STATIC VFS_STATIC VFS_WITH_SLF VFS_WITH_7ZIP USE_VFS _CRT_SECURE_NO_DEPRECATE) +add_compile_definitions(CINTERFACE XML_STATIC VFS_STATIC VFS_WITH_SLF VFS_WITH_7ZIP _CRT_SECURE_NO_DEPRECATE) include_directories(${CMAKE_SOURCE_DIR} "ext/VFS/include" Utils TileEngine TacticalAI ModularizedTacticalAI Tactical Strategic "Standard Gaming Platform" Res Lua Laptop Multiplayer "Multiplayer/raknet" Editor Console) # external libraries diff --git a/Editor/LoadScreen.cpp b/Editor/LoadScreen.cpp index 81a9e024..7c7d70b4 100644 --- a/Editor/LoadScreen.cpp +++ b/Editor/LoadScreen.cpp @@ -83,9 +83,7 @@ INT32 iCurrFileShown; INT32 iLastFileClicked; INT32 iLastClickTime; -#ifdef USE_VFS CHAR8 gzProfileName[FILENAME_BUFLEN];//dnl ch81 021213 -#endif CHAR16 gzFilename[FILENAME_BUFLEN];//dnl ch39 190909 extern INT16 gsSelSectorX; extern INT16 gsSelSectorY; @@ -165,7 +163,6 @@ void LoadSaveScreenEntry() } iTopFileShown = iTotalFiles = 0; -#ifdef USE_VFS//dnl ch37 300909 gzProfileName[0] = 0;//dnl ch81 021213 FDLG_LIST* TempFileList = NULL; vfs::CProfileStack* st = getVFS()->getProfileStack(); @@ -220,25 +217,6 @@ void LoadSaveScreenEntry() } while(FileList->pPrev) FileList = FileList->pPrev; -#else - if(GetFileFirst("MAPS\\*.dat", &FileInfo)) - { - if(strlen(FileInfo.zFileName) < FILENAME_BUFLEN) - { - FileList = AddToFDlgList(FileList, &FileInfo); - iTotalFiles++; - } - while(GetFileNext(&FileInfo)) - { - if(strlen(FileInfo.zFileName) < FILENAME_BUFLEN) - { - FileList = AddToFDlgList(FileList, &FileInfo); - iTotalFiles++; - } - } - GetFileClose(&FileInfo); - } -#endif swprintf( zOrigName, L"%s Map (*.dat)", iCurrentAction == ACTION_SAVE_MAP ? L"Save" : L"Load" ); swprintf( gzFilename, L"%S", gubFilename ); @@ -283,7 +261,8 @@ UINT32 ProcessLoadSaveScreenMessageBoxResult() { if( gfReadOnly ) { - FileClearAttributes( gszCurrFilename ); + // Other call sites have replaced this with FileDelete(); for VFS, should we do the same here? + //FileClearAttributes( gszCurrFilename ); gfReadOnly = FALSE; } FileDelete( gszCurrFilename ); @@ -468,19 +447,6 @@ UINT32 LoadSaveScreenHandle(void) } sprintf(gszCurrFilename, "MAPS\\%S", gzFilename); gfFileExists = FALSE; -#ifndef USE_VFS - gfReadOnly = FALSE; - if(FileExists(gszCurrFilename)) - { - gfFileExists = TRUE; - if(GetFileFirst(gszCurrFilename, &FileInfo)) - { - if(FileInfo.uiFileAttribs & (FILE_IS_READONLY|FILE_IS_DIRECTORY|FILE_IS_HIDDEN|FILE_IS_SYSTEM|FILE_IS_OFFLINE|FILE_IS_TEMPORARY)) - gfReadOnly = TRUE; - GetFileClose(&FileInfo); - } - } -#else gfReadOnly = TRUE; vfs::CProfileStack* st = getVFS()->getProfileStack(); vfs::CProfileStack::Iterator it = st->begin(); @@ -502,7 +468,6 @@ UINT32 LoadSaveScreenHandle(void) } it.next(); } -#endif if(gfReadOnly) { CreateMessageBox(L" File is read only! Choose a different name? "); @@ -726,7 +691,6 @@ void SelectFileDialogYPos( UINT16 usRelativeYPos ) iLastClickTime = iCurrClickTime; iLastFileClicked = x; //dnl ch81 021213 -#ifdef USE_VFS gzProfileName[0] = 0; while(FListNode = FListNode->pPrev) { @@ -737,7 +701,6 @@ void SelectFileDialogYPos( UINT16 usRelativeYPos ) break; } } -#endif break; } FListNode = FListNode->pNext; @@ -950,7 +913,6 @@ void HandleMainKeyEvents( InputAtom *pEvent ) SetInputFieldStringWith16BitString(0, L""); wcscpy(gzFilename, L""); } -#ifdef USE_VFS gzProfileName[0] = 0; while(curr = curr->pPrev) { @@ -961,7 +923,6 @@ void HandleMainKeyEvents( InputAtom *pEvent ) break; } } -#endif } } } diff --git a/Editor/LoadScreen.h b/Editor/LoadScreen.h index 07b08c74..c8adac4c 100644 --- a/Editor/LoadScreen.h +++ b/Editor/LoadScreen.h @@ -51,9 +51,7 @@ extern CHAR16 gzErrorCatchString[ 256 ]; //dnl ch81 031213 extern CHAR16 gzFilename[FILENAME_BUFLEN]; -#ifdef USE_VFS extern CHAR8 gzProfileName[FILENAME_BUFLEN]; -#endif #endif #endif diff --git a/Editor/Sector Summary.cpp b/Editor/Sector Summary.cpp index aa486552..b7174247 100644 --- a/Editor/Sector Summary.cpp +++ b/Editor/Sector Summary.cpp @@ -1923,40 +1923,14 @@ BOOLEAN HandleSummaryInput( InputAtom *pEvent ) void CreateGlobalSummary() { -#ifndef USE_VFS - FILE *fp; - STRING512 Dir; - STRING512 ExecDir; -#endif OutputDebugString( "Generating GlobalSummary Information...\n" ); gfGlobalSummaryExists = FALSE; //Set current directory to JA2\DevInfo which contains all of the summary data -#ifndef USE_VFS - GetExecutableDirectory( ExecDir ); - sprintf( Dir, "%s\\DevInfo", ExecDir ); - - // Snap: save current directory - //GetFileManCurrentDirectory( DataDir ); - - //Directory doesn't exist, so create it, and continue. - if( !MakeFileManDirectory( Dir ) ) - AssertMsg( 0, "Can't create new directory, JA2\\DevInfo for summary information." ); - if( !SetFileManCurrentDirectory( Dir ) ) - AssertMsg( 0, "Can't set to new directory, JA2\\DevInfo for summary information." ); - - //Generate a simple readme file. - fp = fopen( "readme.txt", "w" ); - Assert( fp ); - fprintf( fp, "%s\n%s\n", "This information is used in conjunction with the editor.", - "This directory or it's contents shouldn't be included with final release." ); - fclose( fp ); -#else vfs::COpenWriteFile wfile(L"DevInfo\\readme.txt",true,true); std::string str = "This information is used in conjunction with the editor.\n"; str += "This directory or it's contents shouldn't be included with final release.\n"; SGP_TRYCATCH_RETHROW( wfile->write(str.c_str(), str.length()), L"" ); -#endif // Snap: Restore the data directory once we are finished. //SetFileManCurrentDirectory( DataDir ); @@ -2281,12 +2255,6 @@ void CalculateOverrideStatus() void LoadGlobalSummary() { HWFILE hfile; -#ifndef USE_VFS - STRING512 DataDir; - STRING512 ExecDir; - STRING512 DevInfoDir; - STRING512 MapsDir; -#endif UINT32 uiNumBytesRead; FLOAT dMajorVersion; INT32 x,y; @@ -2295,34 +2263,16 @@ void LoadGlobalSummary() OutputDebugString( "Executing LoadGlobalSummary()...\n" ); // Snap: save current directory -#ifndef USE_VFS - GetFileManCurrentDirectory( DataDir ); -#endif gfMustForceUpdateAllMaps = FALSE; gusNumberOfMapsToBeForceUpdated = 0; gfGlobalSummaryExists = FALSE; //Set current directory to JA2\DevInfo which contains all of the summary data -#ifndef USE_VFS - GetExecutableDirectory( ExecDir ); - sprintf( DevInfoDir, "%s\\DevInfo", ExecDir ); - sprintf( MapsDir, "%s\\Maps", DataDir ); - //Check to make sure we have a DevInfo directory. If we don't create one! - if( !SetFileManCurrentDirectory( DevInfoDir ) ) - { - OutputDebugString( "LoadGlobalSummary() aborted -- doesn't exist on this local computer.\n"); - return; - } -#endif //TEMP -#ifndef USE_VFS - FileDelete( "_global.sum" ); -#else if(FileExists("DevInfo\\_global.sum")) { FileDelete( "DevInfo\\_global.sum" ); } -#endif gfGlobalSummaryExists = TRUE; //Analyse all sectors to see if matching maps exist. For any maps found, the information @@ -2337,19 +2287,12 @@ void LoadGlobalSummary() sprintf( szSector, "%c%d", 'A' + y, x + 1 ); //main ground level -#ifndef USE_VFS - sprintf( szFilename, "%c%d.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= GROUND_LEVEL_MASK; @@ -2359,27 +2302,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s.sum", szSector ); -#endif FileDelete( szFilename ); } //main B1 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b1.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b1.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= BASEMENT1_LEVEL_MASK; @@ -2389,27 +2321,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b1.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b1.sum", szSector ); -#endif FileDelete( szFilename ); } //main B2 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b2.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b2.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= BASEMENT2_LEVEL_MASK; @@ -2419,27 +2340,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b2.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b2.sum", szSector ); -#endif FileDelete( szFilename ); } //main B3 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b3.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b3.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= BASEMENT3_LEVEL_MASK; @@ -2449,27 +2359,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b3.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b3.sum", szSector ); -#endif FileDelete( szFilename ); } //alternate ground level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_a.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_a.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= ALTERNATE_GROUND_MASK; @@ -2479,27 +2378,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_a.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_a.sum", szSector ); -#endif FileDelete( szFilename ); } //alternate B1 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b1_a.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b1_a.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= ALTERNATE_B1_MASK; @@ -2509,27 +2397,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b1_a.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b1_a.sum", szSector ); -#endif FileDelete( szFilename ); } //alternate B2 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b2_a.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b2_a.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= ALTERNATE_B2_MASK; @@ -2539,27 +2416,16 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b2_a.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b2_a.sum", szSector ); -#endif FileDelete( szFilename ); } //alternate B3 level -#ifndef USE_VFS - sprintf( szFilename, "%c%d_b3_a.dat", 'A' + y, x + 1 ); - SetFileManCurrentDirectory( MapsDir ); - hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - SetFileManCurrentDirectory( DevInfoDir ); -#else sprintf( szFilename, "Maps\\%c%d_b3_a.dat", 'A' + y, x + 1 ); hfile = NULL; if(FileExists(szFilename)) { hfile = FileOpen( szFilename, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); } -#endif if( hfile ) { gbSectorLevels[x][y] |= ALTERNATE_B1_MASK;; @@ -2569,20 +2435,12 @@ void LoadGlobalSummary() } else { -#ifndef USE_VFS - sprintf( szFilename, "%s_b3_a.sum", szSector ); -#else sprintf( szFilename, "DevInfo\\%s_b3_a.sum", szSector ); -#endif FileDelete( szFilename ); } } OutputDebugString( (LPCSTR)String("Sector Row %c complete... \n", y + 'A') ); } -#ifndef USE_VFS - // Snap: Restore the data directory once we are finished. - SetFileManCurrentDirectory( DataDir ); -#endif //sprintf( MapsDir, "%s\\Data", ExecDir ); //SetFileManCurrentDirectory( MapsDir ); @@ -2599,39 +2457,6 @@ void LoadGlobalSummary() void GenerateSummaryList() { -#ifndef USE_VFS - FILE *fp; - STRING512 DataDir; - STRING512 ExecDir; - STRING512 Dir; - - // Snap: save current directory - GetFileManCurrentDirectory( DataDir ); - - //Set current directory to JA2\DevInfo which contains all of the summary data - GetExecutableDirectory( ExecDir ); - sprintf( Dir, "%s\\DevInfo", ExecDir ); - if( !SetFileManCurrentDirectory( Dir ) ) - { - //Directory doesn't exist, so create it, and continue. - if( !MakeFileManDirectory( Dir ) ) - AssertMsg( 0, "Can't create new directory, JA2\\DevInfo for summary information." ); - if( !SetFileManCurrentDirectory( Dir ) ) - AssertMsg( 0, "Can't set to new directory, JA2\\DevInfo for summary information." ); - //Generate a simple readme file. - fp = fopen( "readme.txt", "w" ); - Assert( fp ); - fprintf( fp, "%s\n%s\n", "This information is used in conjunction with the editor.", - "This directory or it's contents shouldn't be included with final release." ); - fclose( fp ); - } - - // Snap: Restore the data directory once we are finished. - SetFileManCurrentDirectory( DataDir ); - //Set current directory back to data directory! - //sprintf( Dir, "%s\\Data", ExecDir ); - //SetFileManCurrentDirectory( Dir ); -#else try { vfs::COpenWriteFile wfile(L"DevInfo/readme.txt",true,true); @@ -2643,7 +2468,6 @@ void GenerateSummaryList() { SGP_RETHROW(L"Could not create readme.txt", ex); } -#endif } //dnl ch28 260909 diff --git a/Laptop/IMP Confirm.cpp b/Laptop/IMP Confirm.cpp index 81780462..fd74d9f2 100644 --- a/Laptop/IMP Confirm.cpp +++ b/Laptop/IMP Confirm.cpp @@ -1336,16 +1336,6 @@ void WriteOutCurrentImpCharacter( INT32 iProfileId ) DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("WriteOutCurrentImpCharacter: Nickname.dat")); -#ifndef USE_VFS - char zFileName[13]; - char temp; - - for(int i=0;i < 9;i++) // Madd: I couldn't get strcpy or anything to work here... weird... if s/o wants to fix it, go ahead - { - temp = (char) gMercProfiles[iProfileId].zNickname[i]; - zFileName[i] = temp; - } -#else char zFileName[32]; if(vfs::Settings::getUseUnicode()) { @@ -1355,7 +1345,6 @@ void WriteOutCurrentImpCharacter( INT32 iProfileId ) { vfs::String::narrow(gMercProfiles[iProfileId].zNickname, 10, zFileName, 32); } -#endif // Changed by ADB, rev 1513 //strcat(zFileName,IMP_FILENAME_SUFFIX); diff --git a/MainMenuScreen.cpp b/MainMenuScreen.cpp index bebe6193..22d2a266 100644 --- a/MainMenuScreen.cpp +++ b/MainMenuScreen.cpp @@ -248,7 +248,6 @@ BOOLEAN InitMainMenu( ) { is_networked = FALSE; -#ifdef USE_VFS // remove Multiplayer profile if it exists vfs::CProfileStack *PS = getVFS()->getProfileStack(); vfs::CVirtualProfile *pProf = PS->getProfile("_MULTIPLAYER"); @@ -256,7 +255,6 @@ BOOLEAN InitMainMenu( ) { SGP_THROW_IFFALSE(PS->popProfile(), "Leaving Multiplayer mode : Could not remove \"_MULTIPLAYER\" profile"); } -#endif // Snap: UN-Init MP save game directory if ( !InitSaveDir() ) diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index 3d90f27e..a013b455 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -3553,33 +3553,6 @@ BOOLEAN Inventory::Save( HWFILE hFile, bool fSavingMap ) // The save directory now resides in the data directory (default or custom) BOOLEAN InitSaveDir() { -#ifndef USE_VFS - // Look for a custom data dir first - std::string dataDir = gCustomDataCat.GetRootDir(); - if( dataDir.empty() || FileGetAttributes( (STR) dataDir.c_str() ) == 0xFFFFFFFF ) { - dataDir = gDefaultDataCat.GetRootDir(); - } - - // The locale-specific save dir location is of the form L"..\\SavedGames" - // This has not changed; instead, we strip the ".." at the beginning - if(is_networked) - { - sprintf( gSaveDir, "%s%S", dataDir.c_str(), pMessageStrings[ MSG_MPSAVEDIRECTORY ] + 2 ); - } - else - sprintf( gSaveDir, "%s%S", dataDir.c_str(), pMessageStrings[ MSG_SAVEDIRECTORY ] + 2 ); - - // This was moved here from SaveGame - //Check to see if the save directory exists - if( FileGetAttributes( (STR) gSaveDir ) == 0xFFFFFFFF ) - { - //ok the direcotry doesnt exist, create it - if( !MakeFileManDirectory( (CHAR8 *)gSaveDir ) ) - { - return FALSE; - } - } -#else if(is_networked) { sprintf( gSaveDir, "%s", vfs::String::as_utf8(pMessageStrings[ MSG_MPSAVEDIRECTORY ] + 3).c_str() ); @@ -3588,7 +3561,6 @@ BOOLEAN InitSaveDir() { sprintf( gSaveDir, "%s", vfs::String::as_utf8(pMessageStrings[ MSG_SAVEDIRECTORY ] + 3).c_str() ); } -#endif return TRUE; } diff --git a/SaveLoadScreen.cpp b/SaveLoadScreen.cpp index 5fe319ff..e5442659 100644 --- a/SaveLoadScreen.cpp +++ b/SaveLoadScreen.cpp @@ -1350,7 +1350,6 @@ BOOLEAN InitSaveGameArray() gbSaveGameArray[VAL_SLOT_START + cnt] = TRUE; // anv: read last modified date property of save file -#ifdef USE_VFS // get full path to save file vfs::Path vfsPath; vfs::COpenReadFile rfile(zSaveGameName); @@ -1369,7 +1368,6 @@ BOOLEAN InitSaveGameArray() // close CloseHandle( hFile ); rfile->close(); -#endif } } else diff --git a/Standard Gaming Platform/DEBUG.H b/Standard Gaming Platform/DEBUG.H index 2b2e3169..1d0d0c3e 100644 --- a/Standard Gaming Platform/DEBUG.H +++ b/Standard Gaming Platform/DEBUG.H @@ -252,10 +252,8 @@ namespace sgp // compatibility with std::exception Exception(WString const& msg, std::exception& ex SGP_CALLER_LOCATION); -#if defined(USE_VFS) // compatibility with vfs::Exception Exception(WString const& msg, vfs::Exception& ex SGP_CALLER_LOCATION); -#endif virtual const char* what() const throw(); diff --git a/Standard Gaming Platform/DEBUG.cpp b/Standard Gaming Platform/DEBUG.cpp index 8463e9fb..2aad673b 100644 --- a/Standard Gaming Platform/DEBUG.cpp +++ b/Standard Gaming Platform/DEBUG.cpp @@ -562,7 +562,6 @@ sgp::Exception::Exception(sgp::WString const& msg, Exception& ex SGP_CALLER_LOCA _msg.push_back(excp); } -#if defined(USE_VFS) sgp::Exception::Exception(sgp::WString const& msg, vfs::Exception& ex SGP_CALLER_LOCATION_IMPL) { vfs::Exception::CALLSTACK::iterator it = ex.m_CallStack.begin(); @@ -584,7 +583,6 @@ sgp::Exception::Exception(sgp::WString const& msg, vfs::Exception& ex SGP_CALLER _msg.push_back(excp); } -#endif sgp::Exception::Exception(WString const& msg, std::exception& ex SGP_CALLER_LOCATION_IMPL) { diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index 0de5e3d8..e7f2a1d0 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -47,7 +47,6 @@ using namespace std; #include #include -#ifdef USE_VFS #include #include @@ -66,7 +65,6 @@ struct SOperation typedef std::map tFILEMAP; static tFILEMAP s_mapFiles; -#endif //************************************************************************** // // Defines @@ -250,26 +248,7 @@ void FileDebug( BOOLEAN f ) //************************************************************************** BOOLEAN FileExists( STR strFilename ) { -#ifdef USE_VFS return getVFS()->fileExists(vfs::Path(strFilename)); -#else - // First check to see if it's in a library (most files should be there) - if ( gFileDataBase.fInitialized && - CheckIfFileExistInLibrary( strFilename ) ) return TRUE; - - // ... then check if it's in the custom Data directory - if ( gCustomDataCat.FindFile(strFilename) ) return TRUE; - - // ... then check if it's in the default Data directory - if ( gDefaultDataCat.FindFile(strFilename) ) return TRUE; - - // ... lastly, try to locate it in the file system - DWORD attribs = GetFileAttributes(strFilename); - if ( attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY) ) - return TRUE; - - return FALSE; -#endif } //************************************************************************** @@ -296,22 +275,7 @@ BOOLEAN FileExists( STR strFilename ) //************************************************************************** extern BOOLEAN FileExistsNoDB( STR strFilename ) { -#ifdef USE_VFS return getVFS()->fileExists(vfs::Path(strFilename)); -#else - // First check if it's in the custom Data directory - if ( gCustomDataCat.FindFile(strFilename) ) return TRUE; - - // ... then check if it's in the default Data directory - if ( gDefaultDataCat.FindFile(strFilename) ) return TRUE; - - // ... lastly, try to locate it in the file system - DWORD attribs = GetFileAttributes(strFilename); - if ( attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY) ) - return TRUE; - - return FALSE; -#endif } //************************************************************************** @@ -336,16 +300,7 @@ extern BOOLEAN FileExistsNoDB( STR strFilename ) //************************************************************************** BOOLEAN FileDelete( STR strFilename ) { -#ifdef USE_VFS return getVFS()->removeFileFromFS(vfs::Path(strFilename)); -#else - // Snap: delete the file from the default Data catalogue (if it is there) - // Since the path can be either relative or absolute, try both methods - gDefaultDataCat.RemoveFile(strFilename, true); - gDefaultDataCat.RemoveFile(strFilename, false); - - return( DeleteFile( (LPCSTR) strFilename ) ); -#endif } //************************************************************************** @@ -375,7 +330,6 @@ BOOLEAN FileDelete( STR strFilename ) //************************************************************************** HWFILE FileOpen( STR strFilename, UINT32 uiOptions, BOOLEAN fDeleteOnClose, STR strProfilename )//dnl ch81 021213 { -#ifdef USE_VFS vfs::Path path(strFilename); vfs::IBaseFile *pFile = NULL; try @@ -418,148 +372,6 @@ HWFILE FileOpen( STR strFilename, UINT32 uiOptions, BOOLEAN fDeleteOnClose, STR SGP_ERROR( "Caught undefined exception" ); } return 0; -#else - HWFILE hFile; - HANDLE hRealFile; - DWORD dwAccess; - DWORD dwFlagsAndAttributes; - BOOLEAN fExists; - HDBFILE hDBFile; - DWORD dwCreationFlags; - HWFILE hLibFile; - - hFile = 0; - hDBFile = 0; - dwCreationFlags = 0; - - dwAccess = 0; - if ( uiOptions & FILE_ACCESS_READ ) - dwAccess |= GENERIC_READ; - if ( uiOptions & FILE_ACCESS_WRITE ) - dwAccess |= GENERIC_WRITE; - - dwFlagsAndAttributes = FILE_FLAG_RANDOM_ACCESS; - if ( fDeleteOnClose ) - dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE; - - // Snap: This seems like an unnecessary check, but I don't feel like - // rewriting the function to eliminate it... - - // check if the file exists - note that we use the function FileExistsNoDB - // because it doesn't check the databases, and we don't want to do that here - fExists = FileExistsNoDB( strFilename ); - - // Snap: First see if the file is in the custom Data catalogue: - std::string filePath; - if ( gCustomDataCat.FindFile(strFilename) ) { - filePath = gCustomDataCat.GetRootDir() + '\\'; - } - filePath += strFilename; - // Bad cast! strFilename should have been const. Oh well... - strFilename = const_cast( filePath.c_str() ); - // Now strFilename points either to the original file name, - // or to the full file path in the custom Data directory. - // Except for this substitution, the rest of the function is unchanged. - - //if the file is on the disk - if ( fExists ) - { - hRealFile = CreateFile( (LPCSTR) strFilename, dwAccess, 0, NULL, OPEN_ALWAYS, - dwFlagsAndAttributes, NULL ); - - if ( hRealFile == INVALID_HANDLE_VALUE ) - { - return(0); - } - - //create a file handle for the 'real file' - hFile = CreateRealFileHandle( hRealFile ); - } - - // if the file did not exist, try to open it from the database - else if ( gFileDataBase.fInitialized ) - { - //if the file is to be opened for writing, return an error cause you cant write a file that is in the database library - if( fDeleteOnClose ) - { - return( 0 ); - } - - //if the file doesnt exist on the harddrive, but it is to be created, dont try to load it from the file database - if( uiOptions & FILE_ACCESS_WRITE ) - { - //if the files is to be written to - if( ( uiOptions & FILE_CREATE_NEW ) || ( uiOptions & FILE_OPEN_ALWAYS ) || ( uiOptions & FILE_CREATE_ALWAYS ) || ( uiOptions & FILE_TRUNCATE_EXISTING ) ) - { - hFile = 0; - } - } - //else if the file is to be opened using FILE_OPEN_EXISTING, and the file doesnt exists, fail out of the function) -// else if( uiOptions & FILE_OPEN_EXISTING ) -// { - //fail out of the function -// return( 0 ); -// } - else - { - //If the file is in the library, get a handle to it. - hLibFile = OpenFileFromLibrary( strFilename ); - - //tried to open a file that wasnt in the database - if( !hLibFile ) - return( 0 ); - else - return( hLibFile ); //return the file handle - } - } - - if ( !hFile ) - { - if ( uiOptions & FILE_CREATE_NEW ) - { - dwCreationFlags = CREATE_NEW; - } - else if ( uiOptions & FILE_CREATE_ALWAYS ) - { - dwCreationFlags = CREATE_ALWAYS; - } - else if ( uiOptions & FILE_OPEN_EXISTING || uiOptions & FILE_ACCESS_READ ) - { - dwCreationFlags = OPEN_EXISTING; - } - else if ( uiOptions & FILE_OPEN_ALWAYS ) - { - dwCreationFlags = OPEN_ALWAYS; - } - else if ( uiOptions & FILE_TRUNCATE_EXISTING ) - { - dwCreationFlags = TRUNCATE_EXISTING; - } - else - { - dwCreationFlags = OPEN_ALWAYS; - } - - - hRealFile = CreateFile( (LPCSTR) strFilename, dwAccess, 0, NULL, dwCreationFlags, - dwFlagsAndAttributes, NULL ); - if ( hRealFile == INVALID_HANDLE_VALUE ) - { - UINT32 uiLastError = GetLastError(); - char zString[1024]; - FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, 0, uiLastError, 0, zString, 1024, NULL); - - return(0); - } - - hFile = CreateRealFileHandle( hRealFile ); - } - - if ( !hFile ) - return(0); - - return(hFile); -#endif } //************************************************************************** @@ -581,43 +393,12 @@ HWFILE FileOpen( STR strFilename, UINT32 uiOptions, BOOLEAN fDeleteOnClose, STR //************************************************************************** void FileClose( HWFILE hFile ) { -#ifdef USE_VFS vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; if(pFile) { pFile->close(); s_mapFiles.erase(pFile); } -#else - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its the 'real file' library - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //if its not already closed - if( gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].uiFileID != 0 ) - { - CloseHandle( gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle ); - gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].uiFileID = 0; - gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle= 0; - gFileDataBase.RealFiles.iNumFilesOpen--; - if( gFileDataBase.RealFiles.iNumFilesOpen < 0 ) - { - //if for some reason we are below 0, report an error ( should never be ) - Assert( 0 ); - } - } - } - else - { - //if the database is initialized - if( gFileDataBase.fInitialized ) - CloseLibraryFile( sLibraryID, uiFileNum ); - } -#endif } //************************************************************************** @@ -669,7 +450,6 @@ private: BOOLEAN FileRead( HWFILE hFile, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiBytesRead ) { -#ifdef USE_VFS #ifdef JA2TESTVERSION TimeCounter timer; #endif @@ -702,80 +482,10 @@ BOOLEAN FileRead( HWFILE hFile, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiByte } } return FALSE; -#else - HANDLE hRealFile; - DWORD dwNumBytesToRead, dwNumBytesRead; - BOOLEAN fRet = FALSE; - INT16 sLibraryID; - UINT32 uiFileNum; - -#ifdef JA2TESTVERSION - UINT32 uiStartTime = GetJA2Clock(); -#endif - - //init the variables - dwNumBytesToRead = dwNumBytesRead = 0; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - dwNumBytesToRead = (DWORD)uiBytesToRead; - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //if the file is opened - if( uiFileNum != 0 ) - { - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - fRet = ReadFile( hRealFile, pDest, dwNumBytesToRead, &dwNumBytesRead, NULL ); - if ( dwNumBytesToRead != dwNumBytesRead ) - { - UINT32 uiLastError = GetLastError(); - char zString[1024]; - FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, 0, uiLastError, 0, zString, 1024, NULL); - - fRet = FALSE; - } - - if ( puiBytesRead ) - *puiBytesRead = (UINT32)dwNumBytesRead; - } - } - else - { - //if the database is initialized - if( gFileDataBase.fInitialized ) - { - //if the library is open - if( IsLibraryOpened( sLibraryID ) ) - { - //if the file is opened - if( gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFileID != 0 ) - { - //read the data from the library - fRet = LoadDataFromLibrary( sLibraryID, uiFileNum, pDest, dwNumBytesToRead, (UINT32 *) &dwNumBytesRead ); - if ( puiBytesRead ) - { - *puiBytesRead = (UINT32)dwNumBytesRead; - } - } - } - } - } - #ifdef JA2TESTVERSION - //Add the time that we spent in this function to the total. - uiTotalFileReadTime += GetJA2Clock() - uiStartTime; - uiTotalFileReadCalls++; - #endif - - return(fRet); -#endif } BOOLEAN FileReadLine( HWFILE hFile, std::string* pDest ) { -#ifdef USE_VFS vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; if ( pFile && FileCheckEndOfFile( hFile ) == FALSE && (s_mapFiles[pFile].op == SOperation::READ) ) { @@ -787,7 +497,6 @@ BOOLEAN FileReadLine( HWFILE hFile, std::string* pDest ) return TRUE; } } -#endif // ifdef USE_VFS return FALSE; } @@ -836,7 +545,6 @@ BOOLEAN FileReadLine( HWFILE hFile, STR8 pDest, UINT32 uiDestSize, UINT32 *puiBy BOOLEAN FileWrite( HWFILE hFile, PTR pDest, UINT32 uiBytesToWrite, UINT32 *puiBytesWritten ) { -#ifdef USE_VFS if(uiBytesToWrite == 0)//dnl ch38 110909 { *puiBytesWritten = 0; @@ -871,42 +579,6 @@ BOOLEAN FileWrite( HWFILE hFile, PTR pDest, UINT32 uiBytesToWrite, UINT32 *puiBy } } return FALSE; -#else - HANDLE hRealFile; - DWORD dwNumBytesToWrite, dwNumBytesWritten; - BOOLEAN fRet; - INT16 sLibraryID; - UINT32 uiFileNum; - - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - dwNumBytesToWrite = (DWORD)uiBytesToWrite; - - //get the real file handle to the file - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - fRet = WriteFile( hRealFile, pDest, dwNumBytesToWrite, &dwNumBytesWritten, NULL ); - - if (dwNumBytesToWrite != dwNumBytesWritten) - fRet = FALSE; - - if ( puiBytesWritten ) - *puiBytesWritten = (UINT32)dwNumBytesWritten; - } - else - { - //we cannot write to a library file - if ( puiBytesWritten ) - *puiBytesWritten = 0; - return(FALSE); - } - - return(fRet); -#endif } //************************************************************************** @@ -932,7 +604,6 @@ BOOLEAN FileWrite( HWFILE hFile, PTR pDest, UINT32 uiBytesToWrite, UINT32 *puiBy BOOLEAN FileLoad( STR strFilename, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiBytesRead ) { -#ifdef USE_VFS vfs::tReadableFile *pFile = getVFS()->getReadFile(vfs::Path(strFilename)); vfs::COpenReadFile rfile(pFile); if(pFile) @@ -952,30 +623,6 @@ BOOLEAN FileLoad( STR strFilename, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiB return TRUE; } return FALSE; -#else - HWFILE hFile; - UINT32 uiNumBytesRead; - BOOLEAN fRet; - - hFile = FileOpen( strFilename, FILE_ACCESS_READ, FALSE ); - if ( hFile ) - { - fRet = FileRead( hFile, pDest, uiBytesToRead, &uiNumBytesRead ); - FileClose( hFile ); - - if (uiBytesToRead != uiNumBytesRead) - fRet = FALSE; - - if ( puiBytesRead ) - *puiBytesRead = uiNumBytesRead; - - CHECKF( uiNumBytesRead == uiBytesToRead ); - } - else - fRet = FALSE; - - return(fRet); -#endif } //************************************************************************** @@ -1008,7 +655,6 @@ BOOLEAN FileLoad( STR strFilename, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiB BOOLEAN _cdecl FilePrintf( HWFILE hFile, STR8 strFormatted, ... ) { -#ifdef USE_VFS CHAR8 strToSend[160]; /* itemdescription of item 0 will NOT fit if only 80 Chars per Line!, Sergeant_Kolja, 2007-06-10 */ va_list argptr; BOOLEAN fRetVal = FALSE; @@ -1020,34 +666,6 @@ BOOLEAN _cdecl FilePrintf( HWFILE hFile, STR8 strFormatted, ... ) fRetVal = FileWrite( hFile, strToSend, strlen(strToSend), NULL ); return( fRetVal ); -#else - CHAR8 strToSend[160]; /* itemdescription of item 0 will NOT fit if only 80 Chars per Line!, Sergeant_Kolja, 2007-06-10 */ - va_list argptr; - BOOLEAN fRetVal = FALSE; - - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - va_start(argptr, strFormatted); - _vsnprintf( strToSend, DIM(strToSend), strFormatted, argptr ); /* made StringLen Save, Sergeant_Kolja, 2007-06-10 */ - strToSend[ DIM(strToSend)-1 ] = 0; - va_end(argptr); - - fRetVal = FileWrite( hFile, strToSend, strlen(strToSend), NULL ); - } - else - { - //its a library file, cant write to it so return an error - fRetVal = FALSE; - } - - return( fRetVal ); -#endif } //************************************************************************** @@ -1077,7 +695,6 @@ BOOLEAN _cdecl FilePrintf( HWFILE hFile, STR8 strFormatted, ... ) BOOLEAN FileSeek( HWFILE hFile, UINT32 uiDistance, UINT8 uiHow ) { -#ifdef USE_VFS INT32 iDistance = (INT32)uiDistance; vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; @@ -1125,50 +742,6 @@ BOOLEAN FileSeek( HWFILE hFile, UINT32 uiDistance, UINT8 uiHow ) } } return FALSE; -#else - HANDLE hRealFile; - LONG lDistanceToMove; - DWORD dwMoveMethod; - INT32 iDistance=0; - - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //Get the handle to the real file - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - iDistance = (INT32) uiDistance; - - if ( uiHow == FILE_SEEK_FROM_START ) - dwMoveMethod = FILE_BEGIN; - else if ( uiHow == FILE_SEEK_FROM_END ) - { - dwMoveMethod = FILE_END; - if( iDistance > 0 ) - iDistance = -(iDistance); - } - else - dwMoveMethod = FILE_CURRENT; - - lDistanceToMove = (LONG)uiDistance; - - if ( SetFilePointer( hRealFile, iDistance, NULL, dwMoveMethod ) == 0xFFFFFFFF ) - return(FALSE); - } - else - { - //if the database is initialized - if( gFileDataBase.fInitialized ) - LibraryFileSeek( sLibraryID, uiFileNum, uiDistance, uiHow ); - } - - return(TRUE); -#endif } //************************************************************************** @@ -1196,7 +769,6 @@ BOOLEAN FileSeek( HWFILE hFile, UINT32 uiDistance, UINT8 uiHow ) INT32 FileGetPos( HWFILE hFile ) { -#ifdef USE_VFS vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; if(pFile && (s_mapFiles[pFile].op == SOperation::WRITE)) { @@ -1216,44 +788,6 @@ INT32 FileGetPos( HWFILE hFile ) } return BAD_INDEX; -#else - HANDLE hRealFile; - UINT32 uiPositionInFile=0; - - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //Get the handle to the real file - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - uiPositionInFile = SetFilePointer( hRealFile, 0, NULL, FILE_CURRENT); - if( uiPositionInFile == 0xFFFFFFFF ) - { - uiPositionInFile = 0; - } - return( uiPositionInFile ); - } - else - { - //if the library is open - if( IsLibraryOpened( sLibraryID ) ) - { - //check if the file is open - if( gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFileID != 0 ) - { - uiPositionInFile = gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFilePosInFile; - return( uiPositionInFile ); - } - } - } - - return(BAD_INDEX); -#endif } //************************************************************************** @@ -1281,43 +815,12 @@ INT32 FileGetPos( HWFILE hFile ) UINT32 FileGetSize( HWFILE hFile ) { -#ifdef USE_VFS vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; if(pFile) { return pFile->getSize(); } return 0; -#else - HANDLE hRealHandle; - UINT32 uiFileSize = 0xFFFFFFFF; - - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //Get the handle to a real file - hRealHandle = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - uiFileSize = GetFileSize( hRealHandle, NULL ); - } - else - { - //if the library is open - if( IsLibraryOpened( sLibraryID ) ) - uiFileSize = gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].pFileHeader->uiFileLength; - } - - - if ( uiFileSize == 0xFFFFFFFF ) - return(0); - else - return( uiFileSize ); -#endif } //************************************************************************** @@ -1632,9 +1135,6 @@ INT32 GetFilesInDirectory( HCONTAINER hStack, CHAR *pcDir, HANDLE hFile, WIN32_F BOOLEAN SetFileManCurrentDirectory( STR pcDirectory ) { -#ifndef USE_VFS - return( SetCurrentDirectory( pcDirectory ) ); -#else try { vfs::OS::setCurrectDirectory(pcDirectory); @@ -1645,19 +1145,11 @@ BOOLEAN SetFileManCurrentDirectory( STR pcDirectory ) return FALSE; } return TRUE; -#endif } BOOLEAN GetFileManCurrentDirectory( STRING512 pcDirectory ) { -#ifndef USE_VFS - if (GetCurrentDirectory( 512, pcDirectory ) == 0) - { - return( FALSE ); - } - return( TRUE ); -#else try { vfs::Path sDir; @@ -1670,7 +1162,6 @@ BOOLEAN GetFileManCurrentDirectory( STRING512 pcDirectory ) return FALSE; } return TRUE; -#endif } @@ -1707,11 +1198,7 @@ BOOLEAN DirectoryExists( STRING512 pcDirectory ) BOOLEAN MakeFileManDirectory( STRING512 pcDirectory ) { -#ifndef USE_VFS - return CreateDirectory( pcDirectory, NULL ); -#else return FALSE; -#endif } @@ -1721,87 +1208,8 @@ BOOLEAN MakeFileManDirectory( STRING512 pcDirectory ) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// BOOLEAN RemoveFileManDirectory( STRING512 pcDirectory, BOOLEAN fRecursive ) { -#ifdef USE_VFS // ignore 'recursive' flag, just delete every file in that subtree (but leave the directories) return getVFS()->removeDirectoryFromFS(pcDirectory); -#else - WIN32_FIND_DATA sFindData; - HANDLE SearchHandle; - const CHAR8 *pFileSpec = "*.*"; - BOOLEAN fDone = FALSE; - BOOLEAN fRetval=FALSE; - CHAR8 zOldDir[512]; - CHAR8 zSubdirectory[512]; - - GetFileManCurrentDirectory( zOldDir ); - - if( !SetFileManCurrentDirectory( pcDirectory ) ) - { - FastDebugMsg(String("RemoveFileManDirectory: ERROR - SetFileManCurrentDirectory on %s failed, error %d", pcDirectory, GetLastError())); - return( FALSE ); //Error going into directory - } - - //If there are files in the directory, DELETE THEM - SearchHandle = FindFirstFile( pFileSpec, &sFindData); - if( SearchHandle != INVALID_HANDLE_VALUE ) - { - - fDone = FALSE; - do - { - // if the object is a directory - if( GetFileAttributes( sFindData.cFileName ) == FILE_ATTRIBUTE_DIRECTORY ) - { - // only go in if the fRecursive flag is TRUE (like Deltree) - if (fRecursive) - { - sprintf(zSubdirectory, "%s\\%s", pcDirectory, sFindData.cFileName); - - if ((strcmp(sFindData.cFileName, ".") != 0) && (strcmp(sFindData.cFileName, "..") != 0)) - { - if (!RemoveFileManDirectory(zSubdirectory, TRUE)) - { - FastDebugMsg(String("RemoveFileManDirectory: ERROR - Recursive call on %s failed", zSubdirectory)); - break; - } - } - } - // otherwise, all the individual files will be deleted, but the subdirectories remain, causing - // RemoveDirectory() at the end to fail, thus this function will return FALSE in that event (failure) - } - else - { - FileDelete( sFindData.cFileName ); - } - - //find the next file in the directory - fRetval = FindNextFile( SearchHandle, &sFindData ); - if( fRetval == 0 ) - { - fDone = TRUE; - } - } while(!fDone); - - // very important: close the find handle, or subsequent RemoveDirectory() calls will fail - FindClose( SearchHandle ); - } - - if( !SetFileManCurrentDirectory( zOldDir ) ) - { - FastDebugMsg(String("RemoveFileManDirectory: ERROR - SetFileManCurrentDirectory on %s failed, error %d", zOldDir, GetLastError())); - return( FALSE ); //Error returning from subdirectory - } - - - // The directory MUST be empty - fRetval = RemoveDirectory( pcDirectory ); - if (!fRetval) - { - FastDebugMsg(String("RemoveFileManDirectory: ERROR - RemoveDirectory on %s failed, error %d", pcDirectory, GetLastError())); - } - - return fRetval; -#endif } @@ -1811,102 +1219,22 @@ BOOLEAN RemoveFileManDirectory( STRING512 pcDirectory, BOOLEAN fRecursive ) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// BOOLEAN EraseDirectory( STRING512 pcDirectory) { -#ifdef USE_VFS // ignore 'recursive' flag, just delete every file in that subtree (but leave the directories) return getVFS()->removeDirectoryFromFS(pcDirectory); -#else - WIN32_FIND_DATA sFindData; - HANDLE SearchHandle; - const CHAR8 *pFileSpec = "*.*"; - BOOLEAN fDone = FALSE; - CHAR8 zOldDir[512]; - - GetFileManCurrentDirectory( zOldDir ); - - if( !SetFileManCurrentDirectory( pcDirectory ) ) - { - FastDebugMsg(String("EraseDirectory: ERROR - SetFileManCurrentDirectory on %s failed, error %d", pcDirectory, GetLastError())); - return( FALSE ); //Error going into directory - } - - //If there are files in the directory, DELETE THEM - SearchHandle = FindFirstFile( pFileSpec, &sFindData); - if( SearchHandle != INVALID_HANDLE_VALUE ) - { - - fDone = FALSE; - do - { - // if it's a file, not a directory - if( GetFileAttributes( sFindData.cFileName ) != FILE_ATTRIBUTES_DIRECTORY ) - { - FileDelete( sFindData.cFileName ); - } - - //find the next file in the directory - if ( !FindNextFile( SearchHandle, &sFindData )) - { - fDone = TRUE; - } - } while(!fDone); - - // very important: close the find handle, or subsequent RemoveDirectory() calls will fail - FindClose( SearchHandle ); - } - - // Snap: Delete the directory from the default Data catalogue (if it is there) - // Since the path can be either relative or absolute, try both methods - gDefaultDataCat.RemoveDir(pcDirectory, true); - gDefaultDataCat.RemoveDir(pcDirectory, false); - - if( !SetFileManCurrentDirectory( zOldDir ) ) - { - FastDebugMsg(String("EraseDirectory: ERROR - SetFileManCurrentDirectory on %s failed, error %d", zOldDir, GetLastError())); - return( FALSE ); //Error returning from directory - } - - return( TRUE ); -#endif } BOOLEAN GetExecutableDirectory( STRING512 pcDirectory ) { -#ifdef USE_VFS vfs::Path exe_dir, exe_file; vfs::OS::getExecutablePath(exe_dir, exe_file); strncpy(pcDirectory, exe_dir.to_string().c_str(), 512); return true; -#else - SGPFILENAME ModuleFilename; - UINT32 cnt; - - if ( GetModuleFileName( NULL, ModuleFilename, sizeof( ModuleFilename ) ) == 0 ) - { - return( FALSE ); - } - - // Now get directory - strcpy( pcDirectory, ModuleFilename ); - - for ( cnt = strlen( pcDirectory ) - 1; cnt >= 0; cnt -- ) - { - if ( pcDirectory[ cnt ] == '\\' ) - { - pcDirectory[ cnt ] = '\0'; - break; - } - } -#endif - return( TRUE ); } -#ifdef USE_VFS static vfs::CVirtualFileSystem::Iterator file_iter; -#endif BOOLEAN GetFileFirst( CHAR8 * pSpec, GETFILESTRUCT *pGFStruct ) { -#ifdef USE_VFS CHECKF( pSpec != NULL ); CHECKF( pGFStruct != NULL ); @@ -1927,43 +1255,10 @@ BOOLEAN GetFileFirst( CHAR8 * pSpec, GETFILESTRUCT *pGFStruct ) return TRUE; } return FALSE; -#else - INT32 x,iWhich=0; - BOOLEAN fFound; - - CHECKF( pSpec != NULL ); - CHECKF( pGFStruct != NULL ); - - fFound = FALSE; - for( x = 0; x < 20 && !fFound; x++) - { - if( !fFindInfoInUse[x] ) - { - iWhich = x; - fFound = TRUE; - } - } - - if ( !fFound ) - return(FALSE); - - pGFStruct->iFindHandle = iWhich; - - hFindInfoHandle[iWhich] = FindFirstFile( pSpec, &Win32FindInfo[iWhich] ); - - if ( hFindInfoHandle[iWhich] == INVALID_HANDLE_VALUE ) - return(FALSE); - fFindInfoInUse[iWhich] = TRUE; - - W32toSGPFileFind( pGFStruct, &Win32FindInfo[iWhich] ); - - return(TRUE); -#endif } BOOLEAN GetFileNext( GETFILESTRUCT *pGFStruct ) { -#ifdef USE_VFS if(!file_iter.end()) { file_iter.next(); @@ -1984,32 +1279,11 @@ BOOLEAN GetFileNext( GETFILESTRUCT *pGFStruct ) return TRUE; } return FALSE; -#else - CHECKF( pGFStruct != NULL ); - - if ( FindNextFile(hFindInfoHandle[pGFStruct->iFindHandle], &Win32FindInfo[pGFStruct->iFindHandle]) ) - { - W32toSGPFileFind( pGFStruct, &Win32FindInfo[pGFStruct->iFindHandle] ); - return(TRUE); - } - return(FALSE); -#endif } void GetFileClose( GETFILESTRUCT *pGFStruct ) { -#ifdef USE_VFS file_iter = vfs::CVirtualFileSystem::Iterator(); -#else - if ( pGFStruct == NULL ) - return; - - FindClose( hFindInfoHandle[pGFStruct->iFindHandle] ); - hFindInfoHandle[pGFStruct->iFindHandle] = INVALID_HANDLE_VALUE; - fFindInfoInUse[pGFStruct->iFindHandle] = FALSE; - - return; -#endif } void W32toSGPFileFind( GETFILESTRUCT *pGFStruct, WIN32_FIND_DATA *pW32Struct ) @@ -2226,18 +1500,13 @@ UINT32 FileGetAttributes( STR strFilename ) BOOLEAN FileClearAttributes( STR strFilename ) { -#ifndef USE_VFS - return SetFileAttributes( (LPCSTR) strFilename, FILE_ATTRIBUTE_NORMAL ); -#else return TRUE; -#endif } //returns true if at end of file, else false BOOLEAN FileCheckEndOfFile( HWFILE hFile ) { -#ifdef USE_VFS vfs::size_t current_position, max_position; vfs::IBaseFile *pFile = (vfs::IBaseFile*)hFile; @@ -2262,139 +1531,13 @@ BOOLEAN FileCheckEndOfFile( HWFILE hFile ) } } return FALSE; -#else - INT16 sLibraryID; - UINT32 uiFileNum; - HANDLE hRealFile; -// UINT8 Data; - UINT32 uiOldFilePtrLoc=0; - UINT32 uiEndOfFilePtrLoc=0; - UINT32 temp=0; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //Get the handle to the real file - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - //Get the current position of the file pointer - uiOldFilePtrLoc = SetFilePointer( hRealFile, 0, NULL, FILE_CURRENT ); - - //Get the end of file ptr location - uiEndOfFilePtrLoc = SetFilePointer( hRealFile, 0, NULL, FILE_END ); - - //reset back to the original location - temp = SetFilePointer( hRealFile, -( (INT32)( uiEndOfFilePtrLoc - uiOldFilePtrLoc ) ), NULL, FILE_END ); - - //if the 2 pointers are the same, we are at the end of a file - if( uiEndOfFilePtrLoc <= uiOldFilePtrLoc ) - { - return( 1 ); - } - } - - //else it is a library file - else - { - //if the database is initialized - if( gFileDataBase.fInitialized ) - { - //if the library is open - if( IsLibraryOpened( sLibraryID ) ) - { - //if the file is opened - if( gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFileID != 0 ) - { - UINT32 uiLength; //uiOffsetInLibrary -// HANDLE hLibraryFile; -// UINT32 uiNumBytesRead; - UINT32 uiCurPos; - - uiLength = gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].pFileHeader->uiFileLength; - uiCurPos = gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFilePosInFile; - - //if we are trying to read more data then the size of the file, return an error - if( uiCurPos >= uiLength ) - { - return( TRUE ); - } - } - } - } - } - - //we are not and the end of a file - return( 0 ); -#endif } BOOLEAN GetFileManFileTime( HWFILE hFile, SGP_FILETIME *pCreationTime, SGP_FILETIME *pLastAccessedTime, SGP_FILETIME *pLastWriteTime ) { -#ifndef USE_VFS - HANDLE hRealFile; - INT16 sLibraryID; - UINT32 uiFileNum; - - FILETIME sCreationUtcFileTime; - FILETIME sLastAccessedUtcFileTime; - FILETIME sLastWriteUtcFileTime; - - //Initialize the passed in variables - if (pCreationTime) memset( pCreationTime, 0, sizeof( SGP_FILETIME ) ); - if (pLastAccessedTime) memset( pLastAccessedTime, 0, sizeof( SGP_FILETIME ) ); - if (pLastWriteTime) memset( pLastWriteTime, 0, sizeof( SGP_FILETIME ) ); - - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //get the real file handle to the file - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - - //Gets the UTC file time for the 'real' file - GetFileTime( hRealFile, &sCreationUtcFileTime, &sLastAccessedUtcFileTime, &sLastWriteUtcFileTime ); - - //converts the creation UTC file time to the current time used for the file - if(pCreationTime) - FileTimeToLocalFileTime( &sCreationUtcFileTime, pCreationTime ); - - //converts the accessed UTC file time to the current time used for the file - if (pLastAccessedTime) - FileTimeToLocalFileTime( &sLastAccessedUtcFileTime, pLastAccessedTime ); - - //converts the write UTC file time to the current time used for the file - if (pLastWriteTime) - FileTimeToLocalFileTime( &sLastWriteUtcFileTime, pLastWriteTime ); - } - else - { - //if the database is initialized - if( gFileDataBase.fInitialized ) - { - //if the library is open - if( IsLibraryOpened( sLibraryID ) ) - { - //if the file is opened - if( gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFileID != 0 ) - { - if( !GetLibraryFileTime( sLibraryID, uiFileNum, pLastWriteTime ) ) - { - return( FALSE ); - } - } - } - } - } - return( TRUE ); -#else return( FALSE ); -#endif } @@ -2405,60 +1548,15 @@ INT32 CompareSGPFileTimes( SGP_FILETIME *pFirstFileTime, SGP_FILETIME *pSecondFi UINT32 FileSize(STR strFilename) { -#ifdef USE_VFS vfs::IBaseFile *pFile = getVFS()->getFile(vfs::Path(strFilename)); if(pFile) { return pFile->getSize(); } return 0; -#else -HWFILE hFile; -UINT32 uiSize; - - if((hFile=FileOpen(strFilename, FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE))==0) - return(0); - - uiSize=FileGetSize(hFile); - FileClose(hFile); - - return(uiSize); -#endif } - -HANDLE GetRealFileHandleFromFileManFileHandle( HWFILE hFile ) -{ -#ifndef USE_VFS - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its the 'real file' library - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //if its not already closed - if( gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].uiFileID != 0 ) - { - return( gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle ); - } - } - else - { - //if the file is not opened, dont close it - if( gFileDataBase.pLibraries[ sLibraryID ].pOpenFiles[ uiFileNum ].uiFileID != 0 ) - { - return( gFileDataBase.pLibraries[ sLibraryID ].hLibraryHandle ); - } - } -#endif - return( 0 ); -} - - - //************************************************************************** // // AddSubdirectoryToPath diff --git a/Standard Gaming Platform/MemMan.cpp b/Standard Gaming Platform/MemMan.cpp index 8db37790..caa545e8 100644 --- a/Standard Gaming Platform/MemMan.cpp +++ b/Standard Gaming Platform/MemMan.cpp @@ -204,23 +204,6 @@ void ShutdownMemoryManager( void ) #ifndef EXTREME_MEMORY_DEBUGGING #ifdef JA2BETAVERSION { -#ifndef USE_VFS - FILE *fp; - fp = fopen( "MemLeakInfo.txt", "a" ); - if( fp ) - { - fprintf( fp, "\n\n" ); - fprintf( fp, ">>>>> MEMORY LEAK DETECTED!!! <<<<<\n" ); - fprintf( fp, " %d bytes memory total was allocated\n", guiMemAlloced ); - fprintf( fp, "- %d bytes memory total was freed\n", guiMemFreed ); - fprintf( fp, "_______________________________________________\n" ); - fprintf( fp, "%d bytes memory total STILL allocated\n", guiMemTotal ); - fprintf( fp, "%d memory blocks still allocated\n", MemDebugCounter ); - fprintf( fp, "guiScreenExitedFrom = %S\n", gzJA2ScreenNames[ gMsgBox.uiExitScreen ] ); - fprintf( fp, "\n\n" ); - } - fclose( fp ); -#else sgp::Logger_ID log_id = sgp::Logger::instance().createLogger(); sgp::Logger::LogInstance memLeak = SGP_LOG(log_id); memLeak << sgp::endl << sgp::endl; @@ -232,7 +215,6 @@ void ShutdownMemoryManager( void ) memLeak << MemDebugCounter << " memory blocks still allocated" << sgp::endl; memLeak << "guiScreenExitedFrom = " << gzJA2ScreenNames[ gMsgBox.uiExitScreen ] << sgp::endl; memLeak << sgp::endl << sgp::endl; -#endif } #endif #endif diff --git a/Standard Gaming Platform/Types.h b/Standard Gaming Platform/Types.h index 0fc57bef..6c304ad3 100644 --- a/Standard Gaming Platform/Types.h +++ b/Standard Gaming Platform/Types.h @@ -141,15 +141,6 @@ typedef VECTOR4 COLOR; // rgba color array inline void convert_string(std::wstring const& str_in, std::string &str_out) { -#if !defined(USE_VFS) - const wchar_t* src = str_in.c_str(); - size_t len = wcstombs(NULL, src, str_in.length()); - if(len > 0) - { - str_out.resize(len); - wcstombs(&str_out[0], src, len); - } -#else if(vfs::Settings::getUseUnicode()) { str_out = vfs::String::as_utf8(str_in); @@ -158,20 +149,10 @@ inline void convert_string(std::wstring const& str_in, std::string &str_out) { vfs::String::narrow(str_in, str_out); } -#endif } inline void convert_string(std::string const& str_in, std::wstring &str_out) { -#if !defined(USE_VFS) - const char* src = str_in.c_str(); - size_t len = mbstowcs(NULL, src, str_in.length()); - if(len > 0) - { - str_out.resize(len); - mbstowcs(&str_out[0], src, len); - } -#else if(vfs::Settings::getUseUnicode()) { vfs::String::as_utf16(str_in, str_out); @@ -180,8 +161,7 @@ inline void convert_string(std::string const& str_in, std::wstring &str_out) { vfs::String::widen(str_in, str_out); } -#endif } -#endif \ No newline at end of file +#endif diff --git a/Standard Gaming Platform/WinFont.cpp b/Standard Gaming Platform/WinFont.cpp index bfed0c1b..223e634f 100644 --- a/Standard Gaming Platform/WinFont.cpp +++ b/Standard Gaming Platform/WinFont.cpp @@ -189,21 +189,6 @@ Name=Tahoma Height=-20 Weight=400 */ -#ifndef USE_VFS - char INIFile[MAX_PATH]; - GetExecutableDirectory( INIFile ); - strcat(INIFile, "\\"); - strcat(INIFile, GAME_INI_FILE); - - - gWinFontAdjust = GetPrivateProfileInt("Ja2 Settings", "WIN_FONT_ADJUST", 0, INIFile); - for (UINT16 i=0; i @@ -841,9 +799,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC -#ifdef USE_VFS vfs::Log::setSharedString( getGameID() ); -#endif //if(!vfs::Aspects::getMutexFactory()) //{ // vfs::Aspects::setMutexFactory( new VfsMutexFactory() ); @@ -914,15 +870,6 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC // ShowCursor(FALSE); -#ifdef USE_VFS - //vfs::Path exe_dir, exe_file; - //os::getExecutablePath(exe_dir, exe_file); - //os::setCurrectDirectory(exe_dir); -#else - STRING512 sExecutableDir; - GetExecutableDirectory( sExecutableDir ); - SetCurrentDirectory(sExecutableDir); -#endif try { // Inititialize the SGP @@ -934,9 +881,7 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC } HANDLE_FATAL_ERROR; -#ifdef USE_VFS vfs::Log::flushReleaseAll(); -#endif #ifdef LUACONSOLE if (1==iScreenMode) @@ -1051,39 +996,10 @@ void GetRuntimeSettings( ) /* Detect cnc-ddraw and disable windowed mode */ BOOL bCncDdraw = GetProcAddress(GetModuleHandleW(L"ddraw.dll"), "GameHandlesClose") != NULL; -#ifndef USE_VFS - CHAR8 zMaximize[ 50 ]; - CHAR8 zWindowedMode[ 50 ]; - - // Runtime settings - for now use INI file - later use registry - STRING512 INIFile; // Path to the ini file - CHAR8 zScreenResolution[ 50 ]; - - // Get Executable Directory - GetExecutableDirectory( INIFile ); - - strcat(INIFile, "\\"); - strcat(INIFile, GAME_INI_FILE); -#else vfs::PropertyContainer oProps; oProps.initFromIniFile(GAME_INI_FILE); PopulateSectionFromCommandLine(oProps, "Ja2 Settings"); -#endif -#ifndef USE_VFS - if (GetPrivateProfileString( "Ja2 Settings","SCREEN_RESOLUTION", "", zScreenResolution, 50, INIFile )) - { - iResolution = atoi(zScreenResolution); - } - if (GetPrivateProfileString( "Ja2 Settings","SCREEN_MODE_WINDOWED_MAXIMIZE", "", zMaximize, 50, INIFile )) - { - iMaximize = atoi(zMaximize); - } - if (GetPrivateProfileString( "Ja2 Settings","SCREEN_MODE_WINDOWED", "", zWindowedMode, 50, INIFile )) - { - iWindowedMode = bCncDdraw ? 0 : atoi(zWindowedMode); - } -#else vfs::String loc = oProps.getStringProperty("Ja2 Settings", L"LOCALE"); if(!loc.empty()) { @@ -1142,9 +1058,7 @@ void GetRuntimeSettings( ) CIniReader::RegisterFileForMerging(*it); } } -#endif -#ifdef USE_VFS extern bool g_bUsePngItemImages; g_bUsePngItemImages = oProps.getBoolProperty(L"Ja2 Settings", L"USE_PNG_ITEM_IMAGES", false); g_bUseXML_Structures = oProps.getBoolProperty(L"Ja2 Settings", L"USE_XML_STRUCTURES", false); @@ -1164,17 +1078,9 @@ void GetRuntimeSettings( ) s_bExportStrings = oProps.getBoolProperty(L"Ja2 Settings", L"EXPORT_STRINGS", false); sp_force_load_jsd_xml_file = oProps.getStringProperty(L"Ja2 Settings", L"FORCE_LOAD_JSD_XML_FILE", L""); -#endif #ifdef JA2EDITOR -#ifndef USE_VFS - if (GetPrivateProfileString( "Ja2 Settings","EDITOR_SCREEN_RESOLUTION", "", zScreenResolution, 50, INIFile )) - { - iResolution = atoi(zScreenResolution); - } -#else iResolution = (int)oProps.getIntProperty("Ja2 Settings","EDITOR_SCREEN_RESOLUTION", -1); -#endif #endif int iResX; @@ -1311,30 +1217,6 @@ void GetRuntimeSettings( ) } // Adjust again - -#ifndef USE_VFS - gbPixelDepth = GetPrivateProfileInt( "SGP", "PIXEL_DEPTH", PIXEL_DEPTH, INIFile ); - - SCREEN_WIDTH = GetPrivateProfileInt( "SGP", "WIDTH", iResX, INIFile ); - SCREEN_HEIGHT = GetPrivateProfileInt( "SGP", "HEIGHT", iResY, INIFile ); - - iScreenWidthOffset = (SCREEN_WIDTH - 640) / 2; - iScreenHeightOffset = (SCREEN_HEIGHT - 480) / 2; - - /* Sergeant_Kolja. 2007-02-20: runtime Windowed mode instead of compile-time */ - /* 1 for Windowed, 0 for Fullscreen */ - if( !bScreenModeCmdLine ) - iScreenMode = bCncDdraw ? 0 : (int) GetPrivateProfileInt( "Ja2 Settings","SCREEN_MODE_WINDOWED", iScreenMode, INIFile ); - - // WANNE: Should we play the intro? - iPlayIntro = (int) GetPrivateProfileInt( "Ja2 Settings","PLAY_INTRO", iPlayIntro, INIFile ); - iUseWinFonts = (int) GetPrivateProfileInt( "Ja2 Settings","USE_WINFONTS", iUseWinFonts, INIFile,); - fTooltipScaleFactor = ((int)GetPrivateProfileInt("Ja2 Settings", "TOOLTIP_SCALE_FACTOR", 100, INIFile, )) / 100; - if (fTooltipScaleFactor < 1) fTooltipScaleFactor = 1; - - // haydent: mouse scrolling - iDisableMouseScrolling = (int) GetPrivateProfileInt( "Ja2 Settings","DISABLE_MOUSE_SCROLLING", iDisableMouseScrolling, INIFile ); -#else gbPixelDepth = PIXEL_DEPTH; SCREEN_WIDTH = iResX; @@ -1388,8 +1270,6 @@ void GetRuntimeSettings( ) // get timer/clock initialization state //SetHiSpeedClockMode( oProps.getBoolProperty("Ja2 Settings", "HIGHSPEED_TIMER", false) ? TRUE : FALSE ); SetHiSpeedClockMode( TRUE ); - -#endif } @@ -1464,7 +1344,6 @@ void ProcessJa2CommandLineBeforeInitialization(CHAR8 *pCommandLine) MemFree(pCopy); } -#ifdef USE_VFS static void PopulateSectionFromCommandLine(vfs::PropertyContainer &oProps, vfs::String const& sSection) { const wchar_t* lpCommandLine = GetCommandLineW(); @@ -1496,7 +1375,6 @@ static void PopulateSectionFromCommandLine(vfs::PropertyContainer &oProps, vfs:: } } } -#endif static LONG __stdcall SGPExceptionFilter(int exceptionCount, EXCEPTION_POINTERS* pExceptInfo) { diff --git a/Standard Gaming Platform/sgp_logger.cpp b/Standard Gaming Platform/sgp_logger.cpp index 54772eba..dc82bbde 100644 --- a/Standard Gaming Platform/sgp_logger.cpp +++ b/Standard Gaming Platform/sgp_logger.cpp @@ -16,16 +16,12 @@ static inline void flush_screen(std::wstringstream& stream) int sgp::Logger::_next_log_id = -1; -#if defined(USE_VFS) //std::vector sgp::Logger::_logs; std::vector sgp::Logger::_logs; -#endif sgp::Logger::Logger() { -#if defined(USE_VFS) connectFile(this->createLogger(), L"game_log.log", false, sgp::Logger::FLUSH_ON_ENDL); -#endif } sgp::Logger::~Logger() @@ -47,9 +43,7 @@ bool sgp::Logger::shutdown() { for(::size_t i=0; i < _logs.size(); ++i) { -#if defined(USE_VFS) disconnectFile(i); -#endif disconnectStream(i); disconnectScreen(i); } @@ -102,7 +96,6 @@ void sgp::Logger::flushMode(sgp::Logger_ID id, sgp::Logger::FlushMode fmode) } -#if defined(USE_VFS) void sgp::Logger::connectFile(sgp::Logger_ID id, vfs::Path const& log_file, bool append, FlushMode fmode) { if(id >= 0 && id < _logs.size()) @@ -128,7 +121,6 @@ void sgp::Logger::disconnectFile(sgp::Logger_ID id) } } } -#endif void sgp::Logger::connectStream(sgp::Logger_ID id, std::ostream& stream) { @@ -170,29 +162,10 @@ void sgp::Logger::disconnectScreen(sgp::Logger_ID id) } -//#if defined(USE_VFS) -//int sgp::Logger::createLogger(vfs::Path const& log_file, bool append, FlushMode fp) -//{ -// vfs::Log::EFlushMode fm; -// if(fp == sgp::Logger::FLUSH_ON_DELETE) fm = vfs::Log::FLUSH_ON_DELETE; -// else if(fp == sgp::Logger::FLUSH_IMMIDIATELY) fm = vfs::Log::FLUSH_IMMEDIATELY; -// else if(fp == sgp::Logger::FLUSH_FULL_BUFFER) fm = vfs::Log::FLUSH_BUFFER; -// else if(fp == sgp::Logger::FLUSH_ON_ENDL) fm = vfs::Log::FLUSH_ON_ENDL; -// else fm = vfs::Log::FLUSH_IMMEDIATELY; -// -// _logs.push_back(STimeLog()); -// _next_log_id++; -// _logs[_next_log_id]._log = vfs::Log::create(log_file,append,fm); -// _logs[_next_log_id]._timer.startTimer(); -// return _next_log_id; -//} -//#endif - sgp::Logger::LogInstance sgp::Logger::logger(sgp::Logger_ID id) { if(id < _logs.size()) { -#if defined(USE_VFS) std::wstringstream tmp; tmp << L"[" << _logs[id].timer.running() << L"] : "; std::wstring str(tmp.str()); @@ -208,7 +181,6 @@ sgp::Logger::LogInstance sgp::Logger::logger(sgp::Logger_ID id) if(ld.screen) { (*ld.screen) << str; } -#endif return sgp::Logger::LogInstance(&ld); } SGP_THROW(L"Unknown log id"); @@ -219,10 +191,8 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< (sgp { if(_log.file) { -#if defined(USE_VFS) (*_log.file).flush(); (*_log.file).unlock(); -#endif } if(_log.stream) { @@ -240,14 +210,12 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< (sgp: { if(_log.file) { -#if defined(USE_VFS) (*_log.file) << vfs::Log::endl; if(_log.file->flushMode() == vfs::Log::FLUSH_ON_ENDL) { (*_log.file).flush(); } (*_log.file).unlock(); -#endif } if(_log.stream) { @@ -263,8 +231,6 @@ sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< (sgp: template <> sgp::Logger::LogInstance& sgp::Logger::LogInstance::operator<< (sgp::_lock const& l) { -#if defined(USE_VFS) _log.file->lock(); -#endif return *this; } diff --git a/Standard Gaming Platform/sgp_logger.h b/Standard Gaming Platform/sgp_logger.h index d93c7cd6..db457eb5 100644 --- a/Standard Gaming Platform/sgp_logger.h +++ b/Standard Gaming Platform/sgp_logger.h @@ -2,13 +2,9 @@ #define SGP_LOGGER_H #include -#if defined(USE_VFS) -# include -# include -# include -#else -# include -#endif +#include +#include +#include namespace sgp { @@ -22,13 +18,9 @@ namespace sgp { struct LogData { -#if defined(USE_VFS) LogData() : file(NULL), stream(NULL), screen(NULL) {}; vfs::HPTimer timer; vfs::Log* file; -#else - LogData() : stream(NULL), screen(NULL) {}; -#endif std::wostream* stream; std::wstringstream* screen; }; @@ -53,9 +45,7 @@ namespace sgp LogInstance& operator<<(T const& t){ if(_log.stream) (*_log.stream) << t; if(_log.screen) (*_log.screen) << t; -#if defined(USE_VFS) if(_log.file ) (*_log.file) << t; -#endif return *this; } private: @@ -72,10 +62,8 @@ namespace sgp Logger_ID createLogger(); -#if defined(USE_VFS) void connectFile(Logger_ID id, vfs::Path const& log_file, bool append, FlushMode fp); void disconnectFile(Logger_ID id); -#endif void connectStream(Logger_ID id, std::ostream& stream); void disconnectStream(Logger_ID id); @@ -102,44 +90,28 @@ namespace sgp Logger::LogInstance& Logger::LogInstance::operator<< <_flush>(_flush const& f); } -#if defined(USE_VFS) inline sgp::Logger::LogInstance SGP_LOG(sgp::Logger_ID id, vfs::String const& str){ -#else -inline sgp::Logger::LogInstance SGP_LOG(int id, const char* str){ -#endif return sgp::Logger::instance().logger(id) << (str) << sgp::endl; } inline sgp::Logger::LogInstance SGP_LOG(sgp::Logger_ID id){ return sgp::Logger::instance().logger(id); } -#if defined(USE_VFS) inline sgp::Logger::LogInstance SGP_INFO(vfs::String const& str){ -#else -inline sgp::Logger::LogInstance SGP_INFO(const char* str){ -#endif return sgp::Logger::instance().logger(0) << str << sgp::endl; } inline sgp::Logger::LogInstance SGP_INFO(){ return sgp::Logger::instance().logger(0); } -#if defined(USE_VFS) inline sgp::Logger::LogInstance SGP_WARNING(vfs::String const& str){ -#else -inline sgp::Logger::LogInstance SGP_WARNING(const char* str){ -#endif return sgp::Logger::instance().logger(0) << "WARNING : " << str << sgp::endl; } inline sgp::Logger::LogInstance SGP_WARNING(){ return sgp::Logger::instance().logger(0) << "WARNING : "; } -#if defined(USE_VFS) inline sgp::Logger::LogInstance SGP_ERROR(vfs::String const& str){ -#else -inline sgp::Logger::LogInstance SGP_ERROR(const char* str){ -#endif return sgp::Logger::instance().logger(0) << "ERROR : " << str << sgp::endl; } inline sgp::Logger::LogInstance SGP_ERROR(){ diff --git a/Standard Gaming Platform/soundman.cpp b/Standard Gaming Platform/soundman.cpp index 22077f74..a2f5869e 100644 --- a/Standard Gaming Platform/soundman.cpp +++ b/Standard Gaming Platform/soundman.cpp @@ -1869,15 +1869,7 @@ void SoundLog(CHAR8 *strMessage) sgp::Logger::instance().connectFile(id, SndDebugFileName, true, sgp::Logger::FLUSH_ON_DELETE); } } s_SoundLog; -#ifndef USE_VFS - if ((SndDebug = fopen(SndDebugFileName, "a+t")) != NULL) - { - fprintf(SndDebug, "%s\n", strMessage); - fclose(SndDebug); - } -#else SGP_LOG(s_SoundLog.id, vfs::String::widen(strMessage,strlen(strMessage))); -#endif } //***************************************************************************************** @@ -1890,10 +1882,4 @@ void SoundLog(CHAR8 *strMessage) //***************************************************************************************** void InitLogging() { -#ifndef USE_VFS - if ((SndDebug = fopen(SndDebugFileName, "wt")) != NULL) - { - fclose(SndDebug); - } -#endif } diff --git a/Standard Gaming Platform/video.cpp b/Standard Gaming Platform/video.cpp index 0432e512..bd1bcca2 100644 --- a/Standard Gaming Platform/video.cpp +++ b/Standard Gaming Platform/video.cpp @@ -1888,22 +1888,10 @@ void RefreshScreen(void *DummyVariable) LPDIRECTDRAWSURFACE _pTmpBuffer; LPDIRECTDRAWSURFACE2 pTmpBuffer; DDSURFACEDESC SurfaceDescription; -#ifndef USE_VFS - FILE *OutputFile; -#endif CHAR8 FileName[64]; INT32 iIndex; UINT16 *p16BPPData; - // Snap: save current directory -#ifndef USE_VFS - STRING512 DataDir; - STRING512 ExecDir; - - GetFileManCurrentDirectory( DataDir ); - GetExecutableDirectory( ExecDir ); - SetFileManCurrentDirectory( ExecDir ); -#endif // // Create temporary system memory surface. This is used to correct problems with the backbuffer // surface which can be interlaced or have a funky pitch @@ -1953,23 +1941,13 @@ void RefreshScreen(void *DummyVariable) { sprintf( FileName, "SCREEN%03d.TGA", guiPrintFrameBufferIndex++); } -#ifndef USE_VFS - while( (_access( FileName, 0 )) != -1 ); -#else while(FileExists(FileName)); -#endif -#ifndef USE_VFS - if ((OutputFile = fopen( FileName, "wb")) != NULL) - { - fprintf(OutputFile, "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c", 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, LOBYTE(SCREEN_WIDTH), HIBYTE(SCREEN_WIDTH), LOBYTE(SCREEN_HEIGHT), HIBYTE(SCREEN_HEIGHT), 0x10, 0); -#else try { vfs::COpenWriteFile wfile(FileName,true,true); char head[] = {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, LOBYTE(SCREEN_WIDTH), HIBYTE(SCREEN_WIDTH), LOBYTE(SCREEN_HEIGHT), HIBYTE(SCREEN_HEIGHT), 0x10, 0}; SGP_TRYCATCH_RETHROW(wfile->write(head,18), L""); -#endif // // Lock temp surface @@ -2006,19 +1984,11 @@ void RefreshScreen(void *DummyVariable) ConvertRGBDistribution565To555( p16BPPData, SCREEN_WIDTH ); // Write -#ifndef USE_VFS - fwrite( p16BPPData, SCREEN_WIDTH * 2, 1, OutputFile); -#else SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)p16BPPData, SCREEN_WIDTH * 2), L""); -#endif } else { -#ifndef USE_VFS - fwrite((void *)(((UINT8 *)SurfaceDescription.lpSurface) + (iIndex * SCREEN_WIDTH * 2)), SCREEN_WIDTH * 2, 1, OutputFile); -#else SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)(((UINT8 *)SurfaceDescription.lpSurface) + (iIndex * SCREEN_WIDTH * 2)), SCREEN_WIDTH * 2), L""); -#endif } } @@ -2027,9 +1997,6 @@ void RefreshScreen(void *DummyVariable) { MemFree( p16BPPData ); } -#ifndef USE_VFS - fclose(OutputFile); -#endif // // Unlock temp surface // @@ -2043,12 +2010,10 @@ void RefreshScreen(void *DummyVariable) } } -#ifdef USE_VFS catch(std::exception& ex) { SGP_RETHROW(L"", ex); } -#endif // // Release temp surface @@ -2056,12 +2021,6 @@ void RefreshScreen(void *DummyVariable) gfPrintFrameBuffer = FALSE; IDirectDrawSurface2_Release(pTmpBuffer); -#ifndef USE_VFS - // Snap: Restore the data directory once we are finished. - SetFileManCurrentDirectory( DataDir ); - //strcat( ExecDir, "\\Data" ); - //SetFileManCurrentDirectory( ExecDir ); -#endif } // @@ -3322,80 +3281,42 @@ void RefreshMovieCache( ) { TARGA_HEADER Header; INT32 iCountX, iCountY; -#ifndef USE_VFS - FILE *disk; -#endif CHAR8 cFilename[_MAX_PATH]; static UINT32 uiPicNum=0; UINT16 *pDest; INT32 cnt; -#ifndef USE_VFS - STRING512 DataDir; - STRING512 ExecDir; -#endif PauseTime( TRUE ); -#ifndef USE_VFS - // Snap: save current directory - GetFileManCurrentDirectory( DataDir ); - - GetExecutableDirectory( ExecDir ); - SetFileManCurrentDirectory( ExecDir ); -#else try { -#endif for ( cnt = 0; cnt < giNumFrames; cnt++ ) { sprintf( cFilename, "JA%5.5d.TGA", uiPicNum++ ); -#ifndef USE_VFS - if( ( disk = fopen(cFilename, "wb"))==NULL ) - return; -#else vfs::COpenWriteFile wfile(cFilename, true, true); -#endif memset(&Header, 0, sizeof(TARGA_HEADER)); Header.ubTargaType=2; // Uncompressed 16/24/32 bit Header.usImageWidth=SCREEN_WIDTH; Header.usImageHeight=SCREEN_HEIGHT; Header.ubBitsPerPixel=16; -#ifndef USE_VFS - fwrite(&Header, sizeof(TARGA_HEADER), 1, disk); -#else SGP_TRYCATCH_RETHROW(wfile->write((vfs::Byte*)&Header, sizeof(TARGA_HEADER)), L""); -#endif pDest = gpFrameData[ cnt ]; for(iCountY=SCREEN_HEIGHT-1; iCountY >=0 ; iCountY-=1) { for(iCountX=0; iCountX < SCREEN_WIDTH; iCountX ++ ) { -#ifndef USE_VFS - fwrite( ( pDest + ( iCountY * SCREEN_WIDTH ) + iCountX ), sizeof(UINT16), 1, disk); -#else SGP_TRYCATCH_RETHROW(wfile->write( (vfs::Byte*)( pDest + ( iCountY * SCREEN_WIDTH ) + iCountX ), sizeof(UINT16)), L""); -#endif } } -#ifndef USE_VFS - fclose(disk); -#endif } PauseTime( FALSE ); giNumFrames = 0; -#ifndef USE_VFS - // Snap: Restore the data directory once we are finished. - SetFileManCurrentDirectory( DataDir ); - //strcat( ExecDir, "\\Data" ); - //SetFileManCurrentDirectory( ExecDir ); -#else } catch(std::exception& ex) { SGP_ERROR(ex.what()); } -#endif } diff --git a/Strategic/Campaign Init.cpp b/Strategic/Campaign Init.cpp index c3faaa38..0da5809b 100644 --- a/Strategic/Campaign Init.cpp +++ b/Strategic/Campaign Init.cpp @@ -206,26 +206,6 @@ BOOLEAN ReadInAltSectors(STR fileName) BOOLEAN WriteInAltSectors(STR fileName) { -#ifndef USE_VFS - // Lets output the current Strategic map format using the XML structure I've devised. - FILE *outfile = fopen(fileName, "wt"); - - UINT32 x, y; - - fprintf (outfile, "\n"); - for(y = 1;y <= 16;y++) - { - fprintf (outfile, "\t",(y+0x40)); - for(x = 1;x <= 16; x++) - { - fprintf (outfile, " %d",RandomSector[ ((y - 1) * 16) + (x - 1) ] ); - } - fprintf (outfile, " \n"); - } - fprintf (outfile, "\n"); - - fclose(outfile); -#else XMLWriter xmlw; xmlw.openNode(L"ALT_SECTORS_LIST"); UINT32 x, y; @@ -241,7 +221,6 @@ BOOLEAN WriteInAltSectors(STR fileName) } xmlw.closeNode(); xmlw.writeToFile(fileName); -#endif return (TRUE); } diff --git a/Strategic/Strategic AI.cpp b/Strategic/Strategic AI.cpp index c64d85ed..bf1d52b5 100644 --- a/Strategic/Strategic AI.cpp +++ b/Strategic/Strategic AI.cpp @@ -5430,22 +5430,11 @@ void LogStrategicMsg( STR8 str, ... ) { va_list argptr; CHAR8 string[512]; -#ifndef USE_VFS - FILE *fp; - - fp = fopen( "Strategic Decisions.txt", "a" ); - if( !fp ) - return; -#endif va_start(argptr, str ); vsprintf( string, str, argptr); va_end(argptr); -#ifndef USE_VFS - fprintf( fp, "%s\n", string ); -#else SGP_LOG(s_stratD.id, string); -#endif if( gfDisplayStrategicAILogs ) { @@ -5455,33 +5444,17 @@ void LogStrategicMsg( STR8 str, ... ) { OutputDebugString( (LPCSTR)String( "%s\n", string ) ); } - -#ifndef USE_VFS - fclose( fp ); -#endif } void LogStrategicEvent( STR8 str, ... ) { va_list argptr; CHAR8 string[512]; -#ifndef USE_VFS - FILE *fp; - - fp = fopen( "Strategic Decisions.txt", "a" ); - if( !fp ) - return; -#endif va_start(argptr, str ); vsprintf( string, str, argptr); va_end(argptr); -#ifndef USE_VFS - fprintf( fp, "\n%S:\n", WORLDTIMESTR ); - fprintf( fp, "%s\n", string ); -#else SGP_LOG(s_stratD.id) << sgp::endl << WORLDTIMESTR << ":" << sgp::endl << string << sgp::endl; -#endif if( gfDisplayStrategicAILogs ) { ScreenMsg( FONT_LTKHAKI, MSG_DIALOG, L"%S", string ); @@ -5490,25 +5463,11 @@ void LogStrategicEvent( STR8 str, ... ) { OutputDebugString( (LPCSTR)String( "%s\n", string ) ); } -#ifndef USE_VFS - fclose( fp ); -#endif } void ClearStrategicLog() { -#ifndef USE_VFS - FILE *fp; - fp = fopen( "Strategic Decisions.txt", "w" ); - if( !fp ) - return; - - fprintf( fp, "STRATEGIC LOG\n" ); - - fclose( fp ); -#else SGP_LOG(s_stratD.id) << sgp::flush; -#endif } #endif diff --git a/Strategic/strategicmap.cpp b/Strategic/strategicmap.cpp index 9fa2cff6..f194853a 100644 --- a/Strategic/strategicmap.cpp +++ b/Strategic/strategicmap.cpp @@ -1659,80 +1659,6 @@ void EndLoadScreen( ) 'A' + gWorldSectorY - 1, gWorldSectorX, gbWorldSectorZ, uiSeconds, uiHundreths ); } ScreenMsg( FONT_YELLOW, MSG_TESTVERSION, str ); -#ifndef USE_VFS - FILE *fp; - - if ( fStartNewFile ) - { //start new file - fp = fopen( "TimeResults.txt", "w" ); - ScreenMsg( FONT_YELLOW, MSG_TESTVERSION, L"See JA2\\Data\\TimeResults.txt for more detailed timings." ); - fStartNewFile = FALSE; - } - else - { //append to end of file - fp = fopen( "TimeResults.txt", "a" ); - - if ( fp ) - { - fprintf( fp, "\n\n--------------------------------------------------------------------\n\n" ); - } - } - if ( fp ) - { - //Record all of the timings. - fprintf( fp, "%S\n", str ); - fprintf( fp, "EnterSector() supersets LoadWorld(). This includes other external sections.\n" ); - //FileRead() - fprintf( fp, "\n\nVARIOUS FUNCTION TIMINGS (exclusive of actual function timings in second heading)\n" ); - uiSeconds = uiTotalFileReadTime / 1000; - uiHundreths = (uiTotalFileReadTime / 10) % 100; - fprintf( fp, "FileRead: %d.%02d (called %d times)\n", uiSeconds, uiHundreths, uiTotalFileReadCalls ); - - fprintf( fp, "\n\nSECTIONS OF LOADWORLD (all parts should add up to 100%)\n" ); - //TrashWorld() - uiSeconds = uiTrashWorldTime / 1000; - uiHundreths = (uiTrashWorldTime / 10) % 100; - fprintf( fp, "TrashWorld: %d.%02d\n", uiSeconds, uiHundreths ); - //LoadMapTilesets() - uiSeconds = uiLoadMapTilesetTime / 1000; - uiHundreths = (uiLoadMapTilesetTime / 10) % 100; - fprintf( fp, "LoadMapTileset: %d.%02d\n", uiSeconds, uiHundreths ); - //LoadMapLights() - uiSeconds = uiLoadMapLightsTime / 1000; - uiHundreths = (uiLoadMapLightsTime / 10) % 100; - fprintf( fp, "LoadMapLights: %d.%02d\n", uiSeconds, uiHundreths ); - uiSeconds = uiBuildShadeTableTime / 1000; - uiHundreths = (uiBuildShadeTableTime / 10) % 100; - fprintf( fp, " 1) BuildShadeTables: %d.%02d\n", uiSeconds, uiHundreths ); - - uiPercentage = uiNumImagesReloaded * 100 / giNumberOfTileTypes; - fprintf( fp, " 2) %d%% of the tileset images were actually reloaded.\n", uiPercentage ); - if ( (uiNumTablesSaved + uiNumTablesLoaded) != 0 ) - { - uiPercentage = uiNumTablesSaved * 100 / (uiNumTablesSaved + uiNumTablesLoaded); - } - else - { - uiPercentage = 0; - } - fprintf( fp, " 3) Of that, %d%% of the shade tables were generated (not loaded).\n", uiPercentage ); - if ( gfForceBuildShadeTables ) - fprintf( fp, " NOTE: Force building of shadetables enabled on this local computer.\n" ); - - - //Unaccounted - uiUnaccounted = uiLoadWorldTime - uiTrashWorldTime - uiLoadMapTilesetTime - uiLoadMapLightsTime; - uiSeconds = uiUnaccounted / 1000; - uiHundreths = (uiUnaccounted / 10) % 100; - fprintf( fp, "Unaccounted: %d.%02d\n", uiSeconds, uiHundreths ); - //LoadWorld() - uiSeconds = uiLoadWorldTime / 1000; - uiHundreths = (uiLoadWorldTime / 10) % 100; - fprintf( fp, "\nTotal: %d.%02d\n", uiSeconds, uiHundreths ); - - fclose( fp ); - } -#else sgp::Logger_ID time_log_id = sgp::Logger::instance( ).createLogger( ); sgp::Logger::instance( ).connectFile( time_log_id, L"TimeResults.txt", true, sgp::Logger::FLUSH_ON_ENDL ); sgp::Logger::LogInstance timeResults = SGP_LOG( time_log_id ); @@ -1793,7 +1719,6 @@ void EndLoadScreen( ) uiSeconds = uiLoadWorldTime / 1000; uiHundreths = (uiLoadWorldTime / 10) % 100; timeResults << vfs::Log::endl << "Total: " << uiSeconds << "." << uiHundreths << sgp::endl; -#endif // USE_VFS #endif } diff --git a/Tactical/Tactical Save.cpp b/Tactical/Tactical Save.cpp index 7a503670..6f84aa34 100644 --- a/Tactical/Tactical Save.cpp +++ b/Tactical/Tactical Save.cpp @@ -1678,33 +1678,7 @@ BOOLEAN RetrieveTempFileFromSavedGame( HWFILE hFile, UINT32 uiType, INT16 sMapX, //Deletes the Temp map Directory BOOLEAN InitTacticalSave( BOOLEAN fCreateTempDir ) { -#ifndef USE_VFS - UINT32 uiRetVal; - - //If the Map Temp directory exists, removes the temp files - uiRetVal = FileGetAttributes( MAPS_DIR ); - if( uiRetVal != 0xFFFFFFFF ) - { - if( uiRetVal & FILE_ATTRIBUTES_DIRECTORY ) - { - //Erase the directory - if( !EraseDirectory( MAPS_DIR ) ) - { - //error erasing the temporary maps directory - } - } - } - else - { - if( !MakeFileManDirectory( MAPS_DIR ) ) - { - //Erro creating the temp map directory - AssertMsg( 0, "Error creating the Temp Directory."); - } - } -#else EraseDirectory( MAPS_DIR ); -#endif if( fCreateTempDir ) { //Create the initial temp file for the Npc Quote Info diff --git a/TileEngine/SaveLoadMap.cpp b/TileEngine/SaveLoadMap.cpp index 0931fe91..3ca80d74 100644 --- a/TileEngine/SaveLoadMap.cpp +++ b/TileEngine/SaveLoadMap.cpp @@ -557,12 +557,6 @@ BOOLEAN LoadAllMapChangesFromMapTempFileAndApplyThem( ) { ReSetSectorFlag( gWorldSectorX, gWorldSectorY, gbWorldSectorZ, SF_MAP_MODIFICATIONS_TEMP_FILE_EXISTS ); } -#ifndef USE_VFS - FileClose( hFile ); -#else - // FileClose( hFile ); - // file already deleted. can't close it anymore (handle is invalid) -#endif //Free the memory used for the temp array MemFree( pTempArrayOfMaps ); diff --git a/TileEngine/Shade Table Util.cpp b/TileEngine/Shade Table Util.cpp index f802fa44..b2345f4f 100644 --- a/TileEngine/Shade Table Util.cpp +++ b/TileEngine/Shade Table Util.cpp @@ -24,10 +24,6 @@ BOOLEAN gfForceBuildShadeTables = FALSE; void DetermineRGBDistributionSettings() { -#ifndef USE_VFS - STRING512 DataDir; - STRING512 ExecDir; -#endif STRING512 ShadeTableDir; UINT32 uiRBitMask, uiGBitMask, uiBBitMask; UINT32 uiPrevRBitMask, uiPrevGBitMask, uiPrevBBitMask; @@ -37,36 +33,9 @@ void DetermineRGBDistributionSettings() BOOLEAN fCleanShadeTable = FALSE; BOOLEAN fLoadedPrevRGBDist = FALSE; -#ifndef USE_VFS - // Snap: save current directory - GetFileManCurrentDirectory( DataDir ); - - //First, determine if we have a file saved. If not, then this is the first time, and - //all shade tables will have to be built and saved to disk. This can be time consuming, adding up to - //3-4 seconds to the time of a map load. - GetExecutableDirectory( ExecDir ); - sprintf( ShadeTableDir, "%s\\%s", DataDir, SHADE_TABLE_DIR ); - - //Check to make sure we have a ShadeTable directory. If we don't create one! - if( !SetFileManCurrentDirectory( ShadeTableDir ) ) - { - if( !MakeFileManDirectory( ShadeTableDir ) ) - { - AssertMsg( 0, "ShadeTable directory doesn't exist, and couldn't create one!" ); - } - if( !SetFileManCurrentDirectory( ShadeTableDir ) ) - { - AssertMsg( 0, "Couldn't access the newly created ShadeTable directory." ); - } - fSaveRGBDist = TRUE; - } - // directory existed or was created. - SetFileManCurrentDirectory( DataDir ); -#else // changing the current directory can screw up the VFS; don't do it // the creation of the SHADE_TABLE_DIR directory is done by the VFS sprintf( ShadeTableDir, "%s", SHADE_TABLE_DIR ); -#endif CHAR8 sRGBDist[50]; sprintf( sRGBDist, "%s\\%s", SHADE_TABLE_DIR, "RGBDist.dat"); diff --git a/TileEngine/WorldDat.cpp b/TileEngine/WorldDat.cpp index 5e9a1580..92b1b204 100644 --- a/TileEngine/WorldDat.cpp +++ b/TileEngine/WorldDat.cpp @@ -138,7 +138,6 @@ void InitEngineTilesets( ) #endif } -#ifdef USE_VFS void ExportTilesets(vfs::Path const& filename) { UINT32 uiNumBytesRead = 0; @@ -217,7 +216,6 @@ void ExportTilesets(vfs::Path const& filename) xmlw.closeNode(); xmlw.writeToFile(filename); } -#endif void SetTilesetOneTerrainValues( ) { diff --git a/TileEngine/worlddef.cpp b/TileEngine/worlddef.cpp index bf616f58..628a35e3 100644 --- a/TileEngine/worlddef.cpp +++ b/TileEngine/worlddef.cpp @@ -2437,14 +2437,10 @@ BOOLEAN EvaluateWorld(STR8 pSector, UINT8 ubLevel) if(ValidMapFileName(szFileName)) strcpy(szFilename, pSector); sprintf(szDirFilename, "MAPS\\%s", szFilename); -#ifdef USE_VFS//dnl ch81 021213 if(guiCurrentScreen == LOADSAVE_SCREEN) hfile = FileOpen(szDirFilename, FILE_ACCESS_READ, FALSE, gzProfileName); else hfile = FileOpen(szDirFilename, FILE_ACCESS_READ); -#else - hfile = FileOpen(szDirFilename, FILE_ACCESS_READ, FALSE); -#endif if(!hfile) return(FALSE); uiFileSize = FileGetSize(hfile); @@ -2851,7 +2847,6 @@ BOOLEAN LoadWorld(const STR8 puiFilename, FLOAT* pMajorMapVersion, UINT8* pMinor else sprintf(aFilename, "MAPS\\%s", puiFilename); // Open file -#ifdef USE_VFS//dnl ch81 021213 #ifdef JA2EDITOR if(guiCurrentScreen == LOADSAVE_SCREEN) hfile = FileOpen(aFilename, FILE_ACCESS_READ, FALSE, gzProfileName); @@ -2859,9 +2854,6 @@ BOOLEAN LoadWorld(const STR8 puiFilename, FLOAT* pMajorMapVersion, UINT8* pMinor hfile = FileOpen(aFilename, FILE_ACCESS_READ); #else hfile = FileOpen(aFilename, FILE_ACCESS_READ); -#endif -#else - hfile = FileOpen(aFilename, FILE_ACCESS_READ, FALSE); #endif if(!hfile) { diff --git a/Utils/Cinematics Bink.cpp b/Utils/Cinematics Bink.cpp index 2e17d1a2..4393c13b 100644 --- a/Utils/Cinematics Bink.cpp +++ b/Utils/Cinematics Bink.cpp @@ -171,17 +171,6 @@ BINKFLIC *BinkOpenFlic( const CHAR8 *cFilename ) ErrorMsg("BINK ERROR: Out of flic slots, cannot open another"); return(NULL); } -#ifndef USE_VFS - // Attempt opening the filename - if(!(pBink->hFileHandle = FileOpen( const_cast(cFilename), FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE ) ) ) - { - ErrorMsg("BINK ERROR: Can't open the BINK file"); - return(NULL); - } - - //Get the real file handle for the file man handle for the smacker file - HANDLE hFile = GetRealFileHandleFromFileManFileHandle( pBink->hFileHandle ); -#else vfs::Path introname(cFilename); vfs::Path dir,filename; introname.splitLast(dir,filename); @@ -207,11 +196,7 @@ BINKFLIC *BinkOpenFlic( const CHAR8 *cFilename ) SGP_RETHROW(_BS(L"Intro file \"") << filename << L"\" could not be extracted" << _BS::wget, ex); } } -#endif -#ifndef USE_VFS - if( !( pBink->BinkHandle = BinkOpen((CHAR8 *)hFile, BINKFILEHANDLE ) ) ) //| SMACKTRACKS -#else vfs::Path tempfilename; try { @@ -226,7 +211,6 @@ BINKFLIC *BinkOpenFlic( const CHAR8 *cFilename ) SGP_RETHROW(L"Temporary intro file could not be read", ex); } if( !( pBink->BinkHandle = BinkOpen(tempfilename.to_string().c_str(), BINKNOTHREADEDIO /*BINKFILEHANDLE*/ ) ) ) //| SMACKTRACKS -#endif { ErrorMsg("BINK ERROR: Bink won't open the BINK file"); return(NULL); diff --git a/Utils/Cinematics.cpp b/Utils/Cinematics.cpp index 8dc05604..5e810cbd 100644 --- a/Utils/Cinematics.cpp +++ b/Utils/Cinematics.cpp @@ -194,19 +194,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename) return(NULL); } -#ifndef USE_VFS - // Attempt opening the filename - if(!(pSmack->hFileHandle=FileOpen(cFilename, FILE_OPEN_EXISTING | FILE_ACCESS_READ, FALSE))) - { - ErrorMsg("SMK ERROR: Can't open the SMK file"); - return(NULL); - } - - HANDLE hFile; - - //Get the real file handle for the file man handle for the smacker file - hFile = GetRealFileHandleFromFileManFileHandle( pSmack->hFileHandle ); -#else vfs::Path introname(cFilename); vfs::Path dir,filename; introname.splitLast(dir,filename); @@ -232,7 +219,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename) SGP_RETHROW(_BS(L"Intro file \"") << filename << L"\" could not be extracted" << _BS::wget, ex); } } -#endif // Allocate a Smacker buffer for video decompression if(!(pSmack->SmackBuffer=SmackBufferOpen(hDisplayWindow,SMACKAUTOBLIT,SCREEN_WIDTH,SCREEN_HEIGHT,0,0))) @@ -240,9 +226,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename) ErrorMsg("SMK ERROR: Can't allocate a Smacker decompression buffer"); return(NULL); } -#ifndef USE_VFS - if(!(pSmack->SmackHandle=SmackOpen((CHAR8 *)hFile, SMACKFILEHANDLE | SMACKTRACKS, SMACKAUTOEXTRA))) -#else // if(!(pSmack->SmackHandle=SmackOpen(cFilename, SMACKTRACKS, SMACKAUTOEXTRA))) vfs::Path tempfilename; try @@ -258,7 +241,6 @@ SMKFLIC *SmkOpenFlic(const CHAR8 *cFilename) SGP_RETHROW(L"Temporary intro file could not be read", ex); } if(!(pSmack->SmackHandle=SmackOpen(tempfilename.to_string().c_str(), SMACKTRACKS, SMACKAUTOEXTRA))) -#endif { ErrorMsg("SMK ERROR: Smacker won't open the SMK file"); return(NULL); diff --git a/Utils/Debug Control.cpp b/Utils/Debug Control.cpp index b1fa6fa7..21ca49e0 100644 --- a/Utils/Debug Control.cpp +++ b/Utils/Debug Control.cpp @@ -62,30 +62,10 @@ static struct LiveLog { void LiveMessage( CHAR8 *strMessage) { -#ifndef USE_VFS - FILE *OutFile; - - if ((OutFile = fopen("Log.txt", "a+t")) != NULL) - { - fprintf(OutFile, "%s\n", strMessage); - fclose(OutFile); - } -#else SGP_LOG(s_LiveLog.id, strMessage); -#endif } void MPDebugMsg( CHAR8 *strMessage) { -#ifndef USE_VFS - FILE *OutFile; - - if ((OutFile = fopen("MPDebug.txt", "a+t")) != NULL) - { - fprintf(OutFile, "%s\n", strMessage); - fclose(OutFile); - } -#else static vfs::Log& mpMsg = *vfs::Log::create(L"MPDebug.txt", true); mpMsg << strMessage << vfs::Log::endl; -#endif } diff --git a/Utils/INIReader.cpp b/Utils/INIReader.cpp index f9649c86..d238ddb0 100644 --- a/Utils/INIReader.cpp +++ b/Utils/INIReader.cpp @@ -12,9 +12,7 @@ #include -#ifdef USE_VFS std::set CIniReader::m_merge_files; -#endif std::stack iniErrorMessages; template @@ -32,26 +30,14 @@ void PushErrorMessage(std::string const& filename, iniErrorMessages.push(errMessage.str()); } -#ifdef USE_VFS void CIniReader::RegisterFileForMerging(vfs::Path const& filename) { m_merge_files.insert(filename); } -#endif CIniReader::CIniReader(const STR8 szFileName) { memset(m_szFileName,0,sizeof(m_szFileName)); -#ifndef USE_VFS - // Snap: Look for the INI file in the custom Data directory. - // If not there, leave at default location. - if ( gCustomDataCat.FindFile(szFileName) ) { - sprintf(m_szFileName, "%s\\%s", gCustomDataCat.GetRootDir().c_str(), szFileName); - } - else { - sprintf(m_szFileName, "%s\\%s", gDefaultDataCat.GetRootDir().c_str(), szFileName); - } -#else strncpy(m_szFileName,szFileName, std::min(strlen(szFileName), sizeof(m_szFileName)-1)); if(m_merge_files.find(szFileName) == m_merge_files.end()) { @@ -81,7 +67,6 @@ CIniReader::CIniReader(const STR8 szFileName) if(getVFS()->fileExists(OvrFileName)) m_oProps.initFromIniFile(vfs::Path(OvrFileName)); } -#endif } CIniReader::CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path) @@ -89,32 +74,6 @@ CIniReader::CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path) memset(m_szFileName,0,sizeof(m_szFileName)); // ary-05/05/2009 : force custom data path for potential non existing file -or- force default data path // : Also, flag file detection to allow functions to determine course of action for case of file [not found/is found]. -#ifndef USE_VFS - if ( Force_Custom_Data_Path ) - { - if ( gCustomDataCat.FindFile(szFileName) ) - { - CIniReader_File_Found = TRUE; - } - else - { - CIniReader_File_Found = FALSE; - } - sprintf(m_szFileName, "%s\\%s", gCustomDataCat.GetRootDir().c_str(), szFileName); - } - else - { - if ( gDefaultDataCat.FindFile(szFileName) ) - { - CIniReader_File_Found = TRUE; - } - else - { - CIniReader_File_Found = FALSE; - } - sprintf(m_szFileName, "%s\\%s", gDefaultDataCat.GetRootDir().c_str(), szFileName); - } -#else strncpy(m_szFileName,szFileName, std::min(strlen(szFileName), sizeof(m_szFileName)-1)); if(m_merge_files.find(szFileName) == m_merge_files.end()) { @@ -137,38 +96,24 @@ CIniReader::CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path) rev_order.pop(); } } - -#endif } void CIniReader::Clear() { -#ifndef USE_VFS - memset(m_szFileName, 0, MAX_PATH); -#else memset(m_szFileName, 0, MAX_PATH); m_oProps.clearContainer(); -#endif } int CIniReader::ReadInteger(const STR8 szSection, const STR8 szKey, int iDefaultValue) { -#ifndef USE_VFS - return GetPrivateProfileInt(szSection, szKey, iDefaultValue, m_szFileName); -#else return (int)(m_oProps.getIntProperty(szSection, szKey, iDefaultValue)); -#endif } int CIniReader::ReadInteger(const STR8 szSection, const STR8 szKey, int defaultValue, int minValue, int maxValue) { -#ifndef USE_VFS - int iniValueReadFromFile = (int)(GetPrivateProfileInt(szSection, szKey, defaultValue, m_szFileName)); -#else int iniValueReadFromFile = (int)(m_oProps.getIntProperty(szSection, szKey, defaultValue)); -#endif //AssertGE(iniValueReadFromFile, minValue); //AssertLE(iniValueReadFromFile, maxValue); if (iniValueReadFromFile < minValue) @@ -200,15 +145,7 @@ int CIniReader::ReadInteger(const STR8 szSection, const STR8 szKey, int defaultV double CIniReader::ReadDouble(const STR8 szSection, const STR8 szKey, double defaultValue, double minValue, double maxValue) { double iniValueReadFromFile; -#ifndef USE_VFS - char szResult[255]; - char szDefault[255]; - sprintf(szDefault, "%f", defaultValue); - GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName); - iniValueReadFromFile = (float) atof(szResult); -#else iniValueReadFromFile = m_oProps.getFloatProperty(szSection, szKey, defaultValue); -#endif //AssertGE(iniValueReadFromFile, minValue); //AssertLE(iniValueReadFromFile, maxValue); if (iniValueReadFromFile < minValue) @@ -227,15 +164,7 @@ double CIniReader::ReadDouble(const STR8 szSection, const STR8 szKey, double def FLOAT CIniReader::ReadFloat(const STR8 szSection, const STR8 szKey, FLOAT defaultValue, FLOAT minValue, FLOAT maxValue) { FLOAT iniValueReadFromFile; -#ifndef USE_VFS - char szResult[255]; - char szDefault[255]; - sprintf(szDefault, "%f", defaultValue); - GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName); - iniValueReadFromFile = (FLOAT) atof(szResult); -#else iniValueReadFromFile = (FLOAT) m_oProps.getFloatProperty(szSection, szKey, (float)defaultValue); -#endif //AssertGE(iniValueReadFromFile, minValue); //AssertLE(iniValueReadFromFile, maxValue); @@ -329,18 +258,6 @@ void CIniReader::ReadINT32Array(const STR8 szSection, const STR8 szKey, std::vec BOOLEAN CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, bool defaultValue, bool bolDisplayError) { -#ifndef USE_VFS - char szResult[255]; - char szDefault[255]; - sprintf(szDefault, "%s", defaultValue? "TRUE" : "FALSE"); - GetPrivateProfileString(szSection, szKey, szDefault, szResult, 255, m_szFileName); - for (int idx=0; (szResult[idx] != 0) && (idx < 255); ++idx) - szResult[idx] = toupper(szResult[idx]); - if (strcmp(szResult, "TRUE") == 0) - return TRUE; - else if (strcmp(szResult, "FALSE") == 0) - return FALSE; -#else vfs::String str = m_oProps.getStringProperty(szSection, szKey, L""); if( vfs::StrCmp::Equal(str, L"true") ) { @@ -353,7 +270,7 @@ BOOLEAN CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, bool def std::string szResult = str.utf8(); char szDefault[255]; sprintf(szDefault, "%s", defaultValue? "TRUE" : "FALSE"); -#endif + if(bolDisplayError){ std::stringstream errMessage; errMessage << "The value [" << szSection << "][" << szKey << "] = \"" << szResult << "\" " @@ -370,14 +287,10 @@ BOOLEAN CIniReader::ReadBoolean(const STR8 szSection, const STR8 szKey, bool def void CIniReader::ReadString(const STR8 szSection, const STR8 szKey, const STR8 szDefaultValue, STR8 input_buffer, size_t buffer_size) { -#ifndef USE_VFS - GetPrivateProfileString(szSection, szKey, szDefaultValue, input_buffer, buffer_size, m_szFileName); -#else std::string s = m_oProps.getStringProperty(szSection, szKey, szDefaultValue).utf8(); int len = std::min(s.length(),buffer_size-1); strncpy(input_buffer, s.c_str(), len); input_buffer[len] = 0; -#endif } // WANNE - MP: Old version, currently used by Multiplayer @@ -386,12 +299,8 @@ STR8 CIniReader::ReadString(const STR8 szSection, const STR8 szKey, const STR8 s // >>>>> Memory Leak <<<<< STR8 szResult = new char[255]; memset(szResult, 0x00, 255); -#ifndef USE_VFS - GetPrivateProfileString(szSection, szKey, szDefaultValue, szResult, 255, m_szFileName); -#else std::string s = m_oProps.getStringProperty(szSection, szKey, szDefaultValue).utf8(); strncpy(szResult, s.c_str(), std::min(s.length(),254)); -#endif return szResult; } @@ -429,20 +338,7 @@ UINT32 CIniReader::ReadUINT32(const STR8 szSection, const STR8 szKey, UINT32 def UINT32 CIniReader::ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue ) { UINT32 iniValueReadFromFile; -#ifndef USE_VFS - STR8 szResult = new char[255]; - STR8 szDefault = new char[255]; - - memset(szResult, 0x00, 255); - memset(szDefault, 0x00, 255); - - sprintf(szDefault, "%u", defaultValue); - - this->ReadString (szSection , szKey , szDefault, szResult, (size_t) 255 ); - iniValueReadFromFile = (UINT32) strtoul(szResult,NULL,0); -#else iniValueReadFromFile = (UINT32) m_oProps.getUIntProperty(szSection, szKey, defaultValue); -#endif //AssertGE(iniValueReadFromFile, minValue); //AssertLE(iniValueReadFromFile, maxValue); @@ -457,10 +353,5 @@ UINT32 CIniReader::ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defau iniValueReadFromFile = maxValue; } -#ifndef USE_VFS - delete [] szResult ; - delete [] szDefault ; -#endif return iniValueReadFromFile; - } diff --git a/Utils/INIReader.h b/Utils/INIReader.h index 947cdeff..11595a1e 100644 --- a/Utils/INIReader.h +++ b/Utils/INIReader.h @@ -56,18 +56,14 @@ public: BOOLEAN Is_CIniReader_File_Found(void) {return (CIniReader_File_Found);} void Clear(); -#ifdef USE_VFS static void RegisterFileForMerging(vfs::Path const& filename); -#endif private: vfs::PropertyContainer m_oProps; char m_szFileName[MAX_PATH]; BOOLEAN CIniReader_File_Found; UINT32 ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue); -#ifdef USE_VFS static std::set m_merge_files; -#endif }; -#endif//INIREADER_H \ No newline at end of file +#endif//INIREADER_H diff --git a/Utils/message.cpp b/Utils/message.cpp index 4c6163c4..2befaa26 100644 --- a/Utils/message.cpp +++ b/Utils/message.cpp @@ -1522,22 +1522,8 @@ static struct DebugMessageLog { void WriteMessageToFile( const STR16 pString ) { #ifdef JA2BETAVERSION -#ifndef USE_VFS - FILE *fp; - - fp = fopen( "DebugMessage.txt", "a" ); - - if( fp == NULL ) - { - return; - } - - fprintf( fp, "%S\n", pString ); - fclose( fp ); -#else SGP_LOG(s_DebugMessageLog.id, pString); #endif -#endif } diff --git a/jascreens.cpp b/jascreens.cpp index 4409a0b4..b431dd2e 100644 --- a/jascreens.cpp +++ b/jascreens.cpp @@ -396,44 +396,25 @@ UINT32 InitScreenHandle(void) // Handle queued .ini file error messages int y = 40; -#ifdef USE_VFS sgp::Logger_ID ini_id = sgp::Logger::instance().createLogger(); sgp::Logger::instance().connectFile(ini_id, L"iniErrorReport.txt", false, sgp::Logger::FLUSH_ON_DELETE); sgp::Logger::LogInstance logger = sgp::Logger::instance().logger(ini_id); -#endif while (! iniErrorMessages.empty()) { -#ifndef USE_VFS - FILE *file_pointer; -#endif static BOOL iniErrorMessage_create_out_file = TRUE; std::string iniErrorMessage = iniErrorMessages.top(); CHAR16 str[256]; if (iniErrorMessage_create_out_file) { -#ifndef USE_VFS - fopen_s( &file_pointer, "..\\iniErrorReport.txt", "w" ); -#endif y += 25; swprintf( str, L"%S", "Warning: found the following ini errors. iniErrorReport.txt has been created." ); DisplayWrappedString( 10, y, 560, 2, FONT12ARIAL, FONT_ORANGE, str, FONT_BLACK, TRUE, LEFT_JUSTIFIED ); iniErrorMessage_create_out_file = FALSE; } - else - { -#ifndef USE_VFS - fopen_s( &file_pointer, "..\\iniErrorReport.txt", "a+" ); -#endif - } y += 25; swprintf( str, L"%S", iniErrorMessage.c_str() ); -#ifndef USE_VFS - fprintf_s (file_pointer , "%S\n" , str ); - fclose( file_pointer ); -#else logger << iniErrorMessage << sgp::endl; -#endif DisplayWrappedString( 10, y, 560, 2, FONT12ARIAL, FONT_ORANGE, str, FONT_BLACK, TRUE, LEFT_JUSTIFIED ); iniErrorMessages.pop(); From 0b5f14a3ad3dd4a220706206d77e338c4f7b651c Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:45:40 +0300 Subject: [PATCH 041/120] Remove empty function --- Standard Gaming Platform/FileMan.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index e7f2a1d0..c11c1282 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -78,8 +78,6 @@ static tFILEMAP s_mapFiles; #define CHECKN(exp) if (!(exp)) { return(NULL); } #define CHECKBI(exp) if (!(exp)) { return(-1); } -#define PRINT_DEBUG_INFO FileDebugPrint(); - //************************************************************************** // // Typedefs @@ -148,7 +146,6 @@ TFileCat gCustomDataCat; // Init in InitializeStandardGamingPlatform (sgp.cpp) void W32toSGPFileFind( GETFILESTRUCT *pGFStruct, WIN32_FIND_DATA *pW32Struct ); -void FileDebugPrint( void ); HANDLE GetHandleToRealFile( HWFILE hFile, BOOLEAN *pfDatabaseFile ); HWFILE CreateFileHandle( HANDLE hRealFile, BOOLEAN fDatabaseFile ); void DestroyFileHandle( HWFILE hFile ); @@ -823,23 +820,6 @@ UINT32 FileGetSize( HWFILE hFile ) return 0; } -//************************************************************************** -// -// FileDebugPrint -// -// To print the state of memory to output. -// -// Parameter List : -// Return Value : -// Modification history : -// -// 24sep96:HJH ->creation -// -//************************************************************************** - -void FileDebugPrint( void ) -{ -} //************************************************************************** // From 74a25a20698f4c8cb64c6a361b8970251da9d348 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:46:36 +0300 Subject: [PATCH 042/120] Remove empty function --- Standard Gaming Platform/soundman.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/Standard Gaming Platform/soundman.cpp b/Standard Gaming Platform/soundman.cpp index a2f5869e..743dd087 100644 --- a/Standard Gaming Platform/soundman.cpp +++ b/Standard Gaming Platform/soundman.cpp @@ -61,7 +61,6 @@ FILE *SndDebug; // Debug logging void SoundLog(CHAR8 *strMessage); -void InitLogging(); // Cache system BOOLEAN SoundInitCache(void); @@ -213,7 +212,6 @@ BOOLEAN InitializeSoundManager(void) { UINT32 uiCount; - InitLogging(); if(fSoundSystemInit) { @@ -1871,15 +1869,3 @@ void SoundLog(CHAR8 *strMessage) } s_SoundLog; SGP_LOG(s_SoundLog.id, vfs::String::widen(strMessage,strlen(strMessage))); } - -//***************************************************************************************** -// InitLogging -// Creates empty log file -// -// Returns nothing -// -// Created: 10.12.2005 Lesh -//***************************************************************************************** -void InitLogging() -{ -} From f5e0d0bbd8611f08e54300ab170e401121f7a35c Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:47:13 +0300 Subject: [PATCH 043/120] Remove useless function --- Standard Gaming Platform/FileMan.cpp | 6 ------ Standard Gaming Platform/FileMan.h | 1 - 2 files changed, 7 deletions(-) diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index c11c1282..3b57cd69 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -1176,12 +1176,6 @@ BOOLEAN DirectoryExists( STRING512 pcDirectory ) } -BOOLEAN MakeFileManDirectory( STRING512 pcDirectory ) -{ - return FALSE; -} - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Removes ALL FILES in the specified directory (and all subdirectories with their files if fRecursive is TRUE) // Use EraseDirectory() to simply delete directory contents without deleting the directory itself diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index b35f06fe..0ef827c1 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -132,7 +132,6 @@ BOOLEAN GetFileManCurrentDirectory( STRING512 pcDirectory ); BOOLEAN GetExecutableDirectory( STRING512 pcDirectory ); BOOLEAN DirectoryExists( STRING512 pcDirectory ); -BOOLEAN MakeFileManDirectory( STRING512 pcDirectory ); // WARNING: THESE DELETE ALL FILES IN THE DIRECTORY ( and all subdirectories if fRecursive is TRUE!! ) BOOLEAN RemoveFileManDirectory( STRING512 pcDirectory, BOOLEAN fRecursive); From f11534e792e64e6aa4957c3e495abadf38574a6a Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:47:38 +0300 Subject: [PATCH 044/120] Remove orphan function declaration --- Standard Gaming Platform/FileMan.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index 0ef827c1..a1350eaa 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -179,10 +179,6 @@ INT32 CompareSGPFileTimes( SGP_FILETIME *pFirstFileTime, SGP_FILETIME *pSecondFi // files times may be slightly different due to SourceSafe of copying BOOLEAN FileIsOlderThanFile(CHAR8 *pcFileName1, CHAR8 *pcFileName2, UINT32 ulNumSeconds); -// Pass in the Fileman file handle of an OPEN file and it will return.. -// if its a Real File, the return will be the handle of the REAL file -// if its a LIBRARY file, the return will be the handle of the LIBRARY -HANDLE GetRealFileHandleFromFileManFileHandle( HWFILE hFile ); BOOLEAN AddSubdirectoryToPath(CHAR8 *pDirectory); From 5a922e3a42c1400e118538ec8e990c59fed7b1d3 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 16:48:18 +0300 Subject: [PATCH 045/120] Remove useless function --- Editor/Sector Summary.cpp | 3 ++- Laptop/files.cpp | 1 - Laptop/finances.cpp | 1 - Laptop/history.cpp | 1 - Laptop/laptop.cpp | 4 ---- Standard Gaming Platform/FileMan.cpp | 5 ----- Standard Gaming Platform/FileMan.h | 2 -- 7 files changed, 2 insertions(+), 15 deletions(-) diff --git a/Editor/Sector Summary.cpp b/Editor/Sector Summary.cpp index b7174247..9c328cfa 100644 --- a/Editor/Sector Summary.cpp +++ b/Editor/Sector Summary.cpp @@ -2177,7 +2177,8 @@ void SummarySaveMapCallback( GUI_BUTTON *btn, INT32 reason ) { CHAR8 filename[40]; sprintf( filename, "MAPS\\%S", gszDisplayName ); - FileClearAttributes( filename ); + // Other call sites have replaced this with FileDelete(); for VFS, should we do the same here? + //FileClearAttributes( filename ); } if( ExternalSaveMap( gszDisplayName ) ) { diff --git a/Laptop/files.cpp b/Laptop/files.cpp index feb80271..3de647b9 100644 --- a/Laptop/files.cpp +++ b/Laptop/files.cpp @@ -476,7 +476,6 @@ void GameInitFiles( ) { if ( FileExists( FILES_DAT_FILE ) == TRUE ) { - FileClearAttributes( FILES_DAT_FILE ); FileDelete( FILES_DAT_FILE ); } diff --git a/Laptop/finances.cpp b/Laptop/finances.cpp index 57c8acba..ac542863 100644 --- a/Laptop/finances.cpp +++ b/Laptop/finances.cpp @@ -460,7 +460,6 @@ void GameInitFinances() // unlink Finances data file if( (FileExists( FINANCES_DATA_FILE ) ) ) { - FileClearAttributes( FINANCES_DATA_FILE ); FileDelete( FINANCES_DATA_FILE ); } GetBalanceFromDisk( ); diff --git a/Laptop/history.cpp b/Laptop/history.cpp index 6067098d..3ca4a8c4 100644 --- a/Laptop/history.cpp +++ b/Laptop/history.cpp @@ -227,7 +227,6 @@ void GameInitHistory() if( ( FileExists( HISTORY_DATA_FILE ) ) ) { // unlink history file - FileClearAttributes( HISTORY_DATA_FILE ); FileDelete( HISTORY_DATA_FILE ); } diff --git a/Laptop/laptop.cpp b/Laptop/laptop.cpp index 33e95d76..00c2f161 100644 --- a/Laptop/laptop.cpp +++ b/Laptop/laptop.cpp @@ -7136,28 +7136,24 @@ void ClearOutTempLaptopFiles( void ) // file file if ( (FileExists( "files.dat" ) == TRUE ) ) { - FileClearAttributes( "files.dat" ); FileDelete( "files.dat" ); } // finances if ( (FileExists( "finances.dat" ) == TRUE ) ) { - FileClearAttributes( "finances.dat" ); FileDelete( "finances.dat" ); } // email if ( (FileExists( "email.dat" ) == TRUE ) ) { - FileClearAttributes( "email.dat" ); FileDelete( "email.dat" ); } // history if ( (FileExists( "history.dat" ) == TRUE ) ) { - FileClearAttributes( "history.dat" ); FileDelete( "history.dat" ); } } diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index 3b57cd69..9e4c3804 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -1472,11 +1472,6 @@ UINT32 FileGetAttributes( STR strFilename ) return( uiFileAttrib ); } -BOOLEAN FileClearAttributes( STR strFilename ) -{ - return TRUE; -} - //returns true if at end of file, else false BOOLEAN FileCheckEndOfFile( HWFILE hFile ) diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index a1350eaa..e5ba0854 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -156,8 +156,6 @@ BOOLEAN FileMove(STR strOldName, STR strNewName); BOOLEAN FileSetAttributes( STR filename, UINT32 uiNewAttribs ); UINT32 FileGetAttributes( STR filename ); -BOOLEAN FileClearAttributes( STR strFilename ); - //returns true if at end of file, else false BOOLEAN FileCheckEndOfFile( HWFILE hFile ); From 8525d3f86967bb8a5877a42af1421ab88a52e8da Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 7 Oct 2023 22:40:45 +0300 Subject: [PATCH 046/120] Use std::vector for HVSURFACE->RegionList Replaces the use of old custom list implementation in container.cpp --- Standard Gaming Platform/vsurface.cpp | 75 ++++++++------------------- Standard Gaming Platform/vsurface.h | 6 +-- 2 files changed, 26 insertions(+), 55 deletions(-) diff --git a/Standard Gaming Platform/vsurface.cpp b/Standard Gaming Platform/vsurface.cpp index 8636b2c0..d9d0b064 100644 --- a/Standard Gaming Platform/vsurface.cpp +++ b/Standard Gaming Platform/vsurface.cpp @@ -110,6 +110,7 @@ HVSURFACE ghFrameBuffer = NULL; HVSURFACE ghMouseBuffer = NULL; #include +#include extern std::map g_SurfaceRectangle; @@ -1161,11 +1162,7 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc ) // // Allocate memory for Video Surface data and initialize // - - hVSurface = (HVSURFACE) MemAlloc( sizeof( SGPVSurface ) ); - memset( hVSurface, 0, sizeof( SGPVSurface ) ); - CHECKF( hVSurface != NULL ); - + hVSurface = new SGPVSurface{}; hVSurface->usHeight = usHeight; hVSurface->usWidth = usWidth; // BF : since we use a 16bpp framebuffer and images are converted to that format, @@ -1178,7 +1175,6 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc ) hVSurface->pPalette = NULL; hVSurface->p16BPPPalette = NULL; hVSurface->TransparentColor = FROMRGB( 0, 0, 0 ); - hVSurface->RegionList = CreateList( DEFAULT_NUM_REGIONS, sizeof( VSURFACE_REGION ) ); hVSurface->fFlags = 0; hVSurface->pClipper = NULL; @@ -1647,12 +1643,6 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface ) hVSurface->pPalette = NULL; } - //if ( hVSurface->pClipper != NULL ) - //{ - // Release Clipper - // DDReleaseClipper( (LPDIRECTDRAWCLIPPER)hVSurface->pClipper ); - //} - // Get surface pointer lpDDSurface = (LPDIRECTDRAWSURFACE2)hVSurface->pSurfaceData; @@ -1670,7 +1660,7 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface ) } // Release region data - DeleteList( hVSurface->RegionList ); + hVSurface->RegionList.clear(); //If there is a 16bpp palette, free it if( hVSurface->p16BPPPalette != NULL ) @@ -1682,8 +1672,7 @@ BOOLEAN DeleteVideoSurface( HVSURFACE hVSurface ) giMemUsedInSurfaces -= ( hVSurface->usHeight * hVSurface->usWidth * ( hVSurface->ubBitDepth / 8 ) ); // Release object - MemFree( hVSurface ); - + delete hVSurface; return( TRUE ); } @@ -1768,7 +1757,7 @@ BOOLEAN GetNumRegions( HVSURFACE hVSurface , UINT32 *puiNumRegions ) { Assert( hVSurface ); - *puiNumRegions = ListSize( hVSurface->RegionList ); + *puiNumRegions = hVSurface->RegionList.size(); return( TRUE ); @@ -1780,7 +1769,7 @@ BOOLEAN AddVSurfaceRegion( HVSURFACE hVSurface, VSURFACE_REGION *pNewRegion ) Assert( pNewRegion != NULL ); // Add new region to list - hVSurface->RegionList = AddtoList( hVSurface->RegionList, pNewRegion, ListSize( hVSurface->RegionList ) ); + hVSurface->RegionList.push_back(*pNewRegion); return( TRUE ); } @@ -1801,29 +1790,10 @@ BOOLEAN AddVSurfaceRegions( HVSURFACE hVSurface, VSURFACE_REGION **ppNewRegions, return( TRUE ); } -BOOLEAN RemoveVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex ) -{ - VSURFACE_REGION aRegion; - - Assert( hVSurface != NULL ); - - return( RemfromList( hVSurface->RegionList, &aRegion, usIndex ) ); - -} - BOOLEAN ClearAllVSurfaceRegions( HVSURFACE hVSurface ) { - UINT32 uiListSize; - Assert( hVSurface != NULL ); - - uiListSize = ListSize( hVSurface->RegionList ); - - for ( INT32 cnt = uiListSize - 1; cnt >= 0; cnt-- ) - { - RemoveVSurfaceRegion( hVSurface, (UINT16)cnt ); - } - + hVSurface->RegionList.clear(); return( TRUE ); } @@ -1831,12 +1801,13 @@ BOOLEAN GetVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION { Assert( hVSurface != NULL ); - if ( !PeekList( hVSurface->RegionList, aRegion, usIndex ) ) + if (usIndex < hVSurface->RegionList.size()) { - return( FALSE ); + *aRegion = hVSurface->RegionList[usIndex]; + return( TRUE ); } - return( TRUE ); + return( FALSE ); } BOOLEAN GetVSurfaceRect( HVSURFACE hVSurface, RECT *pRect) @@ -1858,16 +1829,13 @@ BOOLEAN ReplaceVSurfaceRegion( HVSURFACE hVSurface , UINT16 usIndex, VSURFACE_RE Assert( hVSurface != NULL ); - // Validate index given - if ( !PeekList( hVSurface->RegionList, &OldRegion, usIndex ) ) + if (usIndex < hVSurface->RegionList.size()) { - return( FALSE ); + hVSurface->RegionList[usIndex] = *aRegion; + return( TRUE ); } - // Replace information - hVSurface->RegionList = AddtoList( hVSurface->RegionList, aRegion, usIndex ); - - return( TRUE ); + return( FALSE ); } BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *pNewRegion ) @@ -1876,10 +1844,14 @@ BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_ Assert( pNewRegion != NULL ); // Add new region to list - hVSurface->RegionList = AddtoList( hVSurface->RegionList, pNewRegion, usIndex ); - - return( TRUE ); + if (usIndex < hVSurface->RegionList.size()) + { + auto pos = hVSurface->RegionList.begin() + usIndex; + hVSurface->RegionList.insert(pos, *pNewRegion); + return(TRUE); + } + return(FALSE); } // ******************************************************************* @@ -2161,7 +2133,7 @@ HVSURFACE CreateVideoSurfaceFromDDSurface( LPDIRECTDRAWSURFACE2 lpDDSurface ) // Allocate Video Surface struct - hVSurface = (HVSURFACE) MemAlloc( sizeof( SGPVSurface ) ); + hVSurface = new SGPVSurface{}; // Set values based on DD Surface given DDGetSurfaceDescription ( lpDDSurface, &DDSurfaceDesc ); @@ -2173,7 +2145,6 @@ HVSURFACE CreateVideoSurfaceFromDDSurface( LPDIRECTDRAWSURFACE2 lpDDSurface ) hVSurface->pSurfaceData = (PTR)lpDDSurface; hVSurface->pSurfaceData1 = NULL; hVSurface->pSavedSurfaceData = NULL; - hVSurface->RegionList = CreateList( DEFAULT_NUM_REGIONS, sizeof( VSURFACE_REGION ) ); hVSurface->fFlags = 0; // Get and Set palette, if attached, allow to fail diff --git a/Standard Gaming Platform/vsurface.h b/Standard Gaming Platform/vsurface.h index 57957423..8564aab5 100644 --- a/Standard Gaming Platform/vsurface.h +++ b/Standard Gaming Platform/vsurface.h @@ -5,6 +5,7 @@ #include "container.h" #include "himage.h" #include "vobject.h" +#include /////////////////////////////////////////////////////////////////////////////////////////////////// // @@ -105,7 +106,7 @@ typedef struct UINT16 *p16BPPPalette; // A 16BPP palette used for 8->16 blits COLORVAL TransparentColor; // Defaults to 0,0,0 PTR pClipper; // A void pointer encapsolated as a clipper Surface - HLIST RegionList; // A List of regions within the video Surface + std::vector RegionList; // A List of regions within the video Surface } SGPVSurface, *HVSURFACE; @@ -240,7 +241,6 @@ BOOLEAN DeleteVideoSurfaceFromIndex( UINT32 uiIndex ); BOOLEAN AddVSurfaceRegion( HVSURFACE hVSurface, VSURFACE_REGION *pNewRegion ); BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *pNewRegion ); BOOLEAN AddVSurfaceRegions( HVSURFACE hVSurface, VSURFACE_REGION **ppNewRegions, UINT16 uiNumRegions ); -BOOLEAN RemoveVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex ); BOOLEAN ClearAllVSurfaceRegions( HVSURFACE hVSurface ); BOOLEAN GetVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *aRegion ); BOOLEAN GetNumRegions( HVSURFACE hVSurface , UINT32 *puiNumRegions ); @@ -286,4 +286,4 @@ BOOLEAN ShadowVideoSurfaceRectUsingLowPercentTable( UINT32 uiDestVSurface, INT32 #endif */ -#endif \ No newline at end of file +#endif From d3b4874af0cd4c4eac737ef79afc802318b4ad02 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 7 Oct 2023 22:43:26 +0300 Subject: [PATCH 047/120] Remove unused global --- Standard Gaming Platform/vobject.cpp | 1 - Standard Gaming Platform/vobject.h | 1 - 2 files changed, 2 deletions(-) diff --git a/Standard Gaming Platform/vobject.cpp b/Standard Gaming Platform/vobject.cpp index d8ade50c..c784a383 100644 --- a/Standard Gaming Platform/vobject.cpp +++ b/Standard Gaming Platform/vobject.cpp @@ -51,7 +51,6 @@ -HLIST ghVideoObjects = NULL; BOOLEAN gfVideoObjectsInit=FALSE; #ifndef SGP_VIDEO_DEBUGGING diff --git a/Standard Gaming Platform/vobject.h b/Standard Gaming Platform/vobject.h index 0cdd5553..c4964899 100644 --- a/Standard Gaming Platform/vobject.h +++ b/Standard Gaming Platform/vobject.h @@ -225,7 +225,6 @@ BOOLEAN GetETRLEPixelValue( UINT8 * pDest, HVOBJECT hVObject, UINT16 usETLREInde // Globals // // **************************************************************************** -extern HLIST ghVideoObjects; // **************************************************************************** // From 029af63eb8d84afbd6c188543d95aaffba1ef155 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 7 Oct 2023 22:54:00 +0300 Subject: [PATCH 048/120] Remove unused global --- Standard Gaming Platform/vsurface.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Standard Gaming Platform/vsurface.cpp b/Standard Gaming Platform/vsurface.cpp index d9d0b064..bf103bbc 100644 --- a/Standard Gaming Platform/vsurface.cpp +++ b/Standard Gaming Platform/vsurface.cpp @@ -98,12 +98,6 @@ void CheckValidVSurfaceIndex( UINT32 uiIndex ); INT32 giMemUsedInSurfaces; - -//OBSOLETE!!!!!!!!! -HLIST ghVideoSurfaces = NULL; -//OBSOLETE!!!!!!!!! - - HVSURFACE ghPrimary = NULL; HVSURFACE ghBackBuffer = NULL; HVSURFACE ghFrameBuffer = NULL; From f00214d00dd73d5e8bb59d3e9b5f36803dc2be3e Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sun, 8 Oct 2023 14:55:22 +0300 Subject: [PATCH 049/120] Use std::queue and std::vector in event system instead of old custom code from container.cpp * Removed initialize and shutdown event manager calls from Init.cpp as they were only used to create and destroy the old HLIST globals * Moved code from Event Manager.cpp to Event Pump.cpp as the event queue system is only used in said file. * Removed now useless event manager.cpp and .h files --- Init.cpp | 8 - Utils/CMakeLists.txt | 1 - Utils/Event Manager.cpp | 234 ------------------------ Utils/Event Manager.h | 33 ---- Utils/Event Pump.cpp | 383 ++++++++++++++++++++++++++++------------ Utils/Event Pump.h | 7 +- 6 files changed, 269 insertions(+), 397 deletions(-) delete mode 100644 Utils/Event Manager.cpp delete mode 100644 Utils/Event Manager.h diff --git a/Init.cpp b/Init.cpp index 20788424..605a13a7 100644 --- a/Init.cpp +++ b/Init.cpp @@ -1514,12 +1514,6 @@ UINT32 InitializeJA2(void) // INit intensity tables BuildIntensityTable( ); - // Init Event Manager - if ( !InitializeEventManager( ) ) - { - return( ERROR_SCREEN ); - } - // Initailize World if ( !InitializeWorld( ) ) { @@ -1698,8 +1692,6 @@ void ShutdownJA2(void) ShutdownJA2Sound( ); - ShutdownEventManager( ); - ShutdownBaseDirtyRectQueue( ); // Unload any text box images! diff --git a/Utils/CMakeLists.txt b/Utils/CMakeLists.txt index 0a11b8bb..688f9555 100644 --- a/Utils/CMakeLists.txt +++ b/Utils/CMakeLists.txt @@ -6,7 +6,6 @@ set(UtilsSrc "${CMAKE_CURRENT_SOURCE_DIR}/Debug Control.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/dsutil.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Encrypted File.cpp" -"${CMAKE_CURRENT_SOURCE_DIR}/Event Manager.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Event Pump.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/ExportStrings.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Font Control.cpp" diff --git a/Utils/Event Manager.cpp b/Utils/Event Manager.cpp deleted file mode 100644 index edd39c59..00000000 --- a/Utils/Event Manager.cpp +++ /dev/null @@ -1,234 +0,0 @@ - #include - #include - #include "sgp.h" - #include "container.h" - #include "wcheck.h" - #include "Event Manager.h" - #include "Timer Control.h" - -HLIST hEventQueue = NULL; -HLIST hDelayEventQueue = NULL; -HLIST hDemandEventQueue = NULL; - -#define QUEUE_RESIZE 20 - -// LOCAL FUNCTIONS -HLIST GetQueue( UINT8 ubQueueID ); -void SetQueue( UINT8 ubQueueID, HLIST hQueue ); - - -BOOLEAN InitializeEventManager( ) -{ - // Create Queue - hEventQueue = CreateList( QUEUE_RESIZE, sizeof( PTR ) ); - - if ( hEventQueue == NULL ) - { - return( FALSE ); - } - - // Create Delay Queue - hDelayEventQueue = CreateList( QUEUE_RESIZE, sizeof( PTR ) ); - - if ( hDelayEventQueue == NULL ) - { - return( FALSE ); - } - - // Create Demand Queue (events on this queue are only processed when specifically - // called for by code) - hDemandEventQueue = CreateList( QUEUE_RESIZE, sizeof( PTR ) ); - - if ( hDemandEventQueue == NULL ) - { - return( FALSE ); - } - - return( TRUE ); -} - -BOOLEAN ShutdownEventManager( ) -{ - if ( hEventQueue != NULL ) - { - DeleteList( hEventQueue ); - } - - if ( hDelayEventQueue != NULL ) - { - DeleteList( hDelayEventQueue ); - } - - if ( hDemandEventQueue != NULL ) - { - DeleteList( hDemandEventQueue ); - } - - return( TRUE ); -} - - - -BOOLEAN AddEvent( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSize, UINT8 ubQueueID ) -{ - EVENT *pEvent; - UINT32 uiEventSize = sizeof( EVENT ); - HLIST hQueue; - - // Allocate new event - pEvent = (EVENT *) MemAlloc( uiEventSize + uiDataSize ); - - CHECKF( pEvent != NULL ); - - // Set values - pEvent->TimeStamp = GetJA2Clock( ); - pEvent->usDelay = usDelay; - pEvent->uiEvent = uiEvent; - pEvent->uiFlags = 0; - pEvent->uiDataSize = uiDataSize; - pEvent->pData = (BYTE*)pEvent; - pEvent->pData = pEvent->pData + uiEventSize; - - memcpy( pEvent->pData, pEventData, uiDataSize ); - - // Add event to queue - hQueue = GetQueue( ubQueueID ); - hQueue = AddtoList( hQueue, &pEvent, ListSize( hQueue ) ); - SetQueue( ubQueueID, hQueue ); - - return( TRUE ); - -} - - - -BOOLEAN RemoveEvent( EVENT **ppEvent, UINT32 uiIndex, UINT8 ubQueueID ) -{ - UINT32 uiQueueSize; - HLIST hQueue; - - // Get an event from queue, if one exists - // - - hQueue = GetQueue( ubQueueID ); - - - // Get Size - uiQueueSize = ListSize( hQueue ); - - if ( uiQueueSize > 0 ) - { - // Get - CHECKF( RemfromList( hQueue , ppEvent, uiIndex ) != FALSE ); - } - else - { - return( FALSE ); - } - - return( TRUE ); -} - - -BOOLEAN PeekEvent( EVENT **ppEvent, UINT32 uiIndex , UINT8 ubQueueID ) -{ - UINT32 uiQueueSize; - HLIST hQueue; - - // Get an event from queue, if one exists - // - - hQueue = GetQueue( ubQueueID ); - - - // Get Size - uiQueueSize = ListSize( hQueue ); - - if ( uiQueueSize > 0 ) - { - // Get - CHECKF( PeekList( hQueue, ppEvent, uiIndex ) != FALSE ); - } - else - { - return( FALSE ); - } - - return( TRUE ); -} - - - -BOOLEAN FreeEvent( EVENT *pEvent ) -{ - CHECKF( pEvent != NULL ); - - // Delete event - MemFree( pEvent ); - - return( TRUE ); -} - - -UINT32 EventQueueSize( UINT8 ubQueueID ) -{ - UINT32 uiQueueSize; - HLIST hQueue; - - // Get an event from queue, if one exists - // - - hQueue = GetQueue( ubQueueID ); - - // Get Size - uiQueueSize = ListSize( hQueue ); - - return( uiQueueSize ); -} - - -HLIST GetQueue( UINT8 ubQueueID ) -{ - switch( ubQueueID ) - { - case PRIMARY_EVENT_QUEUE: - return( hEventQueue ); - break; - - case SECONDARY_EVENT_QUEUE: - return( hDelayEventQueue ); - break; - - case DEMAND_EVENT_QUEUE: - return( hDemandEventQueue ); - break; - - default: - Assert( FALSE ); - return( 0 ); - break; - } - -} - -void SetQueue( UINT8 ubQueueID, HQUEUE hQueue ) -{ - switch( ubQueueID ) - { - case PRIMARY_EVENT_QUEUE: - hEventQueue = hQueue; - break; - - case SECONDARY_EVENT_QUEUE: - hDelayEventQueue = hQueue; - break; - - case DEMAND_EVENT_QUEUE: - hDemandEventQueue = hQueue; - break; - - default: - Assert( FALSE ); - break; - } -} diff --git a/Utils/Event Manager.h b/Utils/Event Manager.h deleted file mode 100644 index 1e24941f..00000000 --- a/Utils/Event Manager.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef __EVENT_MANAGER_H -#define __EVENT_MANAGER_H - -typedef struct -{ - TIMER TimeStamp; - UINT32 uiFlags; - UINT16 usDelay; - UINT32 uiEvent; - UINT32 uiDataSize; - BYTE *pData; - -} EVENT; - -#define PRIMARY_EVENT_QUEUE 0 -#define SECONDARY_EVENT_QUEUE 1 -#define DEMAND_EVENT_QUEUE 2 - -#define EVENT_EXPIRED 0x00000002 - -// Management fucntions -BOOLEAN InitializeEventManager( ); -BOOLEAN ShutdownEventManager( ); - -BOOLEAN AddEvent( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSize, UINT8 ubQueueID ); -BOOLEAN RemoveEvent( EVENT **ppEvent, UINT32 uiIndex , UINT8 ubQueueID ); -BOOLEAN PeekEvent( EVENT **ppEvent, UINT32 uiIndex , UINT8 ubQueueID ); -BOOLEAN FreeEvent( EVENT *pEvent ); -UINT32 EventQueueSize( UINT8 ubQueueID ); - - -#endif - diff --git a/Utils/Event Pump.cpp b/Utils/Event Pump.cpp index da01372d..4c5f2a70 100644 --- a/Utils/Event Pump.cpp +++ b/Utils/Event Pump.cpp @@ -1,21 +1,26 @@ - #include - #include - #include "sgp.h" - #include "container.h" - #include "wcheck.h" - #include "Event Pump.h" - #include "Timer.h" - #include "Sound Control.h" - #include "Overhead.h" - #include "weapons.h" - #include "Animation Control.h" - #include "opplist.h" - #include "Tactical Save.h" +#include +#include +#include "sgp.h" +#include "container.h" +#include "wcheck.h" +#include "Event Pump.h" +#include "Timer.h" +#include "Sound Control.h" +#include "Overhead.h" +#include "weapons.h" +#include "Animation Control.h" +#include "opplist.h" +#include "Tactical Save.h" +#include +#include #ifdef NETWORKED #include "Networking.h" #include "NetworkEvent.h" #endif +#include "MemMan.h" +#include "Timer Control.h" +#include "DEBUG.H" UINT8 gubEncryptionArray4[ BASE_NUMBER_OF_ROTATION_ARRAYS * 3 ][ NEW_ROTATION_ARRAY_SIZE ] = { @@ -590,6 +595,26 @@ UINT8 gubEncryptionArray4[ BASE_NUMBER_OF_ROTATION_ARRAYS * 3 ][ NEW_ROTATION_AR }, }; +typedef struct +{ + TIMER TimeStamp; + UINT32 uiFlags; + UINT16 usDelay; + UINT32 uiEvent; + UINT32 uiDataSize; + BYTE* pData; + +} EVENT; + +#define PRIMARY_EVENT_QUEUE 0 +#define SECONDARY_EVENT_QUEUE 1 +#define DEMAND_EVENT_QUEUE 2 +#define EVENT_EXPIRED 0x00000002 + +std::queue hEventQueue; +std::vector hDelayEventQueue; +std::queue hDemandEventQueue; + // GLobals used here, for each event structure used, // Used as globals for stack reasons EV_E_PLAYSOUND EPlaySound; @@ -601,67 +626,172 @@ EV_S_GETNEWPATH SGetNewPath; EV_S_BEGINTURN SBeginTurn; EV_S_CHANGESTANCE SChangeStance; EV_S_SETDIRECTION SSetDirection; -EV_S_SETDESIREDDIRECTION SSetDesiredDirection; -EV_S_BEGINFIREWEAPON SBeginFireWeapon; +EV_S_SETDESIREDDIRECTION SSetDesiredDirection; +EV_S_BEGINFIREWEAPON SBeginFireWeapon; EV_S_FIREWEAPON SFireWeapon; EV_S_WEAPONHIT SWeaponHit; EV_S_STRUCTUREHIT SStructureHit; EV_S_WINDOWHIT SWindowHit; -EV_S_MISS SMiss; -EV_S_NOISE SNoise; +EV_S_MISS SMiss; +EV_S_NOISE SNoise; EV_S_STOP_MERC SStopMerc; -EV_S_SENDPATHTONETWORK SUpdateNetworkSoldier; +EV_S_SENDPATHTONETWORK SUpdateNetworkSoldier; extern BOOLEAN gfAmINetworked; -BOOLEAN AddGameEventToQueue( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT8 ubQueueID ); + BOOLEAN ExecuteGameEvent( EVENT *pEvent ); -BOOLEAN AddGameEvent( UINT32 uiEvent, UINT16 usDelay, PTR pEventData ) +BOOLEAN AddEvent(UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSize, UINT8 ubQueueID) { - if (usDelay == DEMAND_EVENT_DELAY) + BYTE* pData = (BYTE*)MemAlloc(uiDataSize); + Assert(pData); + memcpy(pData, pEventData, uiDataSize); + + // Add event to queue + switch (ubQueueID) { - //DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local and network #%d", uiEvent)); - #ifdef NETWORKED - if(gfAmINetworked) - SendEventToNetwork(uiEvent, usDelay, pEventData); - #endif - return( AddGameEventToQueue( uiEvent, 0, pEventData, DEMAND_EVENT_QUEUE ) ); + case PRIMARY_EVENT_QUEUE: + //hEventQueue.push(*pEvent); + hEventQueue.emplace( + EVENT{ + GetJA2Clock(), + 0, + usDelay, + uiEvent, + uiDataSize, + pData + } + ); + break; + + case SECONDARY_EVENT_QUEUE: + hDelayEventQueue.emplace_back( + EVENT{ + GetJA2Clock(), + 0, + usDelay, + uiEvent, + uiDataSize, + pData + } + ); + break; + + case DEMAND_EVENT_QUEUE: + hDemandEventQueue.emplace( + EVENT{ + GetJA2Clock(), + 0, + usDelay, + uiEvent, + uiDataSize, + pData + } + ); + break; + + default: + Assert(FALSE); + break; } - else if( uiEvent < EVENTS_LOCAL_AND_NETWORK) - { - //DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local and network #%d", uiEvent)); - #ifdef NETWORKED - if(gfAmINetworked) - SendEventToNetwork(uiEvent, usDelay, pEventData); - #endif - return( AddGameEventToQueue( uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE ) ); - } - else if( uiEvent < EVENTS_ONLY_USED_LOCALLY) - { - //DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local #%d", uiEvent)); - return( AddGameEventToQueue( uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE ) ); - } - else if( uiEvent < EVENTS_ONLY_SENT_OVER_NETWORK) - { - //DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending network #%d", uiEvent)); - #ifdef NETWORKED - if(gfAmINetworked) - SendEventToNetwork(uiEvent, usDelay, pEventData); - #endif - return(TRUE); - } - // There is an error with the event - else - return(FALSE); + + return(TRUE); } -BOOLEAN AddGameEventFromNetwork( UINT32 uiEvent, UINT16 usDelay, PTR pEventData ) + +static BOOLEAN RemoveEventFromSecondaryEventQueue(EVENT* ppEvent, UINT32 uiIndex) { - return( AddGameEventToQueue( uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE ) ); + if (uiIndex < hDelayEventQueue.size()) + { + *ppEvent = hDelayEventQueue[uiIndex]; + hDelayEventQueue.erase(hDelayEventQueue.begin() + uiIndex); + return(TRUE); + } + + return(FALSE); } + +BOOLEAN PopEvent(EVENT* ppEvent, UINT8 ubQueueID) +{ + // Get an event from queue, if one exists + // + switch (ubQueueID) + { + case PRIMARY_EVENT_QUEUE: + if (!hEventQueue.empty()) + { + *ppEvent = hEventQueue.front(); + hEventQueue.pop(); + return(TRUE); + } + break; + + case SECONDARY_EVENT_QUEUE: + if (!hDelayEventQueue.empty()) + { + *ppEvent = hDelayEventQueue.front(); + hDelayEventQueue.erase(hDelayEventQueue.begin()); + return(TRUE); + } + break; + + case DEMAND_EVENT_QUEUE: + if (!hDemandEventQueue.empty()) + { + *ppEvent = hDemandEventQueue.front(); + hDemandEventQueue.pop(); + return(TRUE); + } + break; + + default: + Assert(FALSE); + break; + } + + return(FALSE); +} + + +BOOLEAN FreeEvent(EVENT* pEvent) +{ + CHECKF(pEvent != NULL); + + // Delete event + MemFree(pEvent->pData); + //MemFree(pEvent); + + return(TRUE); +} + + +UINT32 EventQueueSize(UINT8 ubQueueID) +{ + switch (ubQueueID) + { + case PRIMARY_EVENT_QUEUE: + return(hEventQueue.size()); + break; + + case SECONDARY_EVENT_QUEUE: + return(hDelayEventQueue.size()); + break; + + case DEMAND_EVENT_QUEUE: + return(hDemandEventQueue.size()); + break; + + default: + Assert(FALSE); + return(-1); + break; + } +} + + BOOLEAN AddGameEventToQueue( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT8 ubQueueID ) { UINT32 uiDataSize; @@ -783,18 +913,65 @@ BOOLEAN AddGameEventToQueue( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UIN return( TRUE ); } + +BOOLEAN AddGameEvent(UINT32 uiEvent, UINT16 usDelay, PTR pEventData) +{ + if (usDelay == DEMAND_EVENT_DELAY) + { + //DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local and network #%d", uiEvent)); +#ifdef NETWORKED + if (gfAmINetworked) + SendEventToNetwork(uiEvent, usDelay, pEventData); +#endif + return(AddGameEventToQueue(uiEvent, 0, pEventData, DEMAND_EVENT_QUEUE)); + } + else if (uiEvent < EVENTS_LOCAL_AND_NETWORK) + { + //DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local and network #%d", uiEvent)); +#ifdef NETWORKED + if (gfAmINetworked) + SendEventToNetwork(uiEvent, usDelay, pEventData); +#endif + return(AddGameEventToQueue(uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE)); + } + else if (uiEvent < EVENTS_ONLY_USED_LOCALLY) + { + //DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending Local #%d", uiEvent)); + return(AddGameEventToQueue(uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE)); + } + else if (uiEvent < EVENTS_ONLY_SENT_OVER_NETWORK) + { + //DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("AddGameEvent: Sending network #%d", uiEvent)); +#ifdef NETWORKED + if (gfAmINetworked) + SendEventToNetwork(uiEvent, usDelay, pEventData); +#endif + return(TRUE); + } + // There is an error with the event + else + return(FALSE); +} + + +BOOLEAN AddGameEventFromNetwork(UINT32 uiEvent, UINT16 usDelay, PTR pEventData) +{ + return(AddGameEventToQueue(uiEvent, usDelay, pEventData, PRIMARY_EVENT_QUEUE)); +} + + BOOLEAN DequeAllGameEvents( BOOLEAN fExecute ) { - EVENT *pEvent; - UINT32 uiQueueSize, cnt; - BOOLEAN fCompleteLoop = FALSE; + EVENT pEvent; + UINT32 uiQueueSize, i; + BOOLEAN fCompleteLoop = FALSE; + + // First dequeue all primary events - - while( EventQueueSize( PRIMARY_EVENT_QUEUE ) > 0 ) { // Get Event - if ( RemoveEvent( &pEvent, 0, PRIMARY_EVENT_QUEUE) == FALSE ) + if (PopEvent( &pEvent, PRIMARY_EVENT_QUEUE) == FALSE ) { return( FALSE ); } @@ -802,90 +979,66 @@ BOOLEAN DequeAllGameEvents( BOOLEAN fExecute ) if ( fExecute ) { // Check if event has a delay and add to secondary queue if so - if ( pEvent->usDelay > 0 ) + if ( pEvent.usDelay > 0 ) { - AddGameEventToQueue( pEvent->uiEvent, pEvent->usDelay, pEvent->pData, SECONDARY_EVENT_QUEUE ); + AddGameEventToQueue( pEvent.uiEvent, pEvent.usDelay, pEvent.pData, SECONDARY_EVENT_QUEUE ); } else { - ExecuteGameEvent( pEvent ); + ExecuteGameEvent( &pEvent ); } } // Delete event - FreeEvent( pEvent ); - + FreeEvent( &pEvent ); }; - // NOW CHECK SECONDARY QUEUE FOR ANY EXPRIED EVENTS - // Get size of queue + + // NOW CHECK SECONDARY QUEUE FOR EVENTS uiQueueSize = EventQueueSize( SECONDARY_EVENT_QUEUE ); - for ( cnt = 0; cnt < uiQueueSize; cnt++ ) + for ( i = 0; i < uiQueueSize; i++ ) { - if ( PeekEvent( &pEvent, cnt, SECONDARY_EVENT_QUEUE) == FALSE ) - { - return( FALSE ); - } - + EVENT& pEventRef = hDelayEventQueue[i]; // Check time - if ( ( GetJA2Clock() - pEvent->TimeStamp ) > pEvent->usDelay ) + if ( ( GetJA2Clock() - pEventRef.TimeStamp ) > pEventRef.usDelay ) { if ( fExecute ) { - ExecuteGameEvent( pEvent ); + ExecuteGameEvent( &pEventRef ); } // FLag as expired - pEvent->uiFlags = EVENT_EXPIRED; - + pEventRef.uiFlags = EVENT_EXPIRED; } - } - do + // Remove expired events from secondary event queue + uiQueueSize = EventQueueSize(SECONDARY_EVENT_QUEUE); + for (INT32 i = uiQueueSize-1; i >= 0; i--) { - uiQueueSize = EventQueueSize( SECONDARY_EVENT_QUEUE ); - - for ( cnt = 0; cnt < uiQueueSize; cnt++ ) + EVENT& pEventRef = hDelayEventQueue[i]; + if (pEventRef.uiFlags & EVENT_EXPIRED) { - if ( PeekEvent( &pEvent, cnt, SECONDARY_EVENT_QUEUE) == FALSE ) - { - return( FALSE ); - } - - // Check time - if ( pEvent->uiFlags & EVENT_EXPIRED ) - { - RemoveEvent( &pEvent, cnt, SECONDARY_EVENT_QUEUE ); - FreeEvent( pEvent ); - // Restart loop - break; - - } - + RemoveEventFromSecondaryEventQueue(&pEventRef, i); + FreeEvent(&pEventRef); } - - if ( cnt == uiQueueSize ) - { - fCompleteLoop = TRUE; - } - - } while( fCompleteLoop == FALSE ); + } return( TRUE ); } + BOOLEAN DequeueAllDemandGameEvents( BOOLEAN fExecute ) { - EVENT *pEvent; + EVENT pEvent; // Dequeue all events on the demand queue (only) while( EventQueueSize( DEMAND_EVENT_QUEUE ) > 0 ) { // Get Event - if ( RemoveEvent( &pEvent, 0, DEMAND_EVENT_QUEUE) == FALSE ) + if ( PopEvent( &pEvent, DEMAND_EVENT_QUEUE) == FALSE ) { return( FALSE ); } @@ -893,18 +1046,18 @@ BOOLEAN DequeueAllDemandGameEvents( BOOLEAN fExecute ) if ( fExecute ) { // Check if event has a delay and add to secondary queue if so - if ( pEvent->usDelay > 0 ) + if ( pEvent.usDelay > 0 ) { - AddGameEventToQueue( pEvent->uiEvent, pEvent->usDelay, pEvent->pData, SECONDARY_EVENT_QUEUE ); + AddGameEventToQueue( pEvent.uiEvent, pEvent.usDelay, pEvent.pData, SECONDARY_EVENT_QUEUE ); } else { - ExecuteGameEvent( pEvent ); + ExecuteGameEvent( &pEvent ); } } // Delete event - FreeEvent( pEvent ); + FreeEvent( &pEvent ); }; @@ -912,7 +1065,6 @@ BOOLEAN DequeueAllDemandGameEvents( BOOLEAN fExecute ) } - BOOLEAN ExecuteGameEvent( EVENT *pEvent ) { SOLDIERTYPE *pSoldier; @@ -1237,17 +1389,16 @@ BOOLEAN ExecuteGameEvent( EVENT *pEvent ) BOOLEAN ClearEventQueue( void ) { // clear out the event queue - EVENT *pEvent; + EVENT pEvent; while( EventQueueSize( PRIMARY_EVENT_QUEUE ) > 0 ) { // Get Event - if ( RemoveEvent( &pEvent, 0, PRIMARY_EVENT_QUEUE) == FALSE ) + if (PopEvent( &pEvent, PRIMARY_EVENT_QUEUE) == FALSE ) { return( FALSE ); } + FreeEvent(&pEvent); } return( TRUE ); } - - diff --git a/Utils/Event Pump.h b/Utils/Event Pump.h index 536d0ab5..b171bca7 100644 --- a/Utils/Event Pump.h +++ b/Utils/Event Pump.h @@ -1,7 +1,6 @@ #ifndef EVENT_PROCESSOR_H #define EVENT_PROCESSOR_H -#include "Event Manager.h" #include "Overhead Types.h" @@ -271,8 +270,6 @@ BOOLEAN AddGameEventFromNetwork( UINT32 uiEvent, UINT16 usDelay, PTR pEventData BOOLEAN DequeAllGameEvents( BOOLEAN fExecute ); BOOLEAN DequeueAllDemandGameEvents( BOOLEAN fExecute ); -// clean out the evetn queue +// clean out the event queue BOOLEAN ClearEventQueue( void ); - - -#endif \ No newline at end of file +#endif From d6a3a27b58eb7cd7a00bbccc72db1065726f2172 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Tue, 10 Oct 2023 00:47:02 +0300 Subject: [PATCH 050/120] Address review feedback * Dialogue control.cpp * vsurface.cpp * Event pump.cpp --- Standard Gaming Platform/vsurface.cpp | 27 ++++----- Tactical/Dialogue Control.cpp | 20 +++---- Utils/Event Pump.cpp | 85 ++++++++++++--------------- 3 files changed, 57 insertions(+), 75 deletions(-) diff --git a/Standard Gaming Platform/vsurface.cpp b/Standard Gaming Platform/vsurface.cpp index bf103bbc..0df8bab7 100644 --- a/Standard Gaming Platform/vsurface.cpp +++ b/Standard Gaming Platform/vsurface.cpp @@ -1795,13 +1795,13 @@ BOOLEAN GetVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION { Assert( hVSurface != NULL ); - if (usIndex < hVSurface->RegionList.size()) + if (usIndex >= hVSurface->RegionList.size()) { - *aRegion = hVSurface->RegionList[usIndex]; - return( TRUE ); + return( FALSE ); } - return( FALSE ); + *aRegion = hVSurface->RegionList[usIndex]; + return( TRUE ); } BOOLEAN GetVSurfaceRect( HVSURFACE hVSurface, RECT *pRect) @@ -1823,13 +1823,13 @@ BOOLEAN ReplaceVSurfaceRegion( HVSURFACE hVSurface , UINT16 usIndex, VSURFACE_RE Assert( hVSurface != NULL ); - if (usIndex < hVSurface->RegionList.size()) + if (usIndex >= hVSurface->RegionList.size()) { - hVSurface->RegionList[usIndex] = *aRegion; - return( TRUE ); + return( FALSE ); } - return( FALSE ); + hVSurface->RegionList[usIndex] = *aRegion; + return( TRUE ); } BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *pNewRegion ) @@ -1837,15 +1837,14 @@ BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_ Assert( hVSurface != NULL ); Assert( pNewRegion != NULL ); - // Add new region to list - if (usIndex < hVSurface->RegionList.size()) + if (usIndex >= hVSurface->RegionList.size()) { - auto pos = hVSurface->RegionList.begin() + usIndex; - hVSurface->RegionList.insert(pos, *pNewRegion); - return(TRUE); + return(FALSE); } - return(FALSE); + auto pos = hVSurface->RegionList.begin() + usIndex; + hVSurface->RegionList.insert(pos, *pNewRegion); + return(TRUE); } // ******************************************************************* diff --git a/Tactical/Dialogue Control.cpp b/Tactical/Dialogue Control.cpp index b8d9a9a7..cb646341 100644 --- a/Tactical/Dialogue Control.cpp +++ b/Tactical/Dialogue Control.cpp @@ -361,7 +361,7 @@ void EmptyDialogueQueue( ) } -inline BOOLEAN DialogueQueueIsEmpty( ) +BOOLEAN DialogueQueueIsEmpty( ) { return( ghDialogueQ.empty() ); } @@ -1798,8 +1798,7 @@ void AdditionalTacticalCharacterDialogue_AllInSectorRadiusCall( UINT8 ausIgnoreP BOOLEAN CharacterDialogueWithSpecialEvent( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 iFaceIndex, UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed, UINT32 uiFlag, UINT32 uiData1, UINT32 uiData2 ) { - DIALOGUE_Q_STRUCT QItem; - memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + DIALOGUE_Q_STRUCT QItem{}; QItem.ubCharacterNum = ubCharacterNum; QItem.usQuoteNum = usQuoteNum; QItem.iFaceIndex = iFaceIndex; @@ -1833,8 +1832,7 @@ BOOLEAN CharacterDialogueWithSpecialEvent( UINT8 ubCharacterNum, UINT16 usQuoteN BOOLEAN CharacterDialogueWithSpecialEventEx( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 iFaceIndex, UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed, UINT32 uiFlag, UINT32 uiData1, UINT32 uiData2, UINT32 uiData3 ) { - DIALOGUE_Q_STRUCT QItem; - memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + DIALOGUE_Q_STRUCT QItem{}; QItem.ubCharacterNum = ubCharacterNum; QItem.usQuoteNum = usQuoteNum; QItem.iFaceIndex = iFaceIndex; @@ -1863,8 +1861,7 @@ BOOLEAN CharacterDialogueWithSpecialEventEx( UINT8 ubCharacterNum, UINT16 usQuot BOOLEAN CharacterDialogue( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 iFaceIndex, UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed ) { - DIALOGUE_Q_STRUCT QItem; - memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + DIALOGUE_Q_STRUCT QItem{}; QItem.ubCharacterNum = ubCharacterNum; QItem.usQuoteNum = usQuoteNum; QItem.iFaceIndex = iFaceIndex; @@ -1914,8 +1911,7 @@ BOOLEAN SnitchCharacterDialogue( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 UINT32 uiSpecialEventData3, UINT32 uiSpecialEventData4, UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed ) { - DIALOGUE_Q_STRUCT QItem; - memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + DIALOGUE_Q_STRUCT QItem{}; QItem.ubCharacterNum = ubCharacterNum; QItem.usQuoteNum = usQuoteNum; QItem.uiSpecialEventFlag = uiSpecialEventFlag; @@ -1946,8 +1942,7 @@ BOOLEAN SnitchCharacterDialogue( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 BOOLEAN SpecialCharacterDialogueEvent( UINT32 uiSpecialEventFlag, UINT32 uiSpecialEventData1, UINT32 uiSpecialEventData2, UINT32 uiSpecialEventData3, INT32 iFaceIndex, UINT8 bUIHandlerID ) { - DIALOGUE_Q_STRUCT QItem; - memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + DIALOGUE_Q_STRUCT QItem{}; QItem.uiSpecialEventFlag = uiSpecialEventFlag; QItem.uiSpecialEventData = uiSpecialEventData1; QItem.uiSpecialEventData2 = uiSpecialEventData2; @@ -1972,8 +1967,7 @@ BOOLEAN SpecialCharacterDialogueEvent( UINT32 uiSpecialEventFlag, UINT32 uiSpeci BOOLEAN SpecialCharacterDialogueEventWithExtraParam( UINT32 uiSpecialEventFlag, UINT32 uiSpecialEventData1, UINT32 uiSpecialEventData2, UINT32 uiSpecialEventData3, UINT32 uiSpecialEventData4, INT32 iFaceIndex, UINT8 bUIHandlerID ) { - DIALOGUE_Q_STRUCT QItem; - memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT)); + DIALOGUE_Q_STRUCT QItem{}; QItem.uiSpecialEventFlag = uiSpecialEventFlag; QItem.uiSpecialEventData = uiSpecialEventData1; QItem.uiSpecialEventData2 = uiSpecialEventData2; diff --git a/Utils/Event Pump.cpp b/Utils/Event Pump.cpp index 4c5f2a70..c0567777 100644 --- a/Utils/Event Pump.cpp +++ b/Utils/Event Pump.cpp @@ -11,8 +11,8 @@ #include "Animation Control.h" #include "opplist.h" #include "Tactical Save.h" -#include -#include +#include +#include #ifdef NETWORKED #include "Networking.h" @@ -595,7 +595,7 @@ UINT8 gubEncryptionArray4[ BASE_NUMBER_OF_ROTATION_ARRAYS * 3 ][ NEW_ROTATION_AR }, }; -typedef struct +struct EVENT { TIMER TimeStamp; UINT32 uiFlags; @@ -604,7 +604,25 @@ typedef struct UINT32 uiDataSize; BYTE* pData; -} EVENT; + EVENT(UINT16 delay, UINT32 event, UINT32 dataSize, BYTE* eventData) : + TimeStamp(GetJA2Clock()), + uiFlags(0), + usDelay(delay), + uiEvent(event), + uiDataSize(dataSize), + pData{ eventData } + { + } + + EVENT() : + TimeStamp(GetJA2Clock()), + uiFlags(0), + usDelay(0), + uiEvent(0), + uiDataSize(0), + pData{ nullptr } + {} +}; #define PRIMARY_EVENT_QUEUE 0 #define SECONDARY_EVENT_QUEUE 1 @@ -653,43 +671,15 @@ BOOLEAN AddEvent(UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSi switch (ubQueueID) { case PRIMARY_EVENT_QUEUE: - //hEventQueue.push(*pEvent); - hEventQueue.emplace( - EVENT{ - GetJA2Clock(), - 0, - usDelay, - uiEvent, - uiDataSize, - pData - } - ); + hEventQueue.emplace(usDelay, uiEvent, uiDataSize, pData); break; case SECONDARY_EVENT_QUEUE: - hDelayEventQueue.emplace_back( - EVENT{ - GetJA2Clock(), - 0, - usDelay, - uiEvent, - uiDataSize, - pData - } - ); + hDelayEventQueue.emplace_back(usDelay, uiEvent, uiDataSize, pData); break; case DEMAND_EVENT_QUEUE: - hDemandEventQueue.emplace( - EVENT{ - GetJA2Clock(), - 0, - usDelay, - uiEvent, - uiDataSize, - pData - } - ); + hDemandEventQueue.emplace(usDelay, uiEvent, uiDataSize, pData); break; default: @@ -703,18 +693,18 @@ BOOLEAN AddEvent(UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSi static BOOLEAN RemoveEventFromSecondaryEventQueue(EVENT* ppEvent, UINT32 uiIndex) { - if (uiIndex < hDelayEventQueue.size()) + if (uiIndex >= hDelayEventQueue.size()) { - *ppEvent = hDelayEventQueue[uiIndex]; - hDelayEventQueue.erase(hDelayEventQueue.begin() + uiIndex); - return(TRUE); + return(FALSE); } - return(FALSE); + *ppEvent = hDelayEventQueue[uiIndex]; + hDelayEventQueue.erase(hDelayEventQueue.begin() + uiIndex); + return(TRUE); } -BOOLEAN PopEvent(EVENT* ppEvent, UINT8 ubQueueID) +static BOOLEAN PopEvent(EVENT* ppEvent, UINT8 ubQueueID) { // Get an event from queue, if one exists // @@ -756,11 +746,10 @@ BOOLEAN PopEvent(EVENT* ppEvent, UINT8 ubQueueID) } -BOOLEAN FreeEvent(EVENT* pEvent) +static BOOLEAN FreeEventData(EVENT* pEvent) { CHECKF(pEvent != NULL); - // Delete event MemFree(pEvent->pData); //MemFree(pEvent); @@ -792,7 +781,7 @@ UINT32 EventQueueSize(UINT8 ubQueueID) } -BOOLEAN AddGameEventToQueue( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT8 ubQueueID ) +static BOOLEAN AddGameEventToQueue( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT8 ubQueueID ) { UINT32 uiDataSize; @@ -990,7 +979,7 @@ BOOLEAN DequeAllGameEvents( BOOLEAN fExecute ) } // Delete event - FreeEvent( &pEvent ); + FreeEventData( &pEvent ); }; @@ -1021,7 +1010,7 @@ BOOLEAN DequeAllGameEvents( BOOLEAN fExecute ) if (pEventRef.uiFlags & EVENT_EXPIRED) { RemoveEventFromSecondaryEventQueue(&pEventRef, i); - FreeEvent(&pEventRef); + FreeEventData(&pEventRef); } } @@ -1057,7 +1046,7 @@ BOOLEAN DequeueAllDemandGameEvents( BOOLEAN fExecute ) } // Delete event - FreeEvent( &pEvent ); + FreeEventData( &pEvent ); }; @@ -1397,7 +1386,7 @@ BOOLEAN ClearEventQueue( void ) { return( FALSE ); } - FreeEvent(&pEvent); + FreeEventData(&pEvent); } return( TRUE ); From 5ec08231a34505a895dd98935fa329e5af4985a0 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Tue, 10 Oct 2023 23:37:11 +0300 Subject: [PATCH 051/120] Match new with delete (#238) Only applicable if we actually fail to create a vsurface --- Standard Gaming Platform/vsurface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Standard Gaming Platform/vsurface.cpp b/Standard Gaming Platform/vsurface.cpp index 0df8bab7..905cf893 100644 --- a/Standard Gaming Platform/vsurface.cpp +++ b/Standard Gaming Platform/vsurface.cpp @@ -1190,7 +1190,7 @@ HVSURFACE CreateVideoSurface( VSURFACE_DESC *VSurfaceDesc ) DbgMessage( TOPIC_VIDEOSURFACE, DBG_LEVEL_2, String( "Failed to create Video Surface in video memory" ) ); DDReleaseSurface ( &lpDDS, &lpDDS2 ); - MemFree( hVSurface ); + delete hVSurface; return( NULL ); } From e6f1f40aea94707a08bfc7d5f724d6e9681b0bb2 Mon Sep 17 00:00:00 2001 From: zwwooooo Date: Sun, 15 Oct 2023 22:05:59 +0800 Subject: [PATCH 052/120] Fixed "14POINTARIAL" font height for Chinese Version. --- Standard Gaming Platform/WinFont.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Standard Gaming Platform/WinFont.cpp b/Standard Gaming Platform/WinFont.cpp index 223e634f..bd046f7c 100644 --- a/Standard Gaming Platform/WinFont.cpp +++ b/Standard Gaming Platform/WinFont.cpp @@ -505,7 +505,7 @@ INT16 GetWinFontHeight(INT32 iFont) if (pWinFont == NULL) return(0); #ifdef CHINESE //zwwooooo: Correct tactical interface font height to fixed Chinese characters smearing bug - if (iFont == WinFontMap[TINYFONT1] || iFont == WinFontMap[SMALLFONT1] || iFont == WinFontMap[WIN_14POINTARIAL]) + if (iFont == WinFontMap[TINYFONT1] || iFont == WinFontMap[SMALLFONT1] || iFont == WinFontMap[FONT14ARIAL]) { return pWinFont->Height + 2; } From a47ed9ed55d1286f338d8db6d6914cde815b2990 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Thu, 19 Oct 2023 19:08:39 +0300 Subject: [PATCH 053/120] Correct for loop end condition (#241) --- Tactical/World Items.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tactical/World Items.cpp b/Tactical/World Items.cpp index dd544fb4..341c79bd 100644 --- a/Tactical/World Items.cpp +++ b/Tactical/World Items.cpp @@ -136,7 +136,7 @@ void PruneWorldItems(void) for (size_t i = 0; i < gAllWorldItems.Items.size(); i++) { std::vector& items = gAllWorldItems.Items[i]; - for (INT32 j = items.size()-1; j > 0; j--) + for (INT32 j = items.size()-1; j >= 0; j--) { if (items[j].fExists == false) { From 8f454e2aab8b45e7dc845c15e39a530df5d5f0b1 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Fri, 20 Oct 2023 21:30:39 +0300 Subject: [PATCH 054/120] Container.cpp & .h delete (#242) * Remove GetFilesInDirectory() * Remove BuildFileDirectory * Remove container.cpp & .h Not used in the code --- Ja25Update.cpp | 1 - Standard Gaming Platform/CMakeLists.txt | 1 - Standard Gaming Platform/Container.cpp | 2104 ----------------------- Standard Gaming Platform/Container.h | 132 -- Standard Gaming Platform/FileMan.cpp | 166 -- Standard Gaming Platform/FileMan.h | 4 - Standard Gaming Platform/sgp.cpp | 4 - Standard Gaming Platform/vobject.h | 1 - Standard Gaming Platform/vsurface.h | 1 - Tactical/Faces.cpp | 1 - Tactical/PATHAI.cpp | 1 - Tactical/Soldier Control.cpp | 1 - Tactical/Soldier Tile.cpp | 1 - Tactical/bullets.cpp | 1 - Utils/Event Pump.cpp | 1 - Utils/Utils All.h | 3 +- aniviewscreen.cpp | 1 - 17 files changed, 1 insertion(+), 2423 deletions(-) delete mode 100644 Standard Gaming Platform/Container.cpp delete mode 100644 Standard Gaming Platform/Container.h diff --git a/Ja25Update.cpp b/Ja25Update.cpp index 101b1152..4fd737e1 100644 --- a/Ja25Update.cpp +++ b/Ja25Update.cpp @@ -11,7 +11,6 @@ #include "Animation Cache.h" #include "Animation Data.h" #include "Animation Control.h" -#include "container.h" #include #include "pathai.h" #include "Random.h" diff --git a/Standard Gaming Platform/CMakeLists.txt b/Standard Gaming Platform/CMakeLists.txt index e804d037..70404804 100644 --- a/Standard Gaming Platform/CMakeLists.txt +++ b/Standard Gaming Platform/CMakeLists.txt @@ -2,7 +2,6 @@ set(SGPSrc "${CMAKE_CURRENT_SOURCE_DIR}/Button Sound Control.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Button System.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Compression.cpp" -"${CMAKE_CURRENT_SOURCE_DIR}/Container.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Cursor Control.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/DEBUG.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/debug_util.cpp" diff --git a/Standard Gaming Platform/Container.cpp b/Standard Gaming Platform/Container.cpp deleted file mode 100644 index ad140dd5..00000000 --- a/Standard Gaming Platform/Container.cpp +++ /dev/null @@ -1,2104 +0,0 @@ -//***************************************************************************** -// -// Filename : Container.c -// -// Purpose : Function definition for the Container -// -// Modification History : -// 25 nov 96 TS creation -// -// 19 Dec 97 AM Replace all memcpy() with memmove(), since overlap possibilities -// abound (and there were already bugs in do_copy() for ordered lists) -// While the memcpy() was working in _DEBUG mode, it was failing -// reproducibly in RELEASE mode whenever regions overlapped! -// Having read the code, I strongly suggest that you DO NOT use this -// stuff at all and write your own instead. Tarun was no Carmack... -// - Alex Meduna -// 1998 KM Detached all references to this file from JA2 as it caused a lot of hard to debug -// crashes. The VOBJECT/VSURFACE lists are now self-maintained and no longer use the -// this crap. DON'T USE THIS -- NO MATTER WHAT!!! -//***************************************************************************** - - #include "types.h" - #include - #include - #include - #include "windows.h" - #include "MemMan.h" - #include "Debug.h" - #include "Container.h" - #if _MSC_VER < 1300 //(iostream.h was removed from VC.NET2003) - #include - #endif - - -//***************************************************************************** -// -// Defines and typedefs -// -// -//***************************************************************************** - -typedef struct StackHeaderTag -{ - UINT32 uiTotal_items; - UINT32 uiSiz_of_elem; - UINT32 uiMax_size; - -} StackHeader; - -typedef struct HeaderTag -{ - UINT32 uiTotal_items; - UINT32 uiSiz_of_elem; - UINT32 uiMax_size; - UINT32 uiHead; - UINT32 uiTail; - -} QueueHeader , ListHeader; - -typedef struct OrdHeaderTag -{ - UINT32 uiTotal_items; - UINT32 uiSiz_of_elem; - UINT32 uiMax_size; - UINT32 uiHead; - UINT32 uiTail; - INT8 (*pCompare)(void *,void *, UINT32); - -} OrdListHeader; - - typedef struct test - { - UINT32 me; - long you; - STR8 k; - STR8 p; - - } TEST; - -//***************************************************************************** -// -// CreateStack -// -// Parameter List : num_items - estimated number -// of items in stack -// siz_each - size of each item -// Return Value NULL if unsuccesful -// pointer to allocated memory -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** - -HSTACK CreateStack(UINT32 uiNum_items, UINT32 uiSiz_each) -{ - UINT32 uiAmount; - HSTACK hStack; - StackHeader *pStack; - - // assign an initial amount of memory to allocate - if ((uiNum_items > 0) && (uiSiz_each > 0)) - uiAmount = uiNum_items * uiSiz_each; - else - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Requested stack items and size have to be >0"); - return NULL; - } - // allocate the container memory - if ((hStack = MemAlloc(uiAmount + sizeof(StackHeader))) == 0) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Could not allocate stack container memory"); - return NULL; - } - pStack = (StackHeader *)hStack; - //initialize the header variables - pStack->uiMax_size = uiAmount + sizeof(StackHeader); - pStack->uiTotal_items = 0; - pStack->uiSiz_of_elem = uiSiz_each; - - // return the pointer to the memory - - return hStack; -} - -//***************************************************************************** -// -// CreateQueue -// -// Parameter List : num_items - estimated number -// of items in queue -// siz_each - size of each item -// Return Value NULL if unsuccesful -// pointer to allocated memory -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HQUEUE CreateQueue(UINT32 uiNum_items, UINT32 uiSiz_each) -{ - UINT32 uiAmount; - HQUEUE hQueue; - QueueHeader *pQueue; - - // check to see if the queue has more than 1 - // element to be created and that the size > 1 - - if ((uiNum_items > 0) && (uiSiz_each > 0)) - uiAmount = uiNum_items * uiSiz_each; - else - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Requested queue items and size have to be >0"); - return NULL; - } - - // allocate the queue memory - if ((hQueue = MemAlloc(uiAmount + sizeof(QueueHeader))) == 0) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Could not allocate queue container memory"); - return NULL; - } - - pQueue = (QueueHeader *)hQueue; - //initialize the queue structure - - pQueue->uiMax_size = uiAmount + sizeof(QueueHeader); - pQueue->uiTotal_items = 0; - pQueue->uiSiz_of_elem = uiSiz_each; - pQueue->uiTail = pQueue->uiHead = sizeof(QueueHeader); - - // return the pointer to memory - return hQueue; -} -//***************************************************************************** -// -// CreateList -// -// Parameter List : num_items - estimated number -// of items in ordered list -// siz_each - size of each item -// Return Value NULL if unsuccesful -// pointer to allocated memory -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HLIST CreateList(UINT32 uiNum_items, UINT32 uiSiz_each) -{ - UINT32 uiAmount; - HLIST hList; - ListHeader *pList; - - // check to see if the queue has more than 1 - // element to be created and that the size > 1 - - if ((uiNum_items > 0) && (uiSiz_each > 0)) - uiAmount = uiNum_items * uiSiz_each; - else - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Requested queue items and size have to be >0"); - return 0; - } - - // allocate the list memory - if ((hList = MemAlloc(uiAmount + sizeof(ListHeader))) == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not allocate queue container memory"); - return 0; - } - - pList = (ListHeader *)hList; - //initialize the list structure - - pList->uiMax_size = uiAmount + sizeof(ListHeader); - pList->uiTotal_items = 0; - pList->uiSiz_of_elem = uiSiz_each; - pList->uiTail = pList->uiHead = sizeof(ListHeader); - - // return the pointer to memory - - return hList; - -} - - - -//***************************************************************************** -// -// CreateOrdList -// -// Parameter List : num_items - estimated number -// of items in ordered list -// siz_each - size of each item -// Return Value NULL if unsuccesful -// pointer to allocated memory -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HORDLIST CreateOrdList(UINT32 uiNum_items, UINT32 uiSiz_each, INT8 (*compare)(void *, void *, UINT32)) -{ - UINT32 uiAmount; - HLIST hOrdList; - OrdListHeader *pOrdList; - - // check to see if the ordered list has more than 1 - // element to be created and that the size > 1 - - if ((uiNum_items > 0) && (uiSiz_each > 0)) - uiAmount = uiNum_items * uiSiz_each; - else - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Requested ordered list items and size have to be >0"); - return 0; - } - - // allocate the list memory - if ((hOrdList = MemAlloc(uiAmount + sizeof(OrdListHeader))) == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not allocate queue container memory"); - return 0; - } - - pOrdList = (OrdListHeader *)hOrdList; - //initialize the list structure - - pOrdList->uiMax_size = uiAmount + sizeof(OrdListHeader); - pOrdList->uiTotal_items = 0; - pOrdList->uiSiz_of_elem = uiSiz_each; - pOrdList->uiTail = pOrdList->uiHead = sizeof(OrdListHeader); - pOrdList->pCompare = compare; - - // return the pointer to memory - - return hOrdList; -} - - - -//***************************************************************************** -// -// push -// -// Parameter List : void * - pointer to stack -// container -// data - data to add to stack -// -// Return Value BOOLEAN true if push ok -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HSTACK Push(HSTACK hStack, void *pdata) -{ - StackHeader *pTemp_cont; - UINT32 uiOffset; - UINT32 uiNew_size; - void *pvoid; - BYTE *pbyte; - - // check for a NULL pointer - - if (hStack == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the stack"); - return NULL; - } - - // some valid data should be passed in - if (pdata == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto stack is NULL"); - return NULL; - } - - //perform operations to calculate offset and decide if the container has to resized - pTemp_cont = (StackHeader *)hStack; - uiOffset = (pTemp_cont->uiSiz_of_elem * pTemp_cont->uiTotal_items) + sizeof(StackHeader); - - if ((uiOffset + pTemp_cont->uiSiz_of_elem) > pTemp_cont->uiMax_size) - { - uiNew_size = pTemp_cont->uiMax_size + (pTemp_cont->uiMax_size - sizeof(StackHeader)); - pTemp_cont->uiMax_size = uiNew_size; - if ((hStack = MemRealloc(hStack, uiNew_size)) == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Could not resize stack container memory"); - return NULL; - } - pTemp_cont = (StackHeader *)hStack; - } - pbyte = (BYTE *)hStack; - pbyte += uiOffset; - pvoid = (void *)pbyte; - //copy data from pdata to pvoid - the stack - memmove(pvoid, pdata, pTemp_cont->uiSiz_of_elem); - pTemp_cont->uiTotal_items++; - //return push succeeded - return hStack; -} -//***************************************************************************** -// -// pop -// -// Parameter List : void * - pointer to stack -// container -// -// -// Return Value : void * - pointer to stack -// after pushing element -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN Pop(HSTACK hStack, void *pdata) -{ - StackHeader *pTemp_cont; - UINT32 uiOffset; - UINT32 uiSize_of_each; - UINT32 uiTotal; - void *pvoid; - BYTE *pbyte; - - // check for a NULL queue - - if (hStack == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the stack"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Variable where data is to be stored is NULL"); - return FALSE; - } - pTemp_cont = (StackHeader *)hStack; - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - if (uiTotal == 0) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "There is no data in stack to pop"); - return FALSE; - } - - // calculate offsets to decide if the page should be rezied - uiOffset = (uiSize_of_each * uiTotal) + sizeof(StackHeader); - uiOffset -= uiSize_of_each; - pbyte = (BYTE *)hStack; - pbyte += uiOffset; - pvoid = (void *)pbyte; - // get the data from pvoid and store in pdata - memmove(pdata, pvoid, uiSize_of_each); - pTemp_cont->uiTotal_items--; - return TRUE; -} -//***************************************************************************** -// -// PeekStack -// -// Parameter List : void * - buffer to hold data -// -// -// Return Value : TRUE if stack not empty -// -// Modification History : -// Apr 14 2000 SCT->Created -// -//***************************************************************************** -BOOLEAN PeekStack(HSTACK hStack, void *pdata) -{ - StackHeader *pTemp_cont; - UINT32 uiOffset; - UINT32 uiSize_of_each; - UINT32 uiTotal; - void *pvoid; - BYTE *pbyte; - - // check for a NULL queue - - if (hStack == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the stack"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "Variable where data is to be stored is NULL"); - return FALSE; - } - pTemp_cont = (StackHeader *)hStack; - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - if (uiTotal == 0) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "There is no data in stack to pop"); - return FALSE; - } - - // calculate offsets to decide if the page should be rezied - uiOffset = (uiSize_of_each * uiTotal) + sizeof(StackHeader); - uiOffset -= uiSize_of_each; - pbyte = (BYTE *)hStack; - pbyte += uiOffset; - pvoid = (void *)pbyte; - // get the data from pvoid and store in pdata - memmove(pdata, pvoid, uiSize_of_each); - return TRUE; -} -//***************************************************************************** -// -// DeleteStack -// -// Parameter List : pointer to memory -// -// Return Value : BOOLEAN -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN DeleteStack(HSTACK hStack) -{ - if (hStack == NULL) - { - DbgMessage(TOPIC_STACK_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the stack"); - return FALSE; - } - // free the memory assigned to the handle - MemFree(hStack); - return TRUE; -} -//***************************************************************************** -// -// DeleteQueue -// -// Parameter List : pointer to memory -// -// Return Value : BOOLEAN -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN DeleteQueue(HQUEUE hQueue) -{ - if (hQueue == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the queue"); - return FALSE; - } - // free the memory assigned to the handle - MemFree(hQueue); - return TRUE; -} -//***************************************************************************** -// -// DeleteList -// -// Parameter List : pointer to memory -// -// Return Value : BOOLEAN -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN DeleteList(HLIST hList) -{ - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the list"); - return FALSE; - } - // free the memory assigned to the list - MemFree(hList); - return TRUE; -} -//***************************************************************************** -// -// DeleteOrdList -// -// Parameter List : pointer to memory -// -// Return Value : BOOLEAN -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN DeleteOrdList(HORDLIST hOrdList) -{ - if (hOrdList == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the ordered list"); - return FALSE; - } - // free the memory assigned to the list - MemFree(hOrdList); - return TRUE; -} -//***************************************************************************** -// -// InitializeContainers -// -// Parameter List : none -// -// Return Value : void -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** - -void InitializeContainers(void) -{ - // register the appropriate debug topics - RegisterDebugTopic(TOPIC_STACK_CONTAINERS, "Stack Container"); - RegisterDebugTopic(TOPIC_LIST_CONTAINERS, "List Container"); - RegisterDebugTopic(TOPIC_QUEUE_CONTAINERS, "Queue Container"); - RegisterDebugTopic(TOPIC_ORDLIST_CONTAINERS, "Ordered List Container"); -} - -//***************************************************************************** -// -// ShutdownContainers -// -// Parameter List : none -// -// Return Value : void -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** - -void ShutdownContainers( void ) -{ - UnRegisterDebugTopic(TOPIC_STACK_CONTAINERS, "Stack Container"); - UnRegisterDebugTopic(TOPIC_LIST_CONTAINERS, "List Container"); - UnRegisterDebugTopic(TOPIC_QUEUE_CONTAINERS, "Queue Container"); - UnRegisterDebugTopic(TOPIC_ORDLIST_CONTAINERS, "Ordered List Container"); -} -//***************************************************************************** -// -// PeekQueue - gets the first item in queue without -// actually deleting it. -// -// Parameter List : pvoid_queue - pointer to queue -// container -// data - data removed from queue -// -// Return Value pointer to queue with data removed -// or NULL if failed -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN PeekQueue(HQUEUE hQueue, void *pdata) -{ - QueueHeader *pTemp_cont; - void *pvoid; - BYTE *pbyte; - - // cannot check for invalid handle , only 0 - if (hQueue == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the queue"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Memory fo Data to be removed from queue is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (QueueHeader *)hQueue; - - // if theres no elements to remove return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "There is nothing in the queue"); - return FALSE; - } - - //copy the element pointed to by uiHead - - pbyte = (BYTE *)hQueue; - pbyte += pTemp_cont->uiHead; - pvoid = (void *)pbyte; - memmove(pdata, pvoid, pTemp_cont->uiSiz_of_elem); - - return TRUE; -} -//***************************************************************************** -// -// PeekList - gets the specified item in the list without -// actually deleting it. -// -// Parameter List : hList - pointer to list -// container -// data - data where list element is stored -// -// Return Value BOOLEAN -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN PeekList(HLIST hList, void *pdata, UINT32 uiPos) -{ - ListHeader *pTemp_cont; - void *pvoid; - UINT32 uiOffsetSrc; - BYTE *pbyte; - - // cannot check for invalid handle , only 0 - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the list"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Memory fo Data to be removed from list is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (ListHeader *)hList; - - // if theres no elements to peek return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "There is nothing in the list"); - return FALSE; - } - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "There is no item at this position"); - return FALSE; - } - - //copy the element pointed to by uiHead - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - if (uiOffsetSrc >= pTemp_cont->uiMax_size) - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - pTemp_cont->uiMax_size); - - pbyte = (BYTE *)hList; - pbyte += uiOffsetSrc; - pvoid = (void *)pbyte; - memmove(pdata, pvoid, pTemp_cont->uiSiz_of_elem); - - return TRUE; -} - - -//***************************************************************************** -// -// SwapListNode - Swaps the contents of a list node with the given parameter. -// Note: The data being swapped in MUST have the same size as -// the current node size or strange things could happen. -// Contents of node and pdata parameter are swapped. -// -// Parameter List : hList - pointer to list container -// pdata - pointer to data to be swapped -// uiPos - List position with which to swap. -// -// Return Value BOOLEAN - TRUE if successful, FALSE if function fails. -// -// -// Modification History : -// Added to SGP by Bret Rowdon for use with JA2. May 1 '97. -// - This function was based on the PeekList function. -// -//***************************************************************************** -BOOLEAN SwapListNode(HLIST hList, void *pdata, UINT32 uiPos) -{ - ListHeader *pTemp_cont; - BYTE *pvoid; - UINT32 uiOffsetSrc; - BYTE *pbyte; - BYTE *pSrc; - - - // cannot check for invalid handle, only 0 - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid pointer to list"); - return FALSE; - } - - if (pdata == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data pointer to be swapped from list is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (ListHeader *)hList; - - // if theres no elements to peek return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Empty list"); - return FALSE; - } - - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid list position"); - return FALSE; - } - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - if (uiOffsetSrc >= pTemp_cont->uiMax_size) - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - pTemp_cont->uiMax_size); - - pbyte = (BYTE *)hList; - pbyte += uiOffsetSrc; - pvoid = pbyte; - pSrc = (BYTE *) pdata; - - // possible overlap, use memmove() - memmove(pvoid, pdata, pTemp_cont->uiSiz_of_elem); - //memmove(pvoid, pdata, pTemp_cont->uiSiz_of_elem); - - return TRUE; -} - - - -//***************************************************************************** -// -// StoreListNode - Stores the contents of a list node with the given parameter. -// Unlike SwapListNode(), this does NOT swap previous contents -// back into the pdata buffer! -// -// Parameter List : hList - pointer to list container -// pdata - pointer to data to be stored -// uiPos - List position into which to store. -// -// Return Value BOOLEAN - TRUE if successful, FALSE if function fails. -// -// -// Modification History : -// Added to SGP by Alex Meduna for use with Wiz8. Oct 31 '97. -// - This function is nearly identical to the SwapListNode() function. -// -//***************************************************************************** -BOOLEAN StoreListNode(HLIST hList, void *pdata, UINT32 uiPos) -{ - ListHeader *pTemp_cont; - UINT32 uiOffsetSrc; - BYTE *pbyte; - - // cannot check for invalid handle , only 0 - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid pointer to list"); - return FALSE; - } - - if (pdata == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data pointer to be swapped from list is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (ListHeader *)hList; - - // if theres no elements to peek return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Empty list"); - return FALSE; - } - - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid list position"); - return FALSE; - } - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - if (uiOffsetSrc >= pTemp_cont->uiMax_size) - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - pTemp_cont->uiMax_size); - - pbyte = (BYTE *)hList; - pbyte += uiOffsetSrc; - - memmove(pbyte, pdata, pTemp_cont->uiSiz_of_elem); - - return TRUE; -} - - - -//***************************************************************************** -// -// PeekOrdList - gets the specified item in the list without -// actually deleting it. -// -// Parameter List : hList - pointer to ordered list -// container -// data - data where list element is stored -// -// Return Value BOOLEAN -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN PeekOrdList(HORDLIST hOrdList, void *pdata, UINT32 uiPos) -{ - OrdListHeader *pTemp_cont; - void *pvoid; - UINT32 uiOffsetSrc; - BYTE *pbyte; - - // cannot check for invalid handle , only 0 - if (hOrdList == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the ordered list"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Memory fo Data to be removed from ordered list is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (OrdListHeader *)hOrdList; - - // if theres no elements to peek return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "There is nothing in the list"); - return FALSE; - } - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "There is no item at this position"); - return FALSE; - } - - //copy the element pointed to by uiHead - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - if (uiOffsetSrc >= pTemp_cont->uiMax_size) - uiOffsetSrc = sizeof(OrdListHeader) + (uiOffsetSrc - pTemp_cont->uiMax_size); - - pbyte = (BYTE *)hOrdList; - pbyte += uiOffsetSrc; - pvoid = (void *)pbyte; - memmove(pdata, pvoid, pTemp_cont->uiSiz_of_elem); - - return TRUE; -} -//***************************************************************************** -// -// RemfromQueue -// -// Parameter List : pvoid_queue - pointer to queue -// container -// data - data removed from queue -// -// Return Value pointer to queue with data removed -// or NULL if failed -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN RemfromQueue(HQUEUE hQueue, void *pdata) -{ - QueueHeader *pTemp_cont; - void *pvoid; - BYTE *pbyte; - - // cannot check for invalid handle , only 0 - if (hQueue == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the queue"); - return FALSE; - } - if (pdata == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Memory fo Data to be removed from queue is NULL"); - return FALSE; - } - - //assign to temporary variables - pTemp_cont = (QueueHeader *)hQueue; - - // if theres no elements to remove return error - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "There is nothing in the queue to remove"); - return FALSE; - } - - //remove the element pointed to by uiHead - - pbyte = (BYTE *)hQueue; - pbyte += pTemp_cont->uiHead; - pvoid = (void *)pbyte; - memmove(pdata, pvoid, pTemp_cont->uiSiz_of_elem); - pTemp_cont->uiTotal_items--; - pTemp_cont->uiHead += pTemp_cont->uiSiz_of_elem; - - // if after removing an element head = tail then set them both - // to the beginning of the container as it is empty - - if (pTemp_cont->uiHead == pTemp_cont->uiTail) - pTemp_cont->uiHead = pTemp_cont->uiTail = sizeof(QueueHeader); - - // if only the head is at the end of the container then make it point - // to the beginning of the container - - if (pTemp_cont->uiHead == pTemp_cont->uiMax_size) - pTemp_cont->uiHead = sizeof(QueueHeader); - - return TRUE; -} - -//***************************************************************************** -// -// AddtoQueue -// -// Parameter List : pvoid_queue - pointer to queue -// container -// pdata - pointer to data to add to queue -// -// Return Value pointer to queue with data added -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HQUEUE AddtoQueue(HQUEUE hQueue, void *pdata) -{ - QueueHeader *pTemp_cont; - UINT32 uiMax_size; - UINT32 uiSize_of_each; - UINT32 uiTotal; - UINT32 uiNew_size; - UINT32 uiHead; - UINT32 uiTail; - void *pvoid; - BYTE *pbyte; - BYTE *pmaxsize; - BYTE *presize; - BOOLEAN fresize; - - // check for invalid handle = 0 - if (hQueue == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "This is not a valid pointer to the queue"); - return NULL; - } - - // check for data = NULL - if (pdata == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Data to be added onto queue is NULL"); - return NULL; - } - - // assign some temporary variables - fresize = FALSE; - pTemp_cont = (QueueHeader *)hQueue; - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - uiMax_size = pTemp_cont->uiMax_size; - uiHead = pTemp_cont->uiHead; - uiTail = pTemp_cont->uiTail; - if ((uiTail + uiSize_of_each) > uiMax_size) - { - uiTail = pTemp_cont->uiTail = sizeof(QueueHeader); - fresize = TRUE; - } - if ((uiHead == uiTail) && ((uiHead >= (sizeof(QueueHeader) + uiSize_of_each)) || (fresize == TRUE))) - { - uiNew_size = uiMax_size + (uiMax_size - sizeof(QueueHeader)); - pTemp_cont->uiMax_size = uiNew_size; - if ((hQueue = MemRealloc(hQueue, uiNew_size)) == NULL) - { - DbgMessage(TOPIC_QUEUE_CONTAINERS, DBG_LEVEL_0, "Could not resize queue container memory"); - return NULL; - } - // copy memory from beginning of container to end of container - // so that all the data is in one continuous block - - pTemp_cont = (QueueHeader *)hQueue; - presize = (BYTE *)hQueue; - pmaxsize = (BYTE *)hQueue; - presize += sizeof(QueueHeader); - pmaxsize += uiMax_size; - if (uiHead > sizeof(QueueHeader)) - memmove(pmaxsize, presize, uiHead-sizeof(QueueHeader)); - pTemp_cont->uiTail = uiMax_size + (uiHead-sizeof(QueueHeader)); - } - pbyte = (BYTE *)hQueue; - pbyte += pTemp_cont->uiTail; - pvoid = (void *)pbyte; - memmove(pvoid, pdata, uiSize_of_each); - pTemp_cont->uiTotal_items++; - pTemp_cont->uiTail += uiSize_of_each; - return hQueue; -} - -//***************************************************************************** -// -// do_copy -// -// Parameter List : pointer to mem, source offset, dest offset, size -// -// Return Value BOOLEAN -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN do_copy(void *pmem_void, UINT32 uiSourceOfst, UINT32 uiDestOfst, UINT32 uiSize) -{ - BYTE *pOffsetSrc; - BYTE *pOffsetDst; - void *pvoid_src; - void *pvoid_dest; - - if ((uiSourceOfst < 0) || (uiDestOfst < 0) || (uiSize < 0)) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid parameters passed to do_copy"); - return FALSE; - } - - if (pmem_void == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid pointer passed to do_copy"); - return FALSE; - } - pOffsetSrc = (BYTE *)pmem_void; - pOffsetSrc += uiSourceOfst; - pOffsetDst = (BYTE *)pmem_void; - pOffsetDst += uiDestOfst; - pvoid_src = (void *)pOffsetSrc; - pvoid_dest = (void *)pOffsetDst; - memmove(pvoid_dest, pvoid_src, uiSize); - return TRUE; -} -//***************************************************************************** -// -// do_copy_data -// -// Parameter List : pointer to mem, pointer to data, source offset, size -// -// Return Value BOOLEAN -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN do_copy_data(void *pmem_void, void *data, UINT32 uiSrcOfst, UINT32 uiSize) -{ - BYTE *pOffsetSrc; - void *pvoid_src; - - if ((uiSrcOfst < 0) || (uiSize < 0)) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid parameters passed to do_copy_data"); - return FALSE; - } - - if (pmem_void == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Invalid pointer passed to do_copy_data"); - return FALSE; - } - pOffsetSrc = (BYTE *)pmem_void; - pOffsetSrc += uiSrcOfst; - pvoid_src = (void *)pOffsetSrc; - memmove(data, pvoid_src, uiSize); - return TRUE; -} -//***************************************************************************** -// -// StackSize -// -// Parameter List : pointer to stack -// -// Return Value UINT32 stack size -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -UINT32 StackSize(HSTACK hStack) -{ - StackHeader *pTemp_cont; - if (hStack == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Stack pointer is NULL"); - return 0; - } - pTemp_cont = (StackHeader *)hStack; - return pTemp_cont->uiTotal_items; -} -//***************************************************************************** -// -// QueueSize -// -// Parameter List : pointer to queue -// -// Return Value UINT32 queue size -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -UINT32 QueueSize(HQUEUE hQueue) -{ - QueueHeader *pTemp_cont; - if (hQueue == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Queue pointer is NULL"); - return 0; - } - pTemp_cont = (QueueHeader *)hQueue; - return pTemp_cont->uiTotal_items; -} -//***************************************************************************** -// -// ListSize -// -// Parameter List : pointer to queue -// -// Return Value UINT32 list size -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -UINT32 ListSize(HLIST hList) -{ - ListHeader *pTemp_cont; - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "List pointer is NULL"); - return 0; - } - pTemp_cont = (ListHeader *)hList; - return pTemp_cont->uiTotal_items; -} -//***************************************************************************** -// -// OrdListSize -// -// Parameter List : pointer to list -// -// Return Value UINT32 Ordlist size -// -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -UINT32 OrdListSize(HORDLIST hOrdList) -{ - OrdListHeader *pTemp_cont; - if (hOrdList == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Ordered List pointer is NULL"); - return 0; - } - pTemp_cont = (OrdListHeader *)hOrdList; - return pTemp_cont->uiTotal_items; -} -//***************************************************************************** -// -// AddtoList -// -// Parameter List : HCONTAINER - handle to list -// container -// data - data to add to queue -// position - position after which data is to added -// -// Return Value BOOLEAN true if push ok -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HLIST AddtoList(HLIST hList, void *pdata, UINT32 uiPos) -{ - ListHeader *pTemp_cont; - UINT32 uiMax_size; - UINT32 uiSize_of_each; - UINT32 uiTotal; - UINT32 uiNew_size; - UINT32 uiHead; - UINT32 uiTail; - void *pvoid; - BYTE *pbyte; - UINT32 uiOffsetSrc; - UINT32 uiOffsetDst; - UINT32 uiFinalLoc = 0; - BOOLEAN fTail_check=FALSE; - - // check for invalid handle = 0 - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid handle to the list"); - return NULL; - } - - // check for data = NULL - if (pdata == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto list is NULL"); - return NULL; - } - // check for a 0 or negative position passed in - if (uiPos < 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto list is NULL"); - return NULL; - } - - // assign some temporary variables - - pTemp_cont = (ListHeader *)hList; - if (uiPos > pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "There are not enough elements in the list"); - return NULL; - } - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - uiMax_size = pTemp_cont->uiMax_size; - uiHead = pTemp_cont->uiHead; - uiTail = pTemp_cont->uiTail; - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - if (uiOffsetSrc >= uiMax_size) - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - uiMax_size); - if (uiTail == uiOffsetSrc) - fTail_check = TRUE; - // copy appropriate blocks - if (((uiTail + uiSize_of_each) <= uiMax_size) && - ((uiTail > uiHead) || ((uiTail == uiHead) && (uiHead == sizeof(ListHeader))))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - if (fTail_check == FALSE) - { - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - } - if (fTail_check == FALSE) - pTemp_cont->uiTail += uiSize_of_each; - uiFinalLoc = uiOffsetSrc; - } - - - if ((((uiTail + uiSize_of_each) <= uiMax_size) && (uiTail < uiHead)) - || (((uiTail + uiSize_of_each) > uiMax_size) && (uiHead >= (sizeof(ListHeader) + uiSize_of_each)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - - if (uiOffsetSrc >= uiMax_size) - { - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - uiMax_size); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy(hList, uiOffsetDst, uiOffsetSrc, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - uiFinalLoc = uiOffsetSrc; - } else - { - uiOffsetSrc = sizeof(ListHeader); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - - uiOffsetSrc = uiMax_size - uiSize_of_each; - uiOffsetDst = sizeof(ListHeader); - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, (uiMax_size-uiSize_of_each) - uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - } - pTemp_cont->uiTail += uiSize_of_each; - uiFinalLoc = uiOffsetSrc; - }// end if - - - - if ((((uiTail + uiSize_of_each) <= uiMax_size) && (uiTail == uiHead) && (uiHead >= (sizeof(ListHeader) + uiSize_of_each))) - || (((uiTail + uiSize_of_each) > uiMax_size) && (uiHead == sizeof(ListHeader)))) - { - // need to resize the container - uiNew_size = uiMax_size + (uiMax_size - sizeof(ListHeader)); - pTemp_cont->uiMax_size = uiNew_size; - if ((hList = MemRealloc(hList, uiNew_size)) == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not resize list container memory"); - return NULL; - } - pTemp_cont = (ListHeader *)hList; - if (do_copy(hList, sizeof(ListHeader), uiMax_size, uiHead - sizeof(ListHeader)) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not copy list container memory"); - return NULL; - } - pTemp_cont->uiTail = uiMax_size + (uiHead-sizeof(ListHeader)); - - // now make place for the actual element - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - pTemp_cont->uiTail += uiSize_of_each; - uiFinalLoc = uiOffsetSrc; - } - - - // finally insert data at position uiFinalLoc - - pbyte = (BYTE *)hList; - if (uiFinalLoc == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "This should never happen! report this problem!"); - return NULL; - } - pbyte += uiFinalLoc; - pvoid = (void *)pbyte; - - memmove(pvoid, pdata, pTemp_cont->uiSiz_of_elem); - pTemp_cont->uiTotal_items++; - if (fTail_check == TRUE) - pTemp_cont->uiTail += pTemp_cont->uiSiz_of_elem; - return hList; -} - -//***************************************************************************** -// -// RemfromList -// -// Parameter List : HLIST - handle to list -// container -// data - data to remove from list -// position - position after which data is to added -// -// Return Value BOOLEAN true if push ok -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN RemfromList(HLIST hList, void *pdata, UINT32 uiPos) -{ - ListHeader *pTemp_cont; - UINT32 uiMax_size; - UINT32 uiSize_of_each; - UINT32 uiTotal; - UINT32 uiHead; - UINT32 uiTail; - UINT32 uiOffsetSrc; - UINT32 uiOffsetDst; - UINT32 uiFinalLoc = 0; - - // check for invalid handle = 0 - if (hList == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid handle to the list"); - return FALSE; - } - - // check for data = NULL - if (pdata == NULL) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto list is NULL"); - return FALSE; - } - // check for a 0 or negative position passed in - if (uiPos < 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto list is NULL"); - return FALSE; - } - - // assign some temporary variables - pTemp_cont = (ListHeader *)hList; - - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Cannot delete at the specified position"); - return FALSE; - } - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "There are no elements in the list to remove"); - return FALSE; - } - - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - uiMax_size = pTemp_cont->uiMax_size; - uiHead = pTemp_cont->uiHead; - uiTail = pTemp_cont->uiTail; - - // copy appropriate blocks - if ((uiTail > uiHead) || ((uiTail == uiHead) && (uiHead == sizeof(ListHeader)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - if (do_copy_data(hList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - return FALSE; - } - if (do_copy(hList, uiOffsetDst, uiOffsetSrc, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not remove the data the list"); - return FALSE; - } - pTemp_cont->uiTail -= uiSize_of_each; - pTemp_cont->uiTotal_items--; - } - - - if ((uiTail < uiHead) || ((uiTail == uiHead) && (uiHead <= (sizeof(ListHeader)+uiSize_of_each)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - - if (uiOffsetSrc >= uiMax_size) - { - uiOffsetSrc = sizeof(ListHeader) + (uiOffsetSrc - uiMax_size); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy_data(hList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - return FALSE; - } - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - uiFinalLoc = uiOffsetSrc; - } - else - { - uiOffsetSrc = sizeof(ListHeader); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - - uiOffsetSrc = uiMax_size - uiSize_of_each; - uiOffsetDst = sizeof(ListHeader); - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy_data(hList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - return FALSE; - } - if (do_copy(hList, uiOffsetSrc, uiOffsetDst, (uiMax_size-uiSize_of_each) - uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_LIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - } - pTemp_cont->uiTail -= uiSize_of_each; - pTemp_cont->uiTotal_items--; - } // end if - - return TRUE; -} - - - -//***************************************************************************** -// -// RemfromOrdList -// -// Parameter List : HORDLIST - handle to ordered list -// container -// data - data to remove from ordered list -// position - position after which data is to added -// -// Return Value BOOLEAN true if push ok -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -BOOLEAN RemfromOrdList(HORDLIST hOrdList, void *pdata, UINT32 uiPos) -{ - OrdListHeader *pTemp_cont; - UINT32 uiMax_size; - UINT32 uiSize_of_each; - UINT32 uiTotal; - UINT32 uiHead; - UINT32 uiTail; - UINT32 uiOffsetSrc; - UINT32 uiOffsetDst; - UINT32 uiFinalLoc = 0; - - - // check for invalid handle = 0 - if (hOrdList == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid handle to the ordered list"); - return FALSE; - } - - // check for data = NULL - if (pdata == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto ordered list is NULL"); - return FALSE; - } - // check for a 0 or negative position passed in - if (uiPos < 0) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto ordered list is NULL"); - return FALSE; - } - - // assign some temporary variables - - pTemp_cont = (OrdListHeader *)hOrdList; - if (uiPos >= pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Cannot delete at the specified position"); - return FALSE; - } - - if (pTemp_cont->uiTotal_items == 0) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "There are no elements in the ordered list to remove"); - return FALSE; - } - - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - uiMax_size = pTemp_cont->uiMax_size; - uiHead = pTemp_cont->uiHead; - uiTail = pTemp_cont->uiTail; - - // copy appropriate blocks - if ((uiTail > uiHead) || ((uiTail == uiHead) && (uiHead == sizeof(OrdListHeader)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - if (do_copy_data(hOrdList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from ordered list"); - return FALSE; - } - - if (do_copy(hOrdList, uiOffsetDst, uiOffsetSrc, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not remove the data from the ordered list"); - return FALSE; - } - - pTemp_cont->uiTail -= uiSize_of_each; - pTemp_cont->uiTotal_items--; - } - - - if ((uiTail < uiHead) || ((uiTail == uiHead) && (uiHead <= (sizeof(OrdListHeader)+uiSize_of_each)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - - if (uiOffsetSrc >= uiMax_size) - { - uiOffsetSrc = sizeof(OrdListHeader) + (uiOffsetSrc - uiMax_size); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy_data(hOrdList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - return FALSE; - } - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - - uiFinalLoc = uiOffsetSrc; - } - else - { - uiOffsetSrc = sizeof(OrdListHeader); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - - uiOffsetSrc = uiMax_size - uiSize_of_each; - uiOffsetDst = sizeof(OrdListHeader); - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - if (do_copy_data(hOrdList, pdata, uiOffsetSrc, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - return FALSE; - } - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, (uiMax_size-uiSize_of_each) - uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return FALSE; - } - } - - pTemp_cont->uiTail -= uiSize_of_each; - pTemp_cont->uiTotal_items--; - } // end if - - - return TRUE; -} - - - -//***************************************************************************** -// -// StoreinOrdList -// -// Parameter List : HORDLIST - handle to ordered list -// container -// data - data to add to the ordered list -// position - position after which data is to added -// -// Return Value BOOLEAN true if push ok -// else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// -//***************************************************************************** -HORDLIST StoreinOrdList(HORDLIST hOrdList, void *pdata, UINT32 uiPos) -{ - OrdListHeader *pTemp_cont; - UINT32 uiMax_size; - UINT32 uiSize_of_each; - UINT32 uiTotal; - UINT32 uiNew_size; - UINT32 uiHead; - UINT32 uiTail; - void *pvoid; - BYTE *pbyte; - UINT32 uiOffsetSrc; - UINT32 uiOffsetDst; - UINT32 uiFinalLoc = 0; - BOOLEAN fTail_check=FALSE; - - - // check for invalid handle = 0 - if (hOrdList == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "This is not a valid handle to the ordered list"); - return NULL; - } - - // check for data = NULL - if (pdata == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Data to be pushed onto ordered list is NULL"); - return NULL; - } - - // assign some temporary variables - pTemp_cont = (OrdListHeader *)hOrdList; - - // check for invalid position - if (uiPos > pTemp_cont->uiTotal_items) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "There are not enough elements in the ordered list to add after"); - return NULL; - } - - - uiTotal = pTemp_cont->uiTotal_items; - uiSize_of_each = pTemp_cont->uiSiz_of_elem; - uiMax_size = pTemp_cont->uiMax_size; - uiHead = pTemp_cont->uiHead; - uiTail = pTemp_cont->uiTail; - uiOffsetSrc = pTemp_cont->uiHead + (uiPos * pTemp_cont->uiSiz_of_elem); - - - // this shouldn't be necessary? position should never be outside the range? - if (uiOffsetSrc >= uiMax_size) - uiOffsetSrc = sizeof(OrdListHeader) + (uiOffsetSrc - uiMax_size); - - if (uiTail == uiOffsetSrc) - fTail_check = TRUE; - - - // now copy the appropriate blocks to make room... - - if (((uiTail + uiSize_of_each) <= uiMax_size) && - ((uiTail > uiHead) || ((uiTail == uiHead) && (uiHead == sizeof(OrdListHeader))))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - - if (fTail_check == FALSE) - { - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in ordered list"); - return NULL; - } - } - - if (fTail_check == FALSE) - pTemp_cont->uiTail += uiSize_of_each; - - uiFinalLoc = uiOffsetSrc; - } - - - if ((((uiTail + uiSize_of_each) <= uiMax_size) && (uiTail < uiHead)) || - (((uiTail + uiSize_of_each) > uiMax_size) && (uiHead >= (sizeof(OrdListHeader) + uiSize_of_each)))) - { - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - - if (uiOffsetSrc >= uiMax_size) - { - uiOffsetSrc = sizeof(OrdListHeader) + (uiOffsetSrc - uiMax_size); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - - if (do_copy(hOrdList, uiOffsetDst, uiOffsetSrc, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - uiFinalLoc = uiOffsetSrc; - } - else - { - uiOffsetSrc = sizeof(OrdListHeader); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - - uiOffsetSrc = uiMax_size - uiSize_of_each; - uiOffsetDst = sizeof(OrdListHeader); - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiSize_of_each) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + uiSize_of_each; - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, (uiMax_size-uiSize_of_each) - uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - } - - pTemp_cont->uiTail += uiSize_of_each; - uiFinalLoc = uiOffsetSrc; - } // end if - - - - if ((((uiTail + uiSize_of_each) <= uiMax_size) && (uiTail == uiHead) && (uiHead >= (sizeof(OrdListHeader) + uiSize_of_each))) - || (((uiTail + uiSize_of_each) > uiMax_size) && (uiHead == sizeof(OrdListHeader)))) - { - // need to resize the container - uiNew_size = uiMax_size + (uiMax_size - sizeof(OrdListHeader)); - pTemp_cont->uiMax_size = uiNew_size; - - if ((hOrdList = MemRealloc(hOrdList, uiNew_size)) == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not resize ordered list container memory"); - return NULL; - } - - pTemp_cont = (OrdListHeader *)hOrdList; - - if (do_copy(hOrdList, sizeof(OrdListHeader), uiMax_size, uiHead - sizeof(OrdListHeader)) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy ordered list container memory"); - return NULL; - } - - pTemp_cont->uiTail = uiMax_size + (uiHead-sizeof(OrdListHeader)); - - // now make place for the actual element - - uiOffsetSrc = pTemp_cont->uiHead + (uiPos*pTemp_cont->uiSiz_of_elem); - uiOffsetDst = uiOffsetSrc + pTemp_cont->uiSiz_of_elem; - - if (do_copy(hOrdList, uiOffsetSrc, uiOffsetDst, uiTail-uiOffsetSrc) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not store the data in list"); - return NULL; - } - pTemp_cont->uiTail += uiSize_of_each; - uiFinalLoc = uiOffsetSrc; - } - - if (uiFinalLoc == 0) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "This should never happen! report this problem!"); - return NULL; - } - - - // finally insert data at position uiFinalLoc - pbyte = (BYTE *)hOrdList; - pbyte += uiFinalLoc; - pvoid = (void *)pbyte; - memmove(pvoid, pdata, pTemp_cont->uiSiz_of_elem); - pTemp_cont->uiTotal_items++; - - if (fTail_check == TRUE) - pTemp_cont->uiTail += pTemp_cont->uiSiz_of_elem; - - return hOrdList; -} - - - -//***************************************************************************** -// -// AddtoOrdList -// -// Parameter List : HORDLIST - handle to ordered list -// container -// data - data to add to the ordered list -// -// Return Value BOOLEAN true if Add ok else false -// -// Modification History : -// Nov 26th 1996->modified for use by Wizardry -// Dec 19th 1997->verified, cleaned up, and heavily commented by AM -// -//***************************************************************************** -HORDLIST AddtoOrdList(HORDLIST hOrdList, void *pdata) -{ - OrdListHeader *pOrdList; - void *pTemp_data; - UINT32 uiOffset; - BOOLEAN fContinue = FALSE; - INT8 sbResult; - UINT32 uiPosition; - - - // get a pointer into the list header - pOrdList = (OrdListHeader *)hOrdList; - - - // if the list is empty or full) - if (pOrdList->uiHead == pOrdList->uiTail) - { - // if the head offset points to position 0, presumably that means it's empty (?) - if (pOrdList->uiHead == sizeof(OrdListHeader)) - { - // so store it in position 0 - if ((hOrdList = StoreinOrdList(hOrdList, pdata, 0)) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data into ordered list"); - return NULL; - } - - return hOrdList; - } - - // set flag to go through the while loop even though head == tail - fContinue = TRUE; - } - - - // grab enough space to store one list entry - pTemp_data = MemAlloc(pOrdList->uiSiz_of_elem); - - // start offset by pointing at the last entry in the the list - uiOffset = pOrdList->uiTail; - - // figure out the index of the entry that the tail points to - uiPosition = (pOrdList->uiTail - sizeof(OrdListHeader)) / pOrdList->uiSiz_of_elem; - - - // continue looping while offset hasn't reached the start of the list yet (or at least once if list is full) - while ((uiOffset != pOrdList->uiHead) || (fContinue)) - { - // when offset reaches the top of the list - if (uiOffset == sizeof(OrdListHeader)) - { - // wrap around to the very bottom of the list (guaranteed to hold data?) - uiOffset = pOrdList->uiMax_size; - uiPosition = (pOrdList->uiMax_size - sizeof(OrdListHeader)) / pOrdList->uiSiz_of_elem; - } - - // get entry data at the current offset position and store it in pTemp_data - if (do_copy_data(hOrdList, pTemp_data, (uiOffset - pOrdList->uiSiz_of_elem), pOrdList->uiSiz_of_elem ) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data from list"); - MemFree(pTemp_data); - return NULL; - } - - // run the compare function - sbResult = pOrdList->pCompare(pTemp_data, pdata, pOrdList->uiSiz_of_elem); - - // and do the right thing based on the result... - switch (sbResult) - { - case ORDLIST_ERROR : - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not perform comparison for ordered lists"); - MemFree(pTemp_data); - return NULL; - } - - case ORDLIST_EQUAL : - case ORDLIST_LEFT_LESS : - { - // found the right spot! Insert it at the current position - if ((hOrdList = StoreinOrdList(hOrdList, pdata, uiPosition)) == NULL) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data into ordered list"); - MemFree(pTemp_data); - return NULL; - } - return hOrdList; - } - - case ORDLIST_RIGHT_LESS : - { - // keep looking - uiOffset -= pOrdList->uiSiz_of_elem; - uiPosition--; - break; - } - - default : - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Invalid result received from Compare function"); - MemFree(pTemp_data); - return NULL; - } - } // end switch - - fContinue = FALSE; - } // end while - - - // don't need this anymore - MemFree(pTemp_data); - pTemp_data = NULL; - - - // never found the right spot, which means we must have reached the head (damn well better) - if (uiOffset != pOrdList->uiHead) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "ERROR - left the while loop but not at the head"); - return NULL; - } - - // the new item will be first in list, so calculate the position based on the head - uiPosition = (pOrdList->uiHead - sizeof(OrdListHeader)) / pOrdList->uiSiz_of_elem; - - // and stick it in there... - if ((hOrdList = StoreinOrdList(hOrdList, pdata, uiPosition)) == FALSE) - { - DbgMessage(TOPIC_ORDLIST_CONTAINERS, DBG_LEVEL_0, "Could not copy the data into ordered list"); - return NULL; - } - - - return hOrdList; -} - - - -INT8 Compare(void *p, void *q, UINT32 size) -{ - TEST *temp1; - TEST *temp2; - - - temp1 = (TEST *)p; - temp2 = (TEST *)q; - - if (temp1->me < temp2->me) - return ORDLIST_LEFT_LESS; - - if (temp1->me > temp2->me) - return ORDLIST_RIGHT_LESS; - - if (temp1->me == temp2->me) - return ORDLIST_EQUAL; - - return ORDLIST_ERROR; -} diff --git a/Standard Gaming Platform/Container.h b/Standard Gaming Platform/Container.h deleted file mode 100644 index 69dfe1f5..00000000 --- a/Standard Gaming Platform/Container.h +++ /dev/null @@ -1,132 +0,0 @@ -//*********************************************** -// -// Filename : Container.h -// -// Purpose : prototypes for the container file -// -// Modification History : 25 Nov 96 Creation -// -//*********************************************** - -#ifndef _CONTAINER_H -#define _CONTAINER_H - -//*********************************************** -// -// Includes -// -// -//*********************************************** - -#include "types.h" - -//*********************************************** -// -// Defines and typedefs -// -//*********************************************** -#define ORDLIST_ERROR -1 -#define ORDLIST_EQUAL 0 -#define ORDLIST_LEFT_LESS 1 -#define ORDLIST_RIGHT_LESS 2 - -typedef void * HCONTAINER; -typedef HCONTAINER HSTACK; -typedef HCONTAINER HQUEUE; -typedef HCONTAINER HLIST; -typedef HCONTAINER HORDLIST; - -//*********************************************** -// -// Function Prototypes -// -//*********************************************** -#ifdef __cplusplus -extern "C" { -#endif - -// call these functions to initialize and shutdown the debug messages for -// containers -extern void InitializeContainers(void); -extern void ShutdownContainers(void); - -// Stack Functions -// CreateStack(estimated number of items in stack, size of each item -// Push(handle to container returned from CreateStack, data to be passed in (must be void *) -// : returns handle to new stack -// Pop(handle to container returned from CreateStack, data to be passed in (must be void *) -// : returns BOOLEAN -// DeleteStack deletes the stack container -// StackSize returns size of stack - -extern HSTACK CreateStack(UINT32 num_of_elem , UINT32 siz_of_each); -extern HSTACK Push(HSTACK hStack, void *data); -extern BOOLEAN Pop(HSTACK hStack, void *data); -extern UINT32 StackSize(HSTACK hStack); -extern BOOLEAN DeleteStack(HSTACK hStack); -extern BOOLEAN PeekStack(HSTACK hStack, void *data); - -// Queue Functions -// CreateQueue(estimated number of items in queue, size of each item -// AddtoQueue(handle to container returned from CreateQueue, data to be passed in (must be void *)) -// : returns handle to queue -// RemfromQueue(handle to container returned from CreateQueue, variable where data is stored (must be void *)) -// : returns BOOLEAN -// PeekQueue(handle to the queue, variable where peeked data is stored). Item is not deleted. -// : returns BOOLEAN -// QueueSize(handle to the queue) returns the queue size -// DeleteQueue(handle to container) Delete the queue container -// : returns BOOLEAN - -extern HQUEUE CreateQueue(UINT32 num_of_elem, UINT32 siz_of_each); -extern HQUEUE AddtoQueue(HQUEUE hQueue, void *data); -extern BOOLEAN RemfromQueue(HQUEUE hQueue,void *data); -extern BOOLEAN PeekQueue(HQUEUE hQueue, void *data); -extern UINT32 QueueSize(HQUEUE hQueue); -extern BOOLEAN DeleteQueue(HQUEUE hQueue); - -// List Functions -// CreateList(estimated number of items in queue, size of each item -// AddtoList(handle to container returned from CreateQueue, data to be passed in (must be void *) -// position where data is to be added (0...sizeof(list)) -// : returns handle to new list -// RemfromList(handle to container returned from CreateList, variable where data is stored (must be void *) -// position where data is to be deleted (0...sizeof(list)-1) -// PeekList(handle to the list, variable where peeked data is stored). Item is not deleted. -// position where data is to be peeked (0...sizeof(list)-1) -// ListSize(handle to the list) returns the list size -// DeleteList(handle to the list) Delete the list container - -extern HLIST CreateList(UINT32 num_of_elem, UINT32 siz_of_each); -extern HLIST AddtoList(HLIST hList, void *data, UINT32 position); -extern BOOLEAN RemfromList(HLIST hList,void *data, UINT32 position); -extern BOOLEAN PeekList(HLIST hList, void *data, UINT32 position); -extern UINT32 ListSize(HLIST hList); -extern BOOLEAN DeleteList(HLIST hList); -extern BOOLEAN SwapListNode(HLIST hList, void *pdata, UINT32 uiPos); -extern BOOLEAN StoreListNode(HLIST hList, void *pdata, UINT32 uiPos); - -// Ordered List Functions -// CreateOrdList(estimated number of items in ordered list, size of each item, -// pointer to a compare function that returns info on whether the data in the ordered stack -// is < or > the new data to be added into the ordered list. -// AddtoOrdList(handle to container returned from CreateOrdList, data to be passed in (must be void *) -// RemfromOrdList(handle to container returned from CreateList, variable where data is stored (must be void *) -// position where data is to be deleted (0...sizeof(list)-1) -// PeekOrdList(handle to the list, variable where peeked data is stored). Item is not deleted. -// position where data is to be peeked (0...sizeof(list)-1) -// OrdListSize(handle to the list) returns the ordered list size -// DeleteOrdList(handle to the list) Delete the ordered list container - -extern HLIST CreateOrdList(UINT32 num_of_elem, UINT32 siz_of_each, INT8 (*compare)(void *,void *, UINT32)); -extern HLIST AddtoOrdList(HLIST hList, void *data); -extern BOOLEAN RemfromOrdList(HLIST hList,void *data, UINT32 position); -extern BOOLEAN PeekOrdList(HLIST hList, void *data, UINT32 position); -extern UINT32 OrdListSize(HLIST hList); -extern BOOLEAN DeleteOrdList(HLIST hList); - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index 9e4c3804..ec348b16 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -36,7 +36,6 @@ #include "MemMan.h" #include "Debug.h" #include "RegInst.h" - #include "Container.h" #include "LibraryDataBase.h" #include "io.h" #include "sgp_logger.h" @@ -149,8 +148,6 @@ void W32toSGPFileFind( GETFILESTRUCT *pGFStruct, WIN32_FIND_DATA *pW32Struct ); HANDLE GetHandleToRealFile( HWFILE hFile, BOOLEAN *pfDatabaseFile ); HWFILE CreateFileHandle( HANDLE hRealFile, BOOLEAN fDatabaseFile ); void DestroyFileHandle( HWFILE hFile ); -void BuildFileDirectory( void ); -INT32 GetFilesInDirectory( HCONTAINER hStack, CHAR *, HANDLE hFile, WIN32_FIND_DATA *pFind ); //************************************************************************** // @@ -950,169 +947,6 @@ void DestroyFileHandle( HWFILE hFile ) */ - -//************************************************************************** -// -// BuildFileDirectory -// -// -// -// Parameter List : -// Return Value : -// Modification history : -// -// ??nov96:HJH ->creation -// -//************************************************************************** - -void BuildFileDirectory( void ) -{ - - return; // temporary until container stuff is fixed -/* - INT32 i, iNumFiles = 0; - HANDLE hFile, hFileIn; - WIN32_FIND_DATA find, inFind; - BOOLEAN fMore = TRUE; - CHAR cName[FILENAME_LENGTH], cDir[FILENAME_LENGTH], cSubDir[FILENAME_LENGTH]; - HCONTAINER hStack; - - - - // - // First, push all the file names in the directory (and subdirectories) - // onto the stack. - // - - GetProfileChar( "Startup", "InstPath", "", cDir ); - - if ( strlen( cDir ) == 0 ) - return; - - hStack = CreateStack( 100, FILENAME_LENGTH ); - if (hStack == NULL) - { - FastDebugMsg(String("BuildFileDirectory: CreateStack Failed for the filename stack")); - return; - } - - find.dwFileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY; - - strcpy( &(cDir[strlen(cDir)]), "\\*.*\0" ); - hFile = FindFirstFile( cDir, &find ); - while ( fMore ) - { - if ( find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) - { - if ( strcmp( find.cFileName, "." ) != 0 && strcmp( find.cFileName, ".." ) != 0 ) - { - // a valid directory - inFind.dwFileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY; - strcpy( cSubDir, cDir ); - strcpy( &(cSubDir[strlen(cDir)-3]), find.cFileName ); - strcpy( &(cSubDir[strlen(cSubDir)]), "\\*.*\0" ); - hFileIn = FindFirstFile( cSubDir, &inFind ); - iNumFiles += GetFilesInDirectory( hStack, cSubDir, hFileIn, &inFind ); - FindClose( hFileIn ); - } - } - else - { - iNumFiles++; - strcpy( cName, cDir ); - strcpy( &(cName[strlen(cName)-3]), find.cFileName ); - CharLower( cName ); - hStack = Push( hStack, cName ); - } - find.dwFileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY; - fMore = FindNextFile( hFile, &find ); - } - FindClose( hFile ); - - // - // Okay, we have all the files in the stack, now put them in place. - // - gfs.uiNumFilesInDirectory = iNumFiles; - - gfs.pcFileNames = (STR8)MemAlloc( iNumFiles * FILENAME_LENGTH ); - - if ( gfs.pcFileNames ) - { - for ( i=0 ; icreation -// -//************************************************************************** - -INT32 GetFilesInDirectory( HCONTAINER hStack, CHAR *pcDir, HANDLE hFile, WIN32_FIND_DATA *pFind ) -{ - INT32 iNumFiles; - WIN32_FIND_DATA inFind; - BOOLEAN fMore; - CHAR cName[FILENAME_LENGTH], cDir[FILENAME_LENGTH]; - HANDLE hFileIn; - - fMore = TRUE; - iNumFiles = 0; - - while ( fMore ) - { - if ( pFind->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) - { - if ( strcmp( pFind->cFileName, "." ) != 0 && strcmp( pFind->cFileName, ".." ) != 0 ) - { - // a valid directory - recurse and find the files in that directory - - inFind.dwFileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY; - strcpy( cDir, pcDir ); - strcpy( &(cDir[strlen(cDir)-3]), pFind->cFileName ); - strcpy( &(cDir[strlen(cDir)]), "\\*.*\0" ); - hFileIn = FindFirstFile( cDir, &inFind ); - iNumFiles += GetFilesInDirectory( hStack, cDir, hFileIn, &inFind ); - FindClose( hFileIn ); - } - } - else - { - iNumFiles++; - strcpy( cName, pcDir ); - strcpy( &(cName[strlen(cName)-3]), pFind->cFileName ); - CharLower( cName ); - hStack = Push( hStack, cName ); - } - pFind->dwFileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY; - fMore = FindNextFile( hFile, pFind ); - } - - return(iNumFiles); -} - BOOLEAN SetFileManCurrentDirectory( STR pcDirectory ) { try diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index e5ba0854..cf38d7b4 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -25,7 +25,6 @@ #include "FileCat.h" -#include "Container.h" //************************************************************************** // @@ -163,9 +162,6 @@ BOOLEAN FileCheckEndOfFile( HWFILE hFile ); BOOLEAN GetFileManFileTime( HWFILE hFile, SGP_FILETIME *pCreationTime, SGP_FILETIME *pLastAccessedTime, SGP_FILETIME *pLastWriteTime ); -INT32 GetFilesInDirectory( HCONTAINER hStack, CHAR *pcDir, HANDLE hFile, WIN32_FIND_DATA *pFind ); - - // CompareSGPFileTimes() returns... // -1 if the First file time is less than second file time. ( first file is older ) diff --git a/Standard Gaming Platform/sgp.cpp b/Standard Gaming Platform/sgp.cpp index b3fe6e6d..e5f601ee 100644 --- a/Standard Gaming Platform/sgp.cpp +++ b/Standard Gaming Platform/sgp.cpp @@ -453,9 +453,6 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow) return FALSE; } - FastDebugMsg("Initializing Containers Manager"); - InitializeContainers(); - FastDebugMsg("Initializing Input Manager"); // Initialize the Input Manager if (InitializeInputManager() == FALSE) @@ -656,7 +653,6 @@ void ShutdownStandardGamingPlatform(void) ShutdownVideoManager(); ShutdownInputManager(); - ShutdownContainers(); ShutdownFileManager(); #ifdef EXTREME_MEMORY_DEBUGGING diff --git a/Standard Gaming Platform/vobject.h b/Standard Gaming Platform/vobject.h index c4964899..40a59f03 100644 --- a/Standard Gaming Platform/vobject.h +++ b/Standard Gaming Platform/vobject.h @@ -2,7 +2,6 @@ #define __VOBJECT_H #include "types.h" -#include "container.h" #include "himage.h" // ************************************************************************************ diff --git a/Standard Gaming Platform/vsurface.h b/Standard Gaming Platform/vsurface.h index 8564aab5..b6a7fa0c 100644 --- a/Standard Gaming Platform/vsurface.h +++ b/Standard Gaming Platform/vsurface.h @@ -2,7 +2,6 @@ #define __VSURFACE_H #include "types.h" -#include "container.h" #include "himage.h" #include "vobject.h" #include diff --git a/Tactical/Faces.cpp b/Tactical/Faces.cpp index a1647353..4759b4ac 100644 --- a/Tactical/Faces.cpp +++ b/Tactical/Faces.cpp @@ -8,7 +8,6 @@ #include "vsurface.h" #include "Render Dirty.h" #include "sysutil.h" - #include "container.h" #include "wcheck.h" #include "video.h" #include "vobject_blitters.h" diff --git a/Tactical/PATHAI.cpp b/Tactical/PATHAI.cpp index c8543b59..9bc43579 100644 --- a/Tactical/PATHAI.cpp +++ b/Tactical/PATHAI.cpp @@ -18,7 +18,6 @@ #include "Animation Cache.h" #include "Animation Data.h" #include "Animation Control.h" - #include "container.h" #include "interface.h" #include diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index d99e31bd..dacb8dfc 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -12,7 +12,6 @@ #include "Animation Cache.h" #include "Animation Data.h" #include "Animation Control.h" -#include "container.h" #define _USE_MATH_DEFINES // for C #include #include "pathai.h" diff --git a/Tactical/Soldier Tile.cpp b/Tactical/Soldier Tile.cpp index 4a3d7037..6b994eac 100644 --- a/Tactical/Soldier Tile.cpp +++ b/Tactical/Soldier Tile.cpp @@ -10,7 +10,6 @@ #include "Animation Cache.h" #include "Animation Data.h" #include "Animation Control.h" - #include "container.h" #include "pathai.h" #include "Random.h" #include "worldman.h" diff --git a/Tactical/bullets.cpp b/Tactical/bullets.cpp index 3548b30c..3d1e62a3 100644 --- a/Tactical/bullets.cpp +++ b/Tactical/bullets.cpp @@ -7,7 +7,6 @@ #include "renderworld.h" #include "vsurface.h" #include "sysutil.h" - #include "container.h" #include "wcheck.h" #include "video.h" #include "vobject_blitters.h" diff --git a/Utils/Event Pump.cpp b/Utils/Event Pump.cpp index c0567777..74576ef5 100644 --- a/Utils/Event Pump.cpp +++ b/Utils/Event Pump.cpp @@ -1,7 +1,6 @@ #include #include #include "sgp.h" -#include "container.h" #include "wcheck.h" #include "Event Pump.h" #include "Timer.h" diff --git a/Utils/Utils All.h b/Utils/Utils All.h index dd77c717..208f4990 100644 --- a/Utils/Utils All.h +++ b/Utils/Utils All.h @@ -30,7 +30,6 @@ #include #include #include -#include "container.h" #include "wcheck.h" #include "Event Manager.h" #include "Event Pump.h" @@ -108,4 +107,4 @@ //#include //#include //#include -#endif \ No newline at end of file +#endif diff --git a/aniviewscreen.cpp b/aniviewscreen.cpp index 8f05104d..638e67a2 100644 --- a/aniviewscreen.cpp +++ b/aniviewscreen.cpp @@ -11,7 +11,6 @@ #include "input.h" #include "font.h" #include "screenids.h" - #include "container.h" #include "overhead.h" #include "sysutil.h" #include "Font Control.h" From 02f733ce2f36648a1c3d14f2deb0a2b57518f49b Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 13:34:03 +0300 Subject: [PATCH 055/120] Remove CreateFileHandle() & DestroyFileHandle() --- Standard Gaming Platform/FileMan.cpp | 90 ---------------------------- 1 file changed, 90 deletions(-) diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index ec348b16..91e270af 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -144,10 +144,7 @@ TFileCat gCustomDataCat; // Init in InitializeStandardGamingPlatform (sgp.cpp) //************************************************************************** void W32toSGPFileFind( GETFILESTRUCT *pGFStruct, WIN32_FIND_DATA *pW32Struct ); - HANDLE GetHandleToRealFile( HWFILE hFile, BOOLEAN *pfDatabaseFile ); -HWFILE CreateFileHandle( HANDLE hRealFile, BOOLEAN fDatabaseFile ); -void DestroyFileHandle( HWFILE hFile ); //************************************************************************** // @@ -859,93 +856,6 @@ HANDLE GetHandleToRealFile( HWFILE hFile, BOOLEAN *pfDatabaseFile ) return(hRealFile); } -//************************************************************************** -// -// CreateFileHandle -// -// -// -// Parameter List : -// Return Value : -// Modification history : -// -// 24sep96:HJH ->creation -// -//************************************************************************** -/* - - not needed anymore - -HWFILE CreateFileHandle( HANDLE hRealFile, BOOLEAN fDatabaseFile ) -{ - UINT32 i, uiOldNumHandles; - FMFileInfo *pNewFileInfo; - - Assert( !fDatabaseFile || (fDatabaseFile && gfs.fDBInitialized) ); - - // don't use 1st position - it'll confuse the users - for ( i=1 ; icreation -// -//************************************************************************** -/* -void DestroyFileHandle( HWFILE hFile ) -{ - if ( hFile < gfs.uiNumHandles && hFile ) - { - gfs.pFileInfo[hFile].hFileHandle = 0; - gfs.pFileInfo[hFile].hDBFile = 0; - } -} -*/ - BOOLEAN SetFileManCurrentDirectory( STR pcDirectory ) { From 6c0b62cb42a06e0a5b872fede2f1103aed72befd Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 13:37:12 +0300 Subject: [PATCH 056/120] Remove W32toSGPFileFind() --- Standard Gaming Platform/FileMan.cpp | 61 ---------------------------- 1 file changed, 61 deletions(-) diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index 91e270af..ae437a73 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -143,7 +143,6 @@ TFileCat gCustomDataCat; // Init in InitializeStandardGamingPlatform (sgp.cpp) // //************************************************************************** -void W32toSGPFileFind( GETFILESTRUCT *pGFStruct, WIN32_FIND_DATA *pW32Struct ); HANDLE GetHandleToRealFile( HWFILE hFile, BOOLEAN *pfDatabaseFile ); //************************************************************************** @@ -1004,66 +1003,6 @@ void GetFileClose( GETFILESTRUCT *pGFStruct ) file_iter = vfs::CVirtualFileSystem::Iterator(); } -void W32toSGPFileFind( GETFILESTRUCT *pGFStruct, WIN32_FIND_DATA *pW32Struct ) -{ - UINT32 uiAttribMask; - - // Copy the filename - strcpy(pGFStruct->zFileName, pW32Struct->cFileName); - - // Get file size - if ( pW32Struct->nFileSizeHigh != 0 ) - pGFStruct->uiFileSize = 0xffffffff; - else - pGFStruct->uiFileSize = pW32Struct->nFileSizeLow; - - // Copy the file attributes - pGFStruct->uiFileAttribs = 0; - - for( uiAttribMask = 0x80000000; uiAttribMask > 0; uiAttribMask >>= 1) - { - switch( pW32Struct->dwFileAttributes & uiAttribMask ) - { - case FILE_ATTRIBUTE_ARCHIVE: - pGFStruct->uiFileAttribs |= FILE_IS_ARCHIVE; - break; - - case FILE_ATTRIBUTE_DIRECTORY: - pGFStruct->uiFileAttribs |= FILE_IS_DIRECTORY; - break; - - case FILE_ATTRIBUTE_HIDDEN: - pGFStruct->uiFileAttribs |= FILE_IS_HIDDEN; - break; - - case FILE_ATTRIBUTE_NORMAL: - pGFStruct->uiFileAttribs |= FILE_IS_NORMAL; - break; - - case FILE_ATTRIBUTE_READONLY: - pGFStruct->uiFileAttribs |= FILE_IS_READONLY; - break; - - case FILE_ATTRIBUTE_SYSTEM: - pGFStruct->uiFileAttribs |= FILE_IS_SYSTEM; - break; - - case FILE_ATTRIBUTE_TEMPORARY: - pGFStruct->uiFileAttribs |= FILE_IS_TEMPORARY; - break; - - case FILE_ATTRIBUTE_COMPRESSED: - pGFStruct->uiFileAttribs |= FILE_IS_COMPRESSED; - break; - - case FILE_ATTRIBUTE_OFFLINE: - pGFStruct->uiFileAttribs |= FILE_IS_OFFLINE; - break; - } - } -} - - BOOLEAN FileCopy(STR strSrcFile, STR strDstFile, BOOLEAN fFailIfExists) { From 62b8d272e671d7d749111a088f3b722f07700947 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 13:38:03 +0300 Subject: [PATCH 057/120] Remove GetHandleToRealFile() --- Standard Gaming Platform/FileMan.cpp | 44 ---------------------------- 1 file changed, 44 deletions(-) diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index ae437a73..bc0d5442 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -143,8 +143,6 @@ TFileCat gCustomDataCat; // Init in InitializeStandardGamingPlatform (sgp.cpp) // //************************************************************************** -HANDLE GetHandleToRealFile( HWFILE hFile, BOOLEAN *pfDatabaseFile ); - //************************************************************************** // // Functions @@ -814,48 +812,6 @@ UINT32 FileGetSize( HWFILE hFile ) } -//************************************************************************** -// -// GetHandleToRealFile -// -// -// -// Parameter List : -// Return Value : -// Modification history : -// -// 24sep96:HJH ->creation -// -// 9 Feb 98 DEF - modified to work with the library system -// -//************************************************************************** - -HANDLE GetHandleToRealFile( HWFILE hFile, BOOLEAN *pfDatabaseFile ) -{ - HANDLE hRealFile; - - INT16 sLibraryID; - UINT32 uiFileNum; - - GetLibraryAndFileIDFromLibraryFileHandle( hFile, &sLibraryID, &uiFileNum ); - - //if its a real file, read the data from the file - if( sLibraryID == REAL_FILE_LIBRARY_ID ) - { - //Get the handle to the real file - hRealFile = gFileDataBase.RealFiles.pRealFilesOpen[ uiFileNum ].hRealFileHandle; - *pfDatabaseFile = FALSE; - } - else - { - *pfDatabaseFile = TRUE; - hRealFile = (HANDLE) hFile; - } - - return(hRealFile); -} - - BOOLEAN SetFileManCurrentDirectory( STR pcDirectory ) { try From eff1ccfe63370318b0c7c36db188f799ad065c26 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 13:45:44 +0300 Subject: [PATCH 058/120] Remove unused functions FileDebug() DirectoryExists() FileCopy() FileMove() --- Standard Gaming Platform/FileMan.cpp | 131 --------------------------- Standard Gaming Platform/FileMan.h | 6 -- 2 files changed, 137 deletions(-) diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index bc0d5442..1c43fc2a 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -191,24 +191,6 @@ void ShutdownFileManager( void ) UnRegisterDebugTopic( TOPIC_FILE_MANAGER, "File Manager" ); } -//************************************************************************** -// -// FileDebug -// -// To set whether or not we should print debug info. -// -// Parameter List : -// Return Value : -// Modification history : -// -// 24sep96:HJH ->creation -// -//************************************************************************** - -void FileDebug( BOOLEAN f ) -{ -// gfs.fDebug = f; -} //************************************************************************** // @@ -844,37 +826,6 @@ BOOLEAN GetFileManCurrentDirectory( STRING512 pcDirectory ) } -BOOLEAN DirectoryExists( STRING512 pcDirectory ) -{ - UINT32 uiAttribs; - DWORD uiLastError; - - uiAttribs = GetFileAttributes( pcDirectory ); - - if ( uiAttribs == 0xFFFFFFFF ) - { - // an error, make sure it's the right error - uiLastError = GetLastError(); - - if (uiLastError != ERROR_FILE_NOT_FOUND) - { - FastDebugMsg(String("DirectoryExists: ERROR - GetFileAttributes failed, error #%d on file %s", uiLastError, pcDirectory)); - } - } - else - { - // something's there, make sure it's a directory - if ( uiAttribs & FILE_ATTRIBUTE_DIRECTORY ) - { - return TRUE; - } - } - - // this could also mean that the name given is that of a file, or that an error occurred - return FALSE; -} - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Removes ALL FILES in the specified directory (and all subdirectories with their files if fRecursive is TRUE) // Use EraseDirectory() to simply delete directory contents without deleting the directory itself @@ -960,88 +911,6 @@ void GetFileClose( GETFILESTRUCT *pGFStruct ) } -BOOLEAN FileCopy(STR strSrcFile, STR strDstFile, BOOLEAN fFailIfExists) -{ - return(CopyFile(strSrcFile, strDstFile, fFailIfExists)); - -// Not needed, use Windows CopyFile -/* - HWFILE hFile; - UINT32 uiSize; - CHAR *pBuffer; - UINT32 uiBytesRead, uiBytesWritten; - - - // open source file - hFile = FileOpen(strSrcFile, FILE_ACCESS_READ, FALSE); - if (hFile == 0) - { - FastDebugMsg(String("FileCopy: FileOpen failed on Src file %s", strSrcFile)); - return(FALSE); - } - - // get its size - uiSize = FileGetSize(hFile); - if (uiSize == 0) - { - FastDebugMsg(String("FileCopy: size is 0, Src file %s", strSrcFile)); - FileClose(hFile); - return(FALSE); - } - - // allocate a buffer big enough to hold the entire file - pBuffer = MemAlloc(uiSize); - if (pBuffer == NULL) - { - FastDebugMsg(String("FileCopy: ERROR - MemAlloc pBuffer failed, size %d", uiSize)); - FileClose(hFile); - return(FALSE); - } - - // read the file into memory - if (!FileRead(hFile, pBuffer, uiSize, &uiBytesRead)) - { - FastDebugMsg(String("FileCopy: FileRead failed, file %s", strSrcFile)); - FileClose(hFile); - return(FALSE); - } - - // close source file - FileClose(hFile); - - - // open destination file - hFile = FileOpen(strDstFile, FILE_ACCESS_WRITE | FILE_CREATE_ALWAYS, FALSE); - if (hFile == 0) - { - FastDebugMsg(String("FileCopy: FileOpen failed on Dst file %s", strDstFile)); - return(FALSE); - } - - // write buffer to the destination file - if (!FileWrite(hFile, pBuffer, uiSize, &uiBytesWritten)) - { - FastDebugMsg(String("FileCopy: FileWrite failed, file %s", strDstFile)); - FileClose(hFile); - return(FALSE); - } - - // close destination file - FileClose(hFile); - - - MemFree(pBuffer); - pBuffer = NULL; - return(TRUE); -*/ -} - -BOOLEAN FileMove(STR strOldName, STR strNewName) -{ - // rename - return(MoveFile(strOldName, strNewName)); -} - //Additions by Kris Morness BOOLEAN FileSetAttributes( STR strFilename, UINT32 uiNewAttribs ) { diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index cf38d7b4..e84f872f 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -102,7 +102,6 @@ extern "C" { extern BOOLEAN InitializeFileManager( STR strIndexFilename ); extern void ShutdownFileManager( void ); -extern void FileDebug( BOOLEAN f ); BOOLEAN FileExists( STR strFilename ); @@ -130,8 +129,6 @@ BOOLEAN SetFileManCurrentDirectory( STR pcDirectory ); BOOLEAN GetFileManCurrentDirectory( STRING512 pcDirectory ); BOOLEAN GetExecutableDirectory( STRING512 pcDirectory ); -BOOLEAN DirectoryExists( STRING512 pcDirectory ); - // WARNING: THESE DELETE ALL FILES IN THE DIRECTORY ( and all subdirectories if fRecursive is TRUE!! ) BOOLEAN RemoveFileManDirectory( STRING512 pcDirectory, BOOLEAN fRecursive); BOOLEAN EraseDirectory( STRING512 pcDirectory); @@ -148,9 +145,6 @@ BOOLEAN GetFileFirst( CHAR8 * pSpec, GETFILESTRUCT *pGFStruct ); BOOLEAN GetFileNext( GETFILESTRUCT *pGFStruct ); void GetFileClose( GETFILESTRUCT *pGFStruct ); -BOOLEAN FileCopy(STR strSrcFile, STR strDstFile, BOOLEAN fFailIfExists); -BOOLEAN FileMove(STR strOldName, STR strNewName); - //Added by Kris Morness BOOLEAN FileSetAttributes( STR filename, UINT32 uiNewAttribs ); UINT32 FileGetAttributes( STR filename ); From c07f3f460bf4f8d6b55d89ddd65926262fb04818 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 13:59:28 +0300 Subject: [PATCH 059/120] Remove unused autosave and filetime functions --- SaveLoadGame.cpp | 63 --------------------- SaveLoadGame.h | 1 - Standard Gaming Platform/FileMan.cpp | 82 ---------------------------- Standard Gaming Platform/FileMan.h | 15 ----- 4 files changed, 161 deletions(-) diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index a013b455..dffa7337 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -9961,69 +9961,6 @@ void UpdateMercMercContractInfo() } } -INT8 GetNumberForAutoSave( BOOLEAN fLatestAutoSave ) -{ - CHAR zFileName1[MAX_PATH]; - CHAR zFileName2[MAX_PATH]; - HWFILE hFile; - BOOLEAN fFile1Exist, fFile2Exist; - SGP_FILETIME CreationTime1, LastAccessedTime1, LastWriteTime1; - SGP_FILETIME CreationTime2, LastAccessedTime2, LastWriteTime2; - - fFile1Exist = FALSE; - fFile2Exist = FALSE; - - - //The name of the file - sprintf( zFileName1, "%s\\Auto%02d.%S", gSaveDir, 0, pMessageStrings[ MSG_SAVEEXTENSION ] ); - sprintf( zFileName2, "%s\\Auto%02d.%S", gSaveDir, 1, pMessageStrings[ MSG_SAVEEXTENSION ] ); - - if( FileExists( zFileName1 ) ) - { - hFile = FileOpen( zFileName1, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - - GetFileManFileTime( hFile, &CreationTime1, &LastAccessedTime1, &LastWriteTime1 ); - - FileClose( hFile ); - - fFile1Exist = TRUE; - } - - if( FileExists( zFileName2 ) ) - { - hFile = FileOpen( zFileName2, FILE_ACCESS_READ | FILE_OPEN_EXISTING, FALSE ); - - GetFileManFileTime( hFile, &CreationTime2, &LastAccessedTime2, &LastWriteTime2 ); - - FileClose( hFile ); - - fFile2Exist = TRUE; - } - - if( !fFile1Exist && !fFile2Exist ) - return( -1 ); - else if( fFile1Exist && !fFile2Exist ) - { - if( fLatestAutoSave ) - return( 0 ); - else - return( -1 ); - } - else if( !fFile1Exist && fFile2Exist ) - { - if( fLatestAutoSave ) - return( 1 ); - else - return( -1 ); - } - else - { - if( CompareSGPFileTimes( &LastWriteTime1, &LastWriteTime2 ) > 0 ) - return( 0 ); - else - return( 1 ); - } -} void HandleOldBobbyRMailOrders() { diff --git a/SaveLoadGame.h b/SaveLoadGame.h index a1f9664a..b1a36271 100644 --- a/SaveLoadGame.h +++ b/SaveLoadGame.h @@ -99,7 +99,6 @@ void GetBestPossibleSectorXYZValues( INT16 *psSectorX, INT16 *psSectorY, INT8 *p extern UINT32 guiLastSaveGameNum; // The end turn auto save number (0 = Auto00.sav, 1 = Auto01.sav) -INT8 GetNumberForAutoSave( BOOLEAN fLatestAutoSave ); /*CHRISL: This function is designed to allow reading the save game file one field at a time. We currently save structures by saving a block of memory, but variables are stored in memory so that they fit neatly into a WORD resulting in the program automatically adding some padding. This padding is saved diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index 1c43fc2a..cd631004 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -911,76 +911,6 @@ void GetFileClose( GETFILESTRUCT *pGFStruct ) } -//Additions by Kris Morness -BOOLEAN FileSetAttributes( STR strFilename, UINT32 uiNewAttribs ) -{ - UINT32 uiFileAttrib = 0; - - if( uiNewAttribs & FILE_ATTRIBUTES_ARCHIVE ) - uiFileAttrib |= FILE_ATTRIBUTE_ARCHIVE; - - if( uiNewAttribs & FILE_ATTRIBUTES_HIDDEN ) - uiFileAttrib |= FILE_ATTRIBUTE_HIDDEN; - - if( uiNewAttribs & FILE_ATTRIBUTES_NORMAL ) - uiFileAttrib |= FILE_ATTRIBUTE_NORMAL; - - if( uiNewAttribs & FILE_ATTRIBUTES_OFFLINE ) - uiFileAttrib |= FILE_ATTRIBUTE_OFFLINE; - - if( uiNewAttribs & FILE_ATTRIBUTES_READONLY ) - uiFileAttrib |= FILE_ATTRIBUTE_READONLY; - - if( uiNewAttribs & FILE_ATTRIBUTES_SYSTEM ) - uiFileAttrib |= FILE_ATTRIBUTE_SYSTEM; - - if( uiNewAttribs & FILE_ATTRIBUTES_TEMPORARY ) - uiFileAttrib |= FILE_ATTRIBUTE_TEMPORARY; - - return SetFileAttributes( strFilename, uiFileAttrib ); -} - - -UINT32 FileGetAttributes( STR strFilename ) -{ - UINT32 uiAttribs = 0; - UINT32 uiFileAttrib = 0; - - uiAttribs = GetFileAttributes( strFilename ); - - if( uiAttribs == 0xFFFFFFFF ) - return( uiAttribs ); - - if( uiAttribs & FILE_ATTRIBUTE_ARCHIVE ) - uiFileAttrib |= FILE_ATTRIBUTES_ARCHIVE; - - if( uiAttribs & FILE_ATTRIBUTE_HIDDEN ) - uiFileAttrib |= FILE_ATTRIBUTES_HIDDEN; - - if( uiAttribs & FILE_ATTRIBUTE_NORMAL ) - uiFileAttrib |= FILE_ATTRIBUTES_NORMAL; - - if( uiAttribs & FILE_ATTRIBUTE_OFFLINE ) - uiFileAttrib |= FILE_ATTRIBUTES_OFFLINE; - - if( uiAttribs & FILE_ATTRIBUTE_READONLY ) - uiFileAttrib |= FILE_ATTRIBUTES_READONLY; - - if( uiAttribs & FILE_ATTRIBUTE_SYSTEM ) - uiFileAttrib |= FILE_ATTRIBUTES_SYSTEM; - - if( uiAttribs & FILE_ATTRIBUTE_TEMPORARY ) - uiFileAttrib |= FILE_ATTRIBUTES_TEMPORARY; - - if( uiAttribs & FILE_ATTRIBUTE_DIRECTORY ) - uiFileAttrib |= FILE_ATTRIBUTES_DIRECTORY; - - - - return( uiFileAttrib ); -} - - //returns true if at end of file, else false BOOLEAN FileCheckEndOfFile( HWFILE hFile ) { @@ -1011,18 +941,6 @@ BOOLEAN FileCheckEndOfFile( HWFILE hFile ) } - -BOOLEAN GetFileManFileTime( HWFILE hFile, SGP_FILETIME *pCreationTime, SGP_FILETIME *pLastAccessedTime, SGP_FILETIME *pLastWriteTime ) -{ - return( FALSE ); -} - - -INT32 CompareSGPFileTimes( SGP_FILETIME *pFirstFileTime, SGP_FILETIME *pSecondFileTime ) -{ - return( CompareFileTime( pFirstFileTime, pSecondFileTime ) ); -} - UINT32 FileSize(STR strFilename) { vfs::IBaseFile *pFile = getVFS()->getFile(vfs::Path(strFilename)); diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index e84f872f..1b21e8bc 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -145,24 +145,9 @@ BOOLEAN GetFileFirst( CHAR8 * pSpec, GETFILESTRUCT *pGFStruct ); BOOLEAN GetFileNext( GETFILESTRUCT *pGFStruct ); void GetFileClose( GETFILESTRUCT *pGFStruct ); -//Added by Kris Morness -BOOLEAN FileSetAttributes( STR filename, UINT32 uiNewAttribs ); -UINT32 FileGetAttributes( STR filename ); - //returns true if at end of file, else false BOOLEAN FileCheckEndOfFile( HWFILE hFile ); - - -BOOLEAN GetFileManFileTime( HWFILE hFile, SGP_FILETIME *pCreationTime, SGP_FILETIME *pLastAccessedTime, SGP_FILETIME *pLastWriteTime ); - - -// CompareSGPFileTimes() returns... -// -1 if the First file time is less than second file time. ( first file is older ) -// 0 First file time is equal to second file time. -// +1 First file time is greater than second file time ( first file is newer ). -INT32 CompareSGPFileTimes( SGP_FILETIME *pFirstFileTime, SGP_FILETIME *pSecondFileTime ); - // One call comparison of file times, allowing for a certain leeway in cases where // files times may be slightly different due to SourceSafe of copying BOOLEAN FileIsOlderThanFile(CHAR8 *pcFileName1, CHAR8 *pcFileName2, UINT32 ulNumSeconds); From b7f974f41b7e1deec03e023fb64788da4bcc35ae Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:01:15 +0300 Subject: [PATCH 060/120] Remove unused AddSubdirectoryToPath() & FileIsOlderThanFile() --- Standard Gaming Platform/FileMan.cpp | 71 ---------------------------- Standard Gaming Platform/FileMan.h | 8 ---- 2 files changed, 79 deletions(-) diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index cd631004..a127ee77 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -952,77 +952,6 @@ UINT32 FileSize(STR strFilename) } -//************************************************************************** -// -// AddSubdirectoryToPath -// -// Puts a subdirectory of the current working directory into the current -// task's system path. -// -// Parameter List : -// Return Value : -// Modification history : -// -// 10June98:DB ->creation -// -//************************************************************************** -BOOLEAN AddSubdirectoryToPath(CHAR8 *pDirectory) -{ -CHAR8 *pSystemPath; -CHAR8 *pPath; -UINT32 uiPathLen; - - // Check for NULL - if(!pDirectory) - return(FALSE); - - // Check for zero length string - if(!strlen(pDirectory)) - return(FALSE); - - if((pSystemPath=(CHAR8 *)MemAlloc(_MAX_PATH))==NULL) - return(FALSE); - - memset(pSystemPath, 0, _MAX_PATH); - - if((pPath=(CHAR8 *)MemAlloc(_MAX_PATH))==NULL) - { - MemFree(pSystemPath); - return(FALSE); - } - - memset(pPath, 0, _MAX_PATH); - - // Builds a path to the directory with the SR DLL files. - _getcwd(pPath, _MAX_PATH); - uiPathLen=strlen(pPath); - if(uiPathLen) - uiPathLen--; - if(pPath[uiPathLen]!='\\') - strcat(pPath, "\\"); - - strcat(pPath, pDirectory); - - // Appends it to the path for the current task - if(GetEnvironmentVariable("PATH", pSystemPath, _MAX_PATH)) - { - strcat(pSystemPath, ";"); - strcat(pSystemPath, pPath); - SetEnvironmentVariable("PATH", pSystemPath); - MemFree(pSystemPath); - MemFree(pPath); - return(TRUE); - } - else - { - MemFree(pSystemPath); - MemFree(pPath); - return(FALSE); - } - -} - - UINT32 GetFreeSpaceOnHardDriveWhereGameIsRunningFrom( ) { STRING512 zExecDir; diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index 1b21e8bc..428b213b 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -148,14 +148,6 @@ void GetFileClose( GETFILESTRUCT *pGFStruct ); //returns true if at end of file, else false BOOLEAN FileCheckEndOfFile( HWFILE hFile ); -// One call comparison of file times, allowing for a certain leeway in cases where -// files times may be slightly different due to SourceSafe of copying -BOOLEAN FileIsOlderThanFile(CHAR8 *pcFileName1, CHAR8 *pcFileName2, UINT32 ulNumSeconds); - - -BOOLEAN AddSubdirectoryToPath(CHAR8 *pDirectory); - - //Gets the amount of free space on the hard drive that the main executeablt is runnning from UINT32 GetFreeSpaceOnHardDriveWhereGameIsRunningFrom( ); From db0787b5a37116b7b686d9b0071690369f51da89 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:06:02 +0300 Subject: [PATCH 061/120] Remove unused functions GetFreeSpaceOnHardDriveWhereGameIsRunningFrom() GetFreeSpaceOnHardDrive() FileReadLine() <- non VFS version DoesUserHaveEnoughHardDriveSpace() --- SaveLoadGame.cpp | 15 ------- SaveLoadGame.h | 2 - Standard Gaming Platform/FileMan.cpp | 65 ---------------------------- Standard Gaming Platform/FileMan.h | 7 --- 4 files changed, 89 deletions(-) diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index dffa7337..7d8cc015 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -9683,21 +9683,6 @@ BOOLEAN SaveMeanwhileDefsFromSaveGameFile( HWFILE hFile ) return( TRUE ); } -BOOLEAN DoesUserHaveEnoughHardDriveSpace() -{ - UINT32 uiBytesFree=0; - - uiBytesFree = GetFreeSpaceOnHardDriveWhereGameIsRunningFrom( ); - - //check to see if there is enough hard drive space - if( uiBytesFree < REQUIRED_FREE_SPACE ) - { - return( FALSE ); - } - - return( TRUE ); -} - #ifdef JA2BETAVERSION void InitShutDownMapTempFileTest( BOOLEAN fInit, STR pNameOfFile, UINT8 ubSaveGameID ) diff --git a/SaveLoadGame.h b/SaveLoadGame.h index b1a36271..3cc011f6 100644 --- a/SaveLoadGame.h +++ b/SaveLoadGame.h @@ -93,8 +93,6 @@ BOOLEAN CopySavedSoldierInfoToNewSoldier( SOLDIERTYPE *pDestSourceInfo, SOLDIERT BOOLEAN SaveFilesToSavedGame( STR pSrcFileName, HWFILE hFile ); BOOLEAN LoadFilesFromSavedGame( STR pSrcFileName, HWFILE hFile ); -BOOLEAN DoesUserHaveEnoughHardDriveSpace(); - void GetBestPossibleSectorXYZValues( INT16 *psSectorX, INT16 *psSectorY, INT8 *pbSectorZ ); diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index a127ee77..6ab2b70e 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -470,22 +470,6 @@ BOOLEAN FileReadLine( HWFILE hFile, std::string* pDest ) return FALSE; } -BOOLEAN FileReadLine( HWFILE hFile, STR8 pDest, UINT32 uiDestSize, UINT32 *puiBytesRead ) -{ - std::string sBuffer; - BOOLEAN result = (pDest != NULL) && FileReadLine( hFile, &sBuffer ); - if ( result ) - { - if ( puiBytesRead ) - *puiBytesRead = sBuffer.length(); - - UINT32 uiCountToCopy = min( sBuffer.length(), uiDestSize - 1 ); - sBuffer.copy( pDest, uiCountToCopy ); - pDest[uiCountToCopy] = '\0'; // method copy() does not put a null-terminator - } - return result; -} - //************************************************************************** // // FileWrite @@ -952,55 +936,6 @@ UINT32 FileSize(STR strFilename) } -UINT32 GetFreeSpaceOnHardDriveWhereGameIsRunningFrom( ) -{ - STRING512 zExecDir; - STRING512 zDrive; - STRING512 zDir; - STRING512 zFileName; - STRING512 zExt; - - UINT32 uiFreeSpace = 0; - - GetExecutableDirectory( zExecDir ); - - //get the drive letter from the exec dir - _splitpath( zExecDir, zDrive, zDir, zFileName, zExt); - - sprintf( zDrive, "%s\\", zDrive ); - - uiFreeSpace = GetFreeSpaceOnHardDrive( zDrive ); - - return( uiFreeSpace ); -} - - - - -UINT32 GetFreeSpaceOnHardDrive( STR pzDriveLetter ) -{ - UINT32 uiBytesFree=0; - - UINT32 uiSectorsPerCluster=0; - UINT32 uiBytesPerSector=0; - UINT32 uiNumberOfFreeClusters=0; - UINT32 uiTotalNumberOfClusters=0; - - if( !GetDiskFreeSpace( pzDriveLetter, (LPDWORD) &uiSectorsPerCluster, (LPDWORD) &uiBytesPerSector, - (LPDWORD) &uiNumberOfFreeClusters, (LPDWORD) &uiTotalNumberOfClusters ) ) - { - UINT32 uiLastError = GetLastError(); - char zString[1024]; - FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, 0, uiLastError, 0, zString, 1024, NULL); - - return( TRUE ); - } - - uiBytesFree = uiBytesPerSector * uiNumberOfFreeClusters * uiSectorsPerCluster; - - return( uiBytesFree ); -} - // Flugente: simple wrapper to check whether an audio file in mp3/ogg/wav format exists BOOLEAN SoundFileExists( STR strFilename, STR zFoundFilename ) { diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index 428b213b..ef77be56 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -113,7 +113,6 @@ extern void FileClose( HWFILE ); extern BOOLEAN FileRead( HWFILE hFile, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiBytesRead ); extern BOOLEAN FileReadLine( HWFILE hFile, std::string* pDest ); -extern BOOLEAN FileReadLine( HWFILE hFile, STR8 pDest, UINT32 uiDestSize, UINT32 *puiBytesRead ); extern BOOLEAN FileWrite( HWFILE hFile, PTR pDest, UINT32 uiBytesToWrite, UINT32 *puiBytesWritten ); extern BOOLEAN FileLoad( STR filename, PTR pDest, UINT32 uiBytesToRead, UINT32 *puiBytesRead ); @@ -148,12 +147,6 @@ void GetFileClose( GETFILESTRUCT *pGFStruct ); //returns true if at end of file, else false BOOLEAN FileCheckEndOfFile( HWFILE hFile ); -//Gets the amount of free space on the hard drive that the main executeablt is runnning from -UINT32 GetFreeSpaceOnHardDriveWhereGameIsRunningFrom( ); - -//Gets the free hard drive space from the drive letter passed in. It has to be the root dir. ( eg. c:\ ) -UINT32 GetFreeSpaceOnHardDrive( STR pzDriveLetter ); - // Flugente: simple wrapper to check whether an audio file in mp3/ogg/wav format exists BOOLEAN SoundFileExists( STR strFilename, STR zFoundFilename ); From 1483f15832c0349c5e72b038eb15f9634a6cae58 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:08:48 +0300 Subject: [PATCH 062/120] Remove unused globals --- Standard Gaming Platform/FileMan.cpp | 5 ----- Standard Gaming Platform/FileMan.h | 4 ---- 2 files changed, 9 deletions(-) diff --git a/Standard Gaming Platform/FileMan.cpp b/Standard Gaming Platform/FileMan.cpp index 6ab2b70e..f392d6d8 100644 --- a/Standard Gaming Platform/FileMan.cpp +++ b/Standard Gaming Platform/FileMan.cpp @@ -132,11 +132,6 @@ HANDLE hFindInfoHandle[20] = {INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE }; -// Snap: At program launch we build two directory catalogues: -// one for the default Data directory, the other for the custom Data directory. -TFileCat gDefaultDataCat; // Init in InitializeStandardGamingPlatform (sgp.cpp) -TFileCat gCustomDataCat; // Init in InitializeStandardGamingPlatform (sgp.cpp) - //************************************************************************** // // Function Prototypes diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index ef77be56..8305303a 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -83,10 +83,6 @@ typedef FILETIME SGP_FILETIME; // //************************************************************************** -// Snap: At program launch we build two directory catalogues: -// one for the default Data directory, the other for the custom Data directory. -extern TFileCat gDefaultDataCat; // Init in InitializeStandardGamingPlatform (sgp.cpp) -extern TFileCat gCustomDataCat; // Init in InitializeStandardGamingPlatform (sgp.cpp) //************************************************************************** // From 5a7ef1930fa12b35ce88e75fa2d9fded2402ec33 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:10:34 +0300 Subject: [PATCH 063/120] Remove unused defines --- Standard Gaming Platform/FileMan.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index 8305303a..ee9b68f4 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -60,17 +60,6 @@ #define FILE_IS_OFFLINE 256 - -//File Attributes settings -#define FILE_ATTRIBUTES_ARCHIVE FILE_ATTRIBUTE_ARCHIVE -#define FILE_ATTRIBUTES_HIDDEN FILE_ATTRIBUTE_HIDDEN -#define FILE_ATTRIBUTES_NORMAL FILE_ATTRIBUTE_NORMAL -#define FILE_ATTRIBUTES_OFFLINE FILE_ATTRIBUTE_OFFLINE -#define FILE_ATTRIBUTES_READONLY FILE_ATTRIBUTE_READONLY -#define FILE_ATTRIBUTES_SYSTEM FILE_ATTRIBUTE_SYSTEM -#define FILE_ATTRIBUTES_TEMPORARY FILE_ATTRIBUTE_TEMPORARY -#define FILE_ATTRIBUTES_DIRECTORY FILE_ATTRIBUTE_DIRECTORY - // Snap, Kaiden: This define duplicates a standard MFC define // Added to resolve some intractable issue with MSVC6 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) From d43a597423213aef22206435959e6001ada05f14 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:18:52 +0300 Subject: [PATCH 064/120] Remove commented out ifdefs --- Standard Gaming Platform/FileMan.h | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index ee9b68f4..5fac1d92 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -78,12 +78,6 @@ typedef FILETIME SGP_FILETIME; // Function Prototypes // //************************************************************************** -/* -#ifdef __cplusplus -extern "C" { -#endif -*/ - extern BOOLEAN InitializeFileManager( STR strIndexFilename ); extern void ShutdownFileManager( void ); @@ -134,11 +128,4 @@ BOOLEAN FileCheckEndOfFile( HWFILE hFile ); // Flugente: simple wrapper to check whether an audio file in mp3/ogg/wav format exists BOOLEAN SoundFileExists( STR strFilename, STR zFoundFilename ); - -/* -#ifdef __cplusplus -} -#endif -*/ - #endif From 5b635784cd11b1941a841062e28f825909afc590 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:29:15 +0300 Subject: [PATCH 065/120] Remove FileCat.cpp & .h Not used anywhere in the code. Moved ChompSlash from FileCat.cpp to image.cpp, as the only two references besides ones in filecat.cpp for the function were in there. The references are inside an #ifdef 0 block so they are not compiled currently, but this should prevent them from not working IF we ever enable them --- Standard Gaming Platform/CMakeLists.txt | 1 - Standard Gaming Platform/FileCat.cpp | 100 ------------------------ Standard Gaming Platform/FileCat.h | 48 ------------ Standard Gaming Platform/FileMan.h | 2 - ext/export/src/export/sti/Image.cpp | 11 +++ 5 files changed, 11 insertions(+), 151 deletions(-) delete mode 100644 Standard Gaming Platform/FileCat.cpp delete mode 100644 Standard Gaming Platform/FileCat.h diff --git a/Standard Gaming Platform/CMakeLists.txt b/Standard Gaming Platform/CMakeLists.txt index 70404804..f56cf667 100644 --- a/Standard Gaming Platform/CMakeLists.txt +++ b/Standard Gaming Platform/CMakeLists.txt @@ -9,7 +9,6 @@ set(SGPSrc "${CMAKE_CURRENT_SOURCE_DIR}/DirectDraw Calls.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/DirectX Common.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/English.cpp" -"${CMAKE_CURRENT_SOURCE_DIR}/FileCat.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/FileMan.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Flic.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Font.cpp" diff --git a/Standard Gaming Platform/FileCat.cpp b/Standard Gaming Platform/FileCat.cpp deleted file mode 100644 index a977d597..00000000 --- a/Standard Gaming Platform/FileCat.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -// Snap: Implementation of the TFileCat class -// -#include "FileCat.h" -#include "readdir.h" - - -// Remove a slash or backslash (if any) from the end of a string -void ChompSlash(std::string& s) -{ - if ( s.empty() ) return; - - if ( *s.rbegin() == '\\' || *s.rbegin() == '/' ) { - s.erase( s.length() - 1 ); - } -} - - -// Build a new file catalogue by recursively traversing the root directory -void TFileCat::NewCat(std::string root) -{ - fRootDir = root; - ChompSlash(fRootDir); - - fFileCat.clear(); - - TraverseDir(fRootDir); -} - - -// Look for a given file in the catalogue -// Unless pathIncludesRoot == true, will prepend the root directory to path -bool TFileCat::FindFile(std::string path, bool pathIncludesRoot) const -{ - if (pathIncludesRoot) return fFileCat.find(path) != fFileCat.end(); - else return fFileCat.find(fRootDir + '\\' + path) != fFileCat.end(); -} - - -// Delete a given file from the catalogue -// Unless pathIncludesRoot == true, will prepend the root directory to path -size_t TFileCat::RemoveFile(std::string path, bool pathIncludesRoot) -{ - if (pathIncludesRoot) return fFileCat.erase(path); - else return fFileCat.erase(fRootDir + '\\' + path); -} - - -// Delete all files from a given directory in the catalogue -// Unless pathIncludesRoot == true, will prepend the root directory to path -size_t TFileCat::RemoveDir(std::string dir, bool pathIncludesRoot) -{ - if ( !pathIncludesRoot ) dir = fRootDir + '\\' + dir; - ChompSlash(dir); - std::string dirlower = dir + '\\'; - std::string dirupper = dir + char('\\'+1); - - TCatalogue::iterator upper = fFileCat.upper_bound(dirupper); - TCatalogue::iterator lower; - - int deleted = 0; - - while ( ( lower = fFileCat.lower_bound(dirlower) ) != upper) { - fFileCat.erase(lower); - deleted++; - } - - return deleted; -} - - -// Recursively traverse a directory, adding regular files to the catalogue -void TFileCat::TraverseDir(std::string dir, int depth) -{ - using std::string; - static string dot( "."); - static string dotdot( ".."); - static string svn( ".svn"); - - if (!dir.empty()) dir += '\\'; - - TReadDir readDir((dir + "*").c_str()); - - char const* fileName; - unsigned attrib; - - while ( readDir.NextFile(fileName, attrib) ) { - if (dot == fileName || dotdot == fileName || svn == fileName) continue; - - string fullPath = dir + fileName; - - if (attrib & FILE_ATTRIBUTE_DIRECTORY) { - if (depth < 0) TraverseDir(fullPath); - else if (depth > 0) TraverseDir(fullPath, depth-1); - } - else { - fFileCat.insert(fullPath); - } - } -} diff --git a/Standard Gaming Platform/FileCat.h b/Standard Gaming Platform/FileCat.h deleted file mode 100644 index 38d1fc27..00000000 --- a/Standard Gaming Platform/FileCat.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// Snap: Declaration of the TFileCat class -// -// This class catalogues files in a directory and all its subdirectories -// -#ifndef FILECAT_H -#define FILECAT_H - -#include "stringicmp.h" -#include -#include - - -class TFileCat { -public: - - TFileCat(std::string root) { NewCat(root); } - TFileCat() {} - - // Build a new file catalogue by recursively traversing the root directory - void NewCat(std::string root); - - std::string GetRootDir() const { return fRootDir; } - - // Look for a given file in the catalogue - // Unless pathIncludesRoot == true, will prepend the root directory to path - bool FindFile(std::string path, bool pathIncludesRoot = false) const; - - // Delete a given file from the catalogue - // Unless pathIncludesRoot == true, will prepend the root directory to path - size_t RemoveFile(std::string path, bool pathIncludesRoot = false); - - // Delete all files from a given directory in the catalogue - // Unless pathIncludesRoot == true, will prepend the root directory to path - size_t RemoveDir(std::string dir, bool pathIncludesRoot = false); - -private: - - typedef std::set TCatalogue; - - std::string fRootDir; - TCatalogue fFileCat; - - // Recursively traverse a directory, adding regular files to the catalogue - void TraverseDir(std::string dir, int depth = -1); -}; - -#endif // FILECAT_H diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index 5fac1d92..bc860fc8 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -20,10 +20,8 @@ //************************************************************************** #include "types.h" - #include "Windows.h" -#include "FileCat.h" //************************************************************************** diff --git a/ext/export/src/export/sti/Image.cpp b/ext/export/src/export/sti/Image.cpp index cc719d69..2db90738 100644 --- a/ext/export/src/export/sti/Image.cpp +++ b/ext/export/src/export/sti/Image.cpp @@ -406,7 +406,18 @@ vfs::Path CreateFileName(vfs::Path const& sOutPathName, vfs::Path const& sFileNa outPath += vfs::Path(fullpath.str()); return outPath; } + #if 0 +// Remove a slash or backslash (if any) from the end of a string +void ChompSlash(std::string& s) +{ + if (s.empty()) return; + + if (*s.rbegin() == '\\' || *s.rbegin() == '/') { + s.erase(s.length() - 1); + } +} + bool CImage::WriteAsBMPs(vfs_string sOutPathName) { if(!this->LoadData()) From 2849590ef28a11f2ed90696c38f23893d8496ac8 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:36:23 +0300 Subject: [PATCH 066/120] Remove readdir.cpp & h Unused --- Standard Gaming Platform/CMakeLists.txt | 1 - Standard Gaming Platform/readdir.cpp | 22 -------------------- Standard Gaming Platform/readdir.h | 27 ------------------------- 3 files changed, 50 deletions(-) delete mode 100644 Standard Gaming Platform/readdir.cpp delete mode 100644 Standard Gaming Platform/readdir.h diff --git a/Standard Gaming Platform/CMakeLists.txt b/Standard Gaming Platform/CMakeLists.txt index f56cf667..c39224f5 100644 --- a/Standard Gaming Platform/CMakeLists.txt +++ b/Standard Gaming Platform/CMakeLists.txt @@ -24,7 +24,6 @@ set(SGPSrc "${CMAKE_CURRENT_SOURCE_DIR}/PCX.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/PngLoader.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Random.cpp" -"${CMAKE_CURRENT_SOURCE_DIR}/readdir.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/RegInst.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/sgp.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/sgp_logger.cpp" diff --git a/Standard Gaming Platform/readdir.cpp b/Standard Gaming Platform/readdir.cpp deleted file mode 100644 index 57a8c852..00000000 --- a/Standard Gaming Platform/readdir.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// -// Snap: Implementation of the TReadDir class -// This class reads the contents of a directory file-by-file -// -#include "readdir.h" - -TReadDir::TReadDir(char const* searchPattern) -{ - fSearchHandle = FindFirstFile(searchPattern, &fFileInfo); - fFirstRequest = true; -} - - -bool TReadDir::NextFile(char const* &fileName, unsigned &attrib) -{ - if (fSearchHandle == INVALID_HANDLE_VALUE) return false; - if (fFirstRequest) fFirstRequest = false; - else if ( !FindNextFile(fSearchHandle, &fFileInfo) ) return false; - fileName = fFileInfo.cFileName; - attrib = fFileInfo.dwFileAttributes; - return true; -} diff --git a/Standard Gaming Platform/readdir.h b/Standard Gaming Platform/readdir.h deleted file mode 100644 index b98ebae1..00000000 --- a/Standard Gaming Platform/readdir.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// Snap: Declaration of the TReadDir class -// This class reads the contents of a directory file-by-file -// -#ifndef READDIR_H -#define READDIR_H - -#include - -class TReadDir { -public: - - TReadDir(char const* searchPattern); - - ~TReadDir() { FindClose(fSearchHandle); } - - bool NextFile(char const* &fileName, unsigned &attrib); - -private: - - HANDLE fSearchHandle; - WIN32_FIND_DATA fFileInfo; - bool fFirstRequest; -}; - - -#endif // #ifndef READDIR_H \ No newline at end of file From 58a682db89e693f8281880d15c06f2f3ab725f8e Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:42:09 +0300 Subject: [PATCH 067/120] Remove flic.cpp & h Not used anywhere and even inside the .cpp functions such as FlicPlay() had everything commented out and replaced with "return 1" --- Standard Gaming Platform/CMakeLists.txt | 1 - Standard Gaming Platform/Flic.cpp | 1696 ----------------------- Standard Gaming Platform/flic.h | 224 --- 3 files changed, 1921 deletions(-) delete mode 100644 Standard Gaming Platform/Flic.cpp delete mode 100644 Standard Gaming Platform/flic.h diff --git a/Standard Gaming Platform/CMakeLists.txt b/Standard Gaming Platform/CMakeLists.txt index c39224f5..4d0137a5 100644 --- a/Standard Gaming Platform/CMakeLists.txt +++ b/Standard Gaming Platform/CMakeLists.txt @@ -10,7 +10,6 @@ set(SGPSrc "${CMAKE_CURRENT_SOURCE_DIR}/DirectX Common.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/English.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/FileMan.cpp" -"${CMAKE_CURRENT_SOURCE_DIR}/Flic.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Font.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/himage.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/impTGA.cpp" diff --git a/Standard Gaming Platform/Flic.cpp b/Standard Gaming Platform/Flic.cpp deleted file mode 100644 index 7d278a25..00000000 --- a/Standard Gaming Platform/Flic.cpp +++ /dev/null @@ -1,1696 +0,0 @@ -//************************************************************************** -// -// Filename : flic.c -// -// Purpose : Display System for .flc and .fli Flic Files -// -// This program is derived from the program decribed in the article "The -// Flic File Format" on page 18 of the March 1993 edition of Dr. Dobb's -// Journal. It was restructured from the top down to meet the -// requirements of Sir-Tech. The high level routines were designed to -// provided easy integration with existing applications. Except for a few -// identifiers, the low level routines were not modified. -// -// All of the code for these routines in contained in this file and the -// file "flic.h". -// -// Modification history : -// -// 06-09-94:??? - Creation -// ???:David Smoth - ??? -// ???:Bret Rowdon for RIO/GORGE - added 640x480 SVGA support -// 05-11jun96:HJH - added routines for bitmap use, and -// other utilities -// 08-May-97 ARM Adapted for Win95 Standard Gaming Platform -// -//************************************************************************** - -//************************************************************************** -// -// Includes -// -//************************************************************************** - -#include -#include "flic.h" -#include "windows.h" -#include "types.h" -#include "wcheck.h" - -//************************************************************************** -// -// Variables -// -//************************************************************************** - -//Flic flic; -char pcxbuf[(640*480)]; -char FlicPal[768]; - -//extern char buffer[(640*480)]; -//extern char buffer2[(640*480)]; - -//************************************************************************** -// -// Function prototypes. -// -//************************************************************************** - -static ErrCode flic_next_frame(Flic *flic, BOOL fDecode); - -//************************************************************************** -// -// Functions -// -//************************************************************************** - -//************************************************************************** -// -// Low level Functions -// -//************************************************************************** - -//************************************************************************** -// -// screen_put_dot -// -// Set one dot. -// -// Parameter List : -// Return Value : -// Modification history : -// -//************************************************************************** - -static void screen_put_dot(FlicScreen *s, int x, int y, Pixel color) -{ - // First clip it. - if (x < 0 || y < 0 || x >= s->width || y >= s->height) - return; - - // Then set it. - s->pixels[(unsigned)(s->height-y-1) * s->width + x] = color; -} - -//************************************************************************** -// -// line_clip -// -// Clip a horizontal line segment so that it fits on the screen. -// Return FALSE if clipped out entirely. -// -// Parameter List : -// Return Value : -// Modification history : -// -//************************************************************************** - -static Boolean line_clip(FlicScreen *s, int *px, int *py, int *pwidth) -{ - int x = *px; - int y = *py; - int width = *pwidth; - int xend = x + width; - - if (y < 0 || y >= s->height || xend < 0 || x >= s->width) - return FALSE; /* Clipped off screen. */ - if (x < 0) - { - *pwidth = width = width + x; /* and shortens width. */ - *px = 0; - } - if (xend > s->width) - { - *pwidth = width = width - (xend - s->width); - } - if (width < 0) - return FALSE; - return TRUE; -} - -//************************************************************************** -// -// oldscreen_copy_seg -// -// Copy pixels from memory into screen. -// -// Parameter List : -// Return Value : -// Modification history : -// -//************************************************************************** - -static void oldscreen_copy_seg(FlicScreen *s, int x, int y, Pixel *pixels, int count) -{ - Pixel *pt; - //int xend; - int unclipped_x = x; - int dx; - - // First let's do some clipping. - if (!line_clip(s, &x, &y, &count)) - return; - - dx = x - unclipped_x; // Clipping change in start position. - if (dx != 0) - pixels += dx; // Advance over clipped pixels. - - // Calculate start screen address. - //pt = s->pixels + (unsigned)y * (unsigned)s->width + (unsigned)x; - pt = s->pixels + (unsigned)(s->height-y-1) * (unsigned)s->width + (unsigned)x; - - // Copy pixels to display. - while (--count >= 0) - *pt++ = *pixels++; -} - -//************************************************************************** -// -// screen_repeat_one -// -// Draw a horizontal line of a solid color -// -// Parameter List : -// -// FlicScreen *s -> screen to write to -// int x -> x position to write to -// int y -> y position to write to -// Pixel color -> colour to write -// int count -> how many times to write -// -// Return Value : -// -// Modification history : -// -// 01jun96:HJH -> reversed the screen up and down so that the -// bitmaps wouldn't come out upside down (I put in -// the "s->height -") -// -//************************************************************************** - -static void screen_repeat_one(FlicScreen *s, int x, int y, Pixel color, int count) -{ - Pixel *pt; - - // First let's do some clipping. - if (!line_clip(s, &x, &y, &count)) - return; - - // Calculate start screen address. - pt = s->pixels + (unsigned)(s->height-y-1) * (unsigned)s->width + (unsigned)x; - - // Repeat pixel on display. - while (--count >= 0) - *pt++ = color; -} - -//************************************************************************** -// -// screen_repeat_two -// -// Repeat 2 pixels count times on screen. -// -// Parameter List : -// Return Value : -// Modification history : -// -//************************************************************************** - -static void screen_repeat_two(FlicScreen *s, int x, int y, Pixels2 pixels2, int count) -{ - Pixels2 *pt; - int is_odd; - - // First let's do some clipping. - count <<= 1; // Convert from word to pixel count. - if (!line_clip(s, &x, &y, &count)) - return; - is_odd = (count&1); // Did it turn odd after clipping? Ack! - count >>= 1; // Convert back to word count. - - // Calculate start screen address. - pt = (Pixels2 *)(s->pixels + (unsigned)(s->height-y-1) * (unsigned)s->width + (unsigned)x); - - while (--count >= 0) // Go set screen 2 pixels at a time. - *pt++ = pixels2; - - if (is_odd) // Deal with pixel at end of screen if needed. - { - Pixel *end = (Pixel *)pt; - *end = pixels2.pixels[0]; - } -} - -//************************************************************************** -// -// screen_put_colors -// -// Set count colors in color map starting at start. RGB values -// go from 0 to 255. -// -// Parameter List : -// -// FlicScreen *s -> screen data -// int start -> start position -// Colour *colors -> the colors, of course -// int count -> how many -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static void screen_put_colors(FlicScreen *s, int start, Colour *colors, int count) -{ - int end = start + count; - int ix; - - for (ix = start; ix < end; ++ix) - { - FlicPal[ix*3]=colors->r>>2; - FlicPal[ix*3+1]=colors->g>>2; - FlicPal[ix*3+2]=colors->b>>2; - ++colors; - } -} - -//************************************************************************** -// -// screen_put_colors_64 -// -// Set count colors in color map starting at start. RGB values -// go from 0 to 64. */ -// -// Parameter List : -// -// FlicScreen *s -> screen data -// int start -> start position -// Colour *colors -> the colors, of course -// int count -> how many -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static void screen_put_colors_64(FlicScreen *s, int start, Colour *colors, int count) -{ - int end = start + count; - int ix; - - for (ix = start; ix < end; ++ix) - { - FlicPal[ix*3]=colors->r; - FlicPal[ix*3+1]=colors->g; - FlicPal[ix*3+2]=colors->b; - - ++colors; - } -} - -//************************************************************************** -// -// decode_byte_run -// -// Byte-run-length decompression. -// -// Parameter List : -// -// Uchar *data -> data to be decoded -// Flic *flic -> flic data containing where to decode to -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static void decode_byte_run(Uchar *data, Flic *flic) -{ - int x,y; - int width = flic->head.width; - int height = flic->head.height; - int psize; // was char -> HJH - Char *cpt = (Char *)data; - int end; - - y = flic->yoff; - end = flic->xoff + width; - while (--height >= 0) - { - x = flic->xoff; - cpt += 1; /* skip over obsolete opcount byte */ - psize = 0; - while ((x+=psize) < end) - { - psize = (char)(*cpt++); - if (psize >= 0) - { - screen_repeat_one(&flic->screen, x, y, *cpt++, psize); - } - else - { - psize = -psize; - oldscreen_copy_seg(&(flic->screen),(long) x,(long) y, (unsigned char *)cpt, (long)psize); - cpt += psize; - } - } - y++; - } -} - -//************************************************************************** -// -// decode_delta_fli -// -// Fli style delta decompression. -// -// Parameter List : -// -// Uchar *data -> data to be decoded -// Flic *flic -> flic data containing where to decode to -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static void decode_delta_fli(Uchar *data, Flic *flic) -{ - int xorg = flic->xoff; - int yorg = flic->yoff; - Short *wpt = (Short *)data; - Uchar *cpt = (Uchar *)(wpt + 2); - int x,y; - Short lines; - Uchar opcount; - Char psize; - - y = yorg + *wpt++; - lines = *wpt; - while (--lines >= 0) - { - x = xorg; - opcount = *cpt++; - while (opcount > 0) - { - x += *cpt++; - psize = *cpt++; - if (psize < 0) - { - psize = -psize; - screen_repeat_one(&flic->screen, x, y, *cpt++, psize); - x += psize; - opcount-=1; - } - else - { - oldscreen_copy_seg(&(flic->screen), (long)x, (long)y, (unsigned char *)cpt,(long) psize); - cpt += psize; - x += psize; - opcount -= 1; - } - } - y++; - } -} - -//************************************************************************** -// -// decode_delta_flc -// -// Flc-style delta decompression. The data is word oriented though -// a lot of the control info (how to skip, how many words to -// copy) are byte oriented still to save space. -// -// Parameter List : -// -// Uchar *data -> data to be decoded -// Flic *flic -> flic data containing where to decode to -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static void decode_delta_flc(Uchar *data, Flic *flic) -{ - int xorg = flic->xoff; - int yorg = flic->yoff; - int width = flic->head.width; - int x,y; - Short lp_count; - Short opcount; - int psize; - union {Short *w; Uchar *ub; Char *b; Pixels2 *p2;} wpt; - int lastx; - - - lastx = xorg + width - 1; - wpt.ub = data; - lp_count = *wpt.w++; - y = yorg; - goto LPACK; - -SKIPLINES: /* Advance over some lines. */ - y -= opcount; - -LPACK: /* do next line */ - if ((opcount = *wpt.w++) >= 0) - goto DO_SS2OPS; - if( ((Ushort)opcount) & 0x4000) /* skip lines */ - goto SKIPLINES; - screen_put_dot(&flic->screen,(Uchar)opcount,lastx,(Pixel)y); /* put dot at eol with low byte */ - if((opcount = *wpt.w++) == 0) - { - ++y; - if (--lp_count > 0) - goto LPACK; - goto OUTT; - } -DO_SS2OPS: - x = xorg; - -PPACK: /* do next packet */ - x += *wpt.ub++; - psize = *wpt.b++; - if ((psize += psize) >= 0) - { - oldscreen_copy_seg(&(flic->screen), (long)x, (long)y, (unsigned char *)wpt.ub,(long) psize); - x += psize; - wpt.ub += psize; - if (--opcount != 0) - goto PPACK; - ++y; - if (--lp_count > 0) - goto LPACK; - } - else - { - psize = -psize; - screen_repeat_two(&flic->screen, x, y, *wpt.p2++, psize>>1); - x += psize; - if (--opcount != 0) - goto PPACK; - ++y; - if (--lp_count > 0) - goto LPACK; - } -OUTT: - return; -} - -//************************************************************************** -// -// decode_black -// -// Decode a BLACK chunk. Set frame to solid color 0 one -// line at a time. -// -// Parameter List : -// -// Uchar *data -> data to be decoded -// Flic *flic -> flic data containing where to decode to -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static void decode_black(Uchar *data, Flic *flic) -{ - Pixels2 black; - int i; - int height = flic->head.height; - int width = flic->head.width; - int x = flic->xoff; - int y = flic->yoff; - - black.pixels[0] = black.pixels[1] = 0; - for (i=0; iscreen, x, y+i, black, width/2); - if (width & 1) /* if odd set last pixel */ - screen_put_dot(&flic->screen, x+width-1, y+i, 0); - } -} - -//************************************************************************** -// -// decode_literal -// -// Decode a LITERAL chunk. Just copy data to screen one line at -// a time. -// -// Parameter List : -// -// Uchar *data -> data to be decoded -// Flic *flic -> flic data containing where to decode to -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static void decode_literal(Uchar *data, Flic *flic) -{ - int i; - int height = flic->head.height; - int width = flic->head.width; - int x = flic->xoff; - int y = flic->yoff; - - for (i=0; iscreen),(long) x,(long)(y+i), (unsigned char *)data,(long) width); - data += width; - } -} - - -typedef void ColorOut(FlicScreen *s, int start, Colour *colors, int count); - /* This is the type of output parameter to our decode_color below. - * Not coincedently screen_put_color is of this type. */ - - -//************************************************************************** -// -// decode_color -// -// Decode color map. Put results into output. The two color -// compressions are identical except for whether the RGB values -// are 0-63 or 0-255. Passing in an output that does the appropriate -// shifting on the way to the real pallete lets us use the same -// code for both COLOR_64 and COLOR_256 compression. -// -// Parameter List : -// -// Uchar *data -> data to decode -// Flic *flic -> the flic -// ColorOut *output -> place to put decoded data -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static void decode_color(Uchar *data, Flic *flic, ColorOut *output) -{ - int start = 0; - Uchar *cbuf = (Uchar *)data; - Short *wp = (Short *)cbuf; - Short ops; - int count; - - ops = *wp; - cbuf += sizeof(*wp); - while (--ops >= 0) - { - start += *cbuf++; - if ((count = *cbuf++) == 0) - count = 256; - (*output)(&flic->screen, start, (Colour *)cbuf, count); - cbuf += 3*count; - start += count; - } -} - -//************************************************************************** -// -// decode_color_256 -// -// Decode COLOR_256 chunk. -// -// Parameter List : -// -// Uchar *data -> data to decode -// Flic *flic -> the flic -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static void decode_color_256(Uchar *data, Flic *flic) -{ - decode_color(data, flic, screen_put_colors); -} - -//************************************************************************** -// -// decode_color_64 -// -// Decode COLOR_64 chunk. -// -// Parameter List : -// -// Uchar *data -> data to decode -// Flic *flic -> the flic -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static void decode_color_64(Uchar *data, Flic *flic) -{ - decode_color(data, flic, screen_put_colors_64); -} - -//************************************************************************** -// -// decode_frame -// -// Decode a frame that is in memory already into screen. -// Here we just loop through each chunk calling appropriate -// chunk decoder. -// -// Parameter List : -// -// Flic *flic -> the flic -// FrameHead *frame -> info about the frame -// Uchar *data -> data to decode -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static ErrCode decode_frame(Flic *flic, FrameHead *frame, Uchar *data) -{ - int i; - ChunkHead *chunk; - - for (i=0; ichunks; ++i) - { - chunk = (ChunkHead *)data; - data += chunk->size; - switch (chunk->type) - { - case COLOR_256: - if (flic->screen.change_palette) - //decode_color_256((Uchar *)(chunk+1), flic); - decode_color_256( (((Uchar *)chunk) + 4 ), flic); - break; - case DELTA_FLC: - decode_delta_flc((Uchar *)(chunk+1), flic); - break; - case COLOR_64: - if (flic->screen.change_palette) - decode_color_64((Uchar *)(chunk+1), flic); - break; - case DELTA_FLI: - decode_delta_fli((Uchar *)(chunk+1), flic); - break; - case BLACK_FRAME: - decode_black((Uchar *)(chunk+1), flic); - break; - case BYTE_RUN: - decode_byte_run((Uchar *)(chunk+1), flic); - break; - case LITERAL: - decode_literal((Uchar *)(chunk+1), flic); - break; - default: - break; - } - } - return 0; -} - -static ErrCode file_read_big_block(FILE *file, char *block, Ulong size) - /* Read in a big block. Could be bigger than 64K. */ -{ - char *pt = block; - unsigned size1; - - while (size != 0) - { - size1 = ((size > 0xFFF0) ? 0xFFF0 : size); - if ( fread(pt, size1, 1, file) != 1 ) - return ErrFlicRead; - pt += size1; // Advance pointer to next batch. - size -= size1; // Subtract current batch from size to go. - } - return 0; -} - -//************************************************************************** -// -// fill_in_frame2 -// -// This figures out where the second frame of the flic is -// (useful for playing in a loop). -// -// Parameter List : -// -// Flic *flic -> the flic -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static ErrCode fill_in_frame2(Flic *flic) -{ - FrameHead head; - //ErrCode err; - - (*flic->seek)(flic, flic->head.oframe1); - if ( fread(&head, sizeof(head), 1, flic->file) != 1 ) - return ErrFlicRead; - - if ( fread(&head, sizeof(head), 1, flic->file) != 1 ) - return ErrFlicRead; - - flic->head.oframe2 = flic->head.oframe1 + head.size; - - return 0; -} - -//************************************************************************** -// -// flic_next_frame -// -// Advance to next frame of flic. -// -// Parameter List : -// -// Flic *flic -> the flic -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static ErrCode flic_next_frame(Flic *flic, BOOL fDecode) -{ - FrameHead head; - ErrCode err = 0; - long size; - - if ( fread(&head, sizeof(head), 1, flic->file) != 1 ) - err = ErrFlicRead; - else - { - if (head.type == FRAME_TYPE) - { - size = head.size - sizeof(head); /* Don't include head. */ - if (size > 0) - { - if (size > 500000) - { - //TRACE("FLC chunk too big: %d\n",size); - //Assert(0); - FastDebugMsg(String("flic_next_frame: FLC chunk too big: %d", size)); - size = 64000; - } - if (!(err = file_read_big_block(flic->file, pcxbuf, size))) - { - if ( fDecode ) - err = decode_frame(flic, &head, (unsigned char *)pcxbuf); - } - } - } - else - err = ErrFlicBadFrame; - } - return err; -} - -//************************************************************************** -// -// flic_check_frame -// -// A dummy routine to be called for each frame. -// -// Parameter List : -// -// Flic *flic -> the flic -// -// Return Value : -// Modification history : -// -//************************************************************************** - -static Boolean flic_check_frame(Flic *flic) -{ - return TRUE; -} - -//************************************************************************** -// -// File io -// -//************************************************************************** - -static ErrCode flic_open(Flic *flic, const char *filename) -{ - return (flic->file = fopen(filename, "rb")) ? 0 : ErrFlicAccess; -} - -static ErrCode flic_seek(Flic *flic, long offset) -{ - return fseek(flic->file, offset, SEEK_SET) ? ErrFlicSeek : 0; -} - -//************************************************************************** -// -// FlicInit -// -// Initializes a flic object. -// -// Parameter List : -// -// Flic *flic -> the flic -// -// Return Value : -// Modification history : -// -//************************************************************************** - -void FlicInit(Flic *flic, unsigned screen_width, unsigned screen_height, char change_palette, char *Buff) -{ - flic->file = NULL; - //flic->lib.names = NULL; - - flic->open = flic_open; /* Set routines for single flick file access */ - flic->seek = flic_seek; - - flic->check_frame = flic_check_frame; /* Select a dummy routine */ - - /** Info used by low level routines */ - - flic->screen.pixels = (unsigned char *)Buff; // (char *) 0xa0000; - flic->screen.width = screen_width; - flic->screen.height = screen_height; - flic->screen.change_palette = change_palette; -} - -//************************************************************************** -// -// FlicOpen -// -// Opens a flic file or locates a flic file in a library. -// -// Parameter List : -// -// Flic *flic -> the flic -// const char *filename -> filename of flic to open -// -// Return Value : -// Modification history : -// -//************************************************************************** - -ErrCode FlicOpen(Flic *flic, const char *filename) -{ - ErrCode err; - - flic->xoff = flic->yoff = 0; - - if ( !(err = (*flic->open)(flic, filename)) ) - { - if (fread(&flic->head, sizeof(flic->head), 1, flic->file) != 1) - err = ErrFlicRead; - else - { - flic->name = filename; - - if (flic->head.type == FLC_TYPE) - { - /* Seek frame 1. */ - (*flic->seek)(flic, flic->head.oframe1); - return 0; - } - if (flic->head.type == FLI_TYPE) - { - long i; - /* Do some conversion work here. */ - flic->head.oframe1 = sizeof(flic->head); - i=flic->head.speed * 1000L; - flic->head.speed = i / 70; - return 0; - } - else - { - err = ErrFlicBad; - printf("flic was bad! \n"); - _getch(); - exit(0); - } - } - } - - FlicClose(flic); /* Close down and scrub partially opened flic. */ - return err; -} - -//************************************************************************** -// -// FlicSetOrigin -// -// Sets the location of the top left corner of the flic in terms of screen -// coordinates. -// -// Parameter List : -// -// Flic *flic -> the flic -// unsigned x -> x-coord of origin -// unsigned y -> y-coord of origin -// -// Return Value : -// Modification history : -// -//************************************************************************** - -void FlicSetOrigin(Flic *flic, unsigned x, unsigned y) -{ - flic->xoff = x; - flic->yoff = y; -} - -//************************************************************************** -// -// FlicClose -// -// Closes a flic file if one is open. If a library is open, this function has -// no effect. -// -// Parameter List : -// -// Flic *flic -> the flic -// -// Return Value : -// Modification history : -// -//************************************************************************** - -void FlicClose(Flic *flic) -{ - if ( flic->file ) - { - fclose(flic->file); - flic->file = NULL; - } -} - -//************************************************************************** -// -// flic_play_loop_timer -// -// This routine is called at the end of each timer period. The timer is used -// by the FlicPlay routine. The global variable timer_flag indicates that -// a time interval has elapsed. FlicPlay resets timer_flag for the next -// interval. -// -// Stack checking must be disabled. -// -// Parameter List : -// Return Value : -// Modification history : -// -//************************************************************************** - -#ifdef DEBUG -#pragma off (check_stack) -#endif - -static volatile int timer_flag=1; - -static void flic_play_loop_timer() -{ - timer_flag = 1; -} - -#ifdef DEBUG -#pragma on (check_stack) -#endif - -//************************************************************************** -// -// FlicPlay -// -// This is the engine for the flic display system. Call this function to -// display a flic. -// -// Parameter List : -// -// Flic *flic -> the flic -// -// Return Value : -// Modification history : -// -//************************************************************************** - -ErrCode FlicPlay(Flic *flic, Ulong max_loop) -{ -/* - ErrCode err; - HTIMER timer; - - flic->status.max_loop_count = max_loop; - flic->status.max_frame_index = flic->head.frames; - - if (flic->head.oframe2 == 0) - { - fill_in_frame2(flic); - // FastBlitRegionSVGA((char *)(0xa0000),(char *)(flic->screen.pixels),(long)0,(long)640,(long)480,(long)0,(long)640); - // BlitSVGAPage((char *)(flic->screen.pixels)); - // BlitRegionSVGATst((void *)0xa0000,(void *)(flic->screen.pixels),(long)640,(long)480,(long)640); - //BlitRegionSVGA((char *)0xa0000,(char *)flic->screen.pixels,(long)0,(long)640,(long)480,(long)0,(long)640); - } - - // Seek to first frame. - (*flic->seek)(flic, flic->head.oframe1); - // Save time to move on. - - //videoSetMode(3); - //printf("speed is %d\n",flic->head.speed); - //_getch(); - //exit(0); - - //timer = AIL_register_timer(flic_play_loop_timer); - //AIL_set_timer_period(timer, flic->head.speed* 1000); - //timer_flag = 0; - //AIL_start_timer(timer); - - // Display first frame. - if (err = flic_next_frame(flic, TRUE)) - { - //AIL_release_timer_handle(timer); - return err; - } - - for (flic->status.loop_count = 0; !max_loop || flic->status.loop_count < max_loop; - ++flic->status.loop_count) - { - // Seek to second frame - (*flic->seek)(flic, flic->head.oframe2); - // Loop from 2nd frame thru ring frame - for (flic->status.frame_index=0; - (flic->status.frame_index < (flic->head.frames-1)) || - ( (flic->status.frame_index < flic->head.frames) && - ( !max_loop || (flic->status.loop_count < (max_loop - 1)))); - ++flic->status.frame_index) - { - while (!timer_flag); - - if (err = flic_next_frame(flic, TRUE)) - return err; - //else - // FastBlitRegionSVGA((char *)(0xa0000),(char *)(flic->screen.pixels),(long)0,(long)640,(long)480,(long)0,(long)640); - // BlitSVGAPage((char *)(flic->screen.pixels)); - // BlitRegionSVGATst((void *)0xa0000,(void *)(flic->screen.pixels),(long)640,(long)480,(long)640); - // BlitRegionSVGA((char *)0xa0000,(char *)flic->screen.pixels,(long)0,(long)640,(long)480,(long)0,(long)640); - - timer_flag = 0; - } - } - - //AIL_release_timer_handle(timer); -*/ - return 0; -} - -void FlicSeekFirst(Flic *flic) -{ -// if (flic->head.oframe2 == 0) -// fill_in_frame2(flic); - - // Seek to first frame. - flic_seek(flic, flic->head.oframe1); - - // Display first frame. - //flic_next_frame(flic, TRUE); HJH - flic->status.frame_index=0;//1; HJH -} - -int FlicAdvance(Flic *flic, BOOL fDecode) -{ - // Seek to second frame - //(*flic->seek)(flic, flic->head.oframe2); - // Loop from 2nd frame thru ring frame - - // for (flic->status.frame_index=0; - // (flic->status.frame_index < (flic->head.frames-1)) || - // ( (flic->status.frame_index < flic->head.frames) && - // ( !max_loop || (flic->status.loop_count < (max_loop - 1)))); - // ++flic->status.frame_index) - // { - - if(flic->status.frame_index < flic->head.frames) - { - flic_next_frame(flic, fDecode); - flic->status.frame_index++; - //memcpy(buffer, buffer2, (HSIZE*VSIZE)); - return(1); - } - else - return(0); - - // if (flic->check_frame && !(*flic->check_frame)(flic)) - // return 0; -} - -static void center_flic(Flic *flic) - /* Set flic.xoff and flic.yoff so flic plays centered rather - * than in upper left corner of display. */ -{ - flic->xoff = (flic->screen.width - (signed)flic->head.width)/2; - flic->yoff = (flic->screen.height - (signed)flic->head.height)/2; -} - -void set_flic_origin(Flic *flic, int x, int y) -{ - flic->xoff = x; - flic->yoff = y; -} - -int frame_check(Flic *flic) -{ -/* - char key; - - if (Esc()) - { - //AbortScript = TRUE; - return 0; - } - - if (flic->status.frame_index == FlcSoundFrames[FlcSoundIndex][0]) - { - // if the "sound" number is less than 100, then it's a VOC buffer - if (FlcSoundFrames[FlcSoundIndex][1] < 100) - { - PlayVoc(FlcSoundFrames[FlcSoundIndex][1],-1); - } - else // otherwise a raw sound data file to be streamed off of disk - { - if (FlcSoundNameList[FlcSoundNameIndex][0]!='\0') - { - retcode = lmLibSeek(SNDLIBINFO,FlcSoundNameList[FlcSoundNameIndex++],&SNDoffset,&SNDlength); - if (retcode == 0) - StPlay(glbPlayRate,IGNORE_AUDIO_GAPS); - } - } - - // now that the sound has been triggered, ready the next frame number - FlcSoundIndex++; - } - else - if (FlcSoundFrames[FlcSoundIndex][0] == 9998) // start music? - { - PlayXmi(FlcSoundFrames[FlcSoundIndex++][1],FALSE); - XmiVolume(1,127,0); - } - RefreshSound(); -*/ - return 1; -} - -//************************************************************************** -// -// FlicStart -// -// Parameter List : -// -// char *filename -> filename of flic to start processing -// char *buffer -> screen buffer to put data into -// Flic *flic -> the flic -// int usepal -> flag - should we use the palette? (I think) -// -// Return Value : -// Modification history : -// -//************************************************************************** - -int FlicStart(char *filename, int width, int height, char *buffer, Flic *flic, char usepal) -{ - FlicInit(flic, width, height, usepal, buffer); - - if(FlicOpen(flic, filename)) - return(-1); - - FlicSetOrigin(flic, 0, 0); - FlicSeekFirst(flic); - FlicAdvance(flic, TRUE); // HJH - we go to 1st, then go process it - - //memcpy(buffer, buffer2, (HSIZE*VSIZE)); - - return(0); -} - -//************************************************************************** -// -// FlicStop -// -// Parameter List : -// -// Flic *flic -> the flic -// -// Return Value : -// Modification history : -// -//************************************************************************** - -void FlicStop(Flic *flic) -{ - FlicClose(flic); -} - -//************************************************************************** -// -// FlicGetStats -// -// Gets statistics for the given file. -// -// Parameter List : -// -// char *filename -> the flic filename -// Flic *flic -> the flic -// int *piBufferSize -> this function will fill in how large a -// buffer is needed to store a screen of -// this flick -// int *piColourPalSize->this function will fill in how large -// the colour palette is -// -// Return Value : -// -// ErrCode -> 0 if successfull, non-zero otherwise -// -// Modification history : -// -// 05jun96:HJH -> creation -// -//************************************************************************** - -ErrCode FlicGetStats(char *filename, int width, int height, Flic *flic, int *piBufferSize, int *piColourPalSize) -{ - ErrCode err=0; - FlicInit(flic, width, height, 1, NULL); - - flic->xoff = flic->yoff = 0; - - if ( !(err = (*flic->open)(flic, filename)) ) - { - if (fread(&flic->head, sizeof(flic->head), 1, flic->file) != 1) - err = ErrFlicRead; - } - - if ( !err && piBufferSize ) - *piBufferSize = flic->head.width * flic->head.height; - - FlicSeekChunk( flic, 0, COLOR_256, piColourPalSize ); - FlicClose(flic); /* Close down and scrub partially opened flic. */ - - return err; -} - -//************************************************************************** -// -// FlicGetColourPalette -// -// To get the colour palette from the given flic file. -// -// Parameter List : -// -// char *filename -> the flic file to extract the palette from -// char **ppBuffer -> the place to put the palette -// -// Return Value : -// -// ErrCode -> 0 if successful, non-zero otherwise -// -// Modification history : -// -// 10jun96:HJH -> creation -// 19jun96:HJH -> removed <<2 after colors->r/g/b -// -//************************************************************************** - -ErrCode FlicGetColourPalette(CHAR *filename, int width, int height, CHAR **ppBuffer, INT *piNumColours) -{ - Flic flic; - INT iBufferSize; - INT iColourPaletteSize=0; - ErrCode err = 0; - ChunkHead *chunk = NULL; - CHAR *pcPosition; - - if ( FlicGetStats( filename, width, height, &flic, &iBufferSize, &iColourPaletteSize ) ) - err = -1; - - if ( piNumColours ) - *piNumColours = iColourPaletteSize; - - if ( !err && iColourPaletteSize ) - { - FlicInit(&flic, flic.head.width, flic.head.height, 1, NULL); - - if(FlicOpen(&flic, filename)) - return(-1); - - FlicSetOrigin(&flic, 0, 0); - - *ppBuffer = (CHAR *)MemAlloc( iColourPaletteSize ); - chunk = (ChunkHead *)FlicSeekChunk( &flic, 0, COLOR_256, NULL ); - pcPosition = (CHAR *)(((BYTE *)chunk)+6); - - if ( chunk ) - { - INT ix, end, count, start = 0; - Uchar *cbuf = (Uchar *)pcPosition; - Short *wp = (Short *)cbuf; - Short ops; - Colour *colors; - - ops = *wp; - cbuf += sizeof(*wp); - while (--ops >= 0) - { - start += *cbuf++; - if ((count = *cbuf++) == 0) - count = 256; - { - colors = (Colour *)cbuf; - end = start + count; - - for (ix = start; ix < end; ++ix) - { - (*ppBuffer)[ix*3] =colors->r; - (*ppBuffer)[ix*3+1]=colors->g; - (*ppBuffer)[ix*3+2]=colors->b; - ++colors; - } - } - cbuf += 3*count; - start += count; - } - } - } - else - { - err = -1; - } - - return(err); -} - -//************************************************************************** -// -// FlicSeekChunk -// -// To seek to a particular chunk in the flic file. -// -// Parameter List : -// -// Flic *flic -> the flic to search -// INT iFrame -> frame in which to search -// ChunkTypes eType -> type of chunk to search for -// INT *piChunkSize-> the function puts the size of the chunk here -// -// Return Value : -// -// char * -> the returned chunk -// -// Modification history : -// -// 05jun96:HJH -> creation -// -//************************************************************************** - -CHAR *FlicSeekChunk(Flic *flic, INT iFrame, ChunkTypes eType, INT *piChunkSize) -{ - FrameHead head; - LONG lSize; - ErrCode err=0; - INT i; - - FlicSeekFirst(flic); - - for ( i=0 ; i