Skip to content

Commit 997e305

Browse files
authored
Multiplayer: Only show torture minigame on bullfrog maps (#4865)
Also fixed hanging on torture screen.
1 parent f0f574c commit 997e305

7 files changed

Lines changed: 36 additions & 3 deletions

File tree

config/fxdata/rules.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ AlliesShareCta = 0
5252
AlliesShareDrop = 0
5353
; Allow allied players to share map vision, which is removed as soon as alliance is broken. [0-1]
5454
AlliesShareVision = 0
55+
; Show the torture screen after multiplayer games. [0-1]
56+
WinnerTorturesLoser = 0
5557
; Maximum number of objects or creatures a player can hold simultaneously. [0-64]
5658
MaxThingsInHand = 8
5759
; Total number of creatures allowed on the map at once. [0-1022]

levels/classic_cfgs/rules.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33

44
[game]
55
DungeonHeartHealHealth = 1
6-
MapCreatureLimit = 255
6+
MapCreatureLimit = 255
7+
WinnerTorturesLoser = 1

src/config_rules.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ static const struct NamedField rules_game_named_fields[] = {
9898
{"ALLIESSHAREVISION", 0, field(game.conf.rules[0].game.allies_share_vision ), 0, 0, 1,NULL, value_default, assign_AlliesShareVision_script},
9999
{"ALLIESSHAREDROP", 0, field(game.conf.rules[0].game.allies_share_drop ), 0, 0, 1,NULL, value_default, assign_default},
100100
{"ALLIESSHARECTA", 0, field(game.conf.rules[0].game.allies_share_cta ), 0, 0, 1,NULL, value_default, assign_default},
101+
{"WINNERTORTURESLOSER", 0, field(game.conf.rules[0].game.winner_tortures_loser ), 0, 0, 1,NULL, value_default, assign_default},
101102
{"DISPLAYPORTALLIMIT", 0, field(game.conf.rules[0].game.display_portal_limit ), 0, 0, 1,NULL, value_default, assign_default},
102103
{"MAXTHINGSINHAND", 0, field(game.conf.rules[0].game.max_things_in_hand ), 8, 0, MAX_THINGS_IN_HAND,NULL, value_default, assign_default},
103104
{"TORTUREPAYDAY", 0, field(game.conf.rules[0].game.torture_payday ), 50, 0, USHRT_MAX,NULL, value_default, assign_default},

src/config_rules.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ struct GameRulesConfig {
9292
TbBool allies_share_vision;
9393
TbBool allies_share_drop;
9494
TbBool allies_share_cta;
95+
TbBool winner_tortures_loser;
9596
TbBool display_portal_limit;
9697
unsigned char max_things_in_hand;
9798
unsigned short torture_payday;

src/front_torture.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "bflib_filelst.h"
3030
#include "bflib_dernc.h"
3131
#include "bflib_keybrd.h"
32+
#include "bflib_datetm.h"
3233
#include "bflib_video.h"
3334
#include "bflib_vidraw.h"
3435
#include "bflib_mouse.h"
@@ -61,11 +62,15 @@ static long torture_sprite_frame;
6162
static long torture_door_selected;
6263
static struct DoorSoundState door_sound_state[TORTURE_DOORS_COUNT];
6364
static struct TortureState torture_state;
65+
static TbClockMSec torture_idle_start;
66+
static TbClockMSec torture_screen_start;
6467
static unsigned char *torture_background;
6568
static unsigned char *torture_palette;
6669
extern struct DoorDesc doors[TORTURE_DOORS_COUNT];
6770
extern struct TbSpriteSheet *fronttor_sprites;
6871
long torture_doors_available = TORTURE_DOORS_COUNT;
72+
#define TORTURE_MULTIPLAYER_IDLE_TIMEOUT 10000
73+
#define TORTURE_MULTIPLAYER_MAX_TIME 45000
6974
/******************************************************************************/
7075
#ifdef __cplusplus
7176
}
@@ -167,6 +172,8 @@ void fronttorture_load(void)
167172
LbMouseChangeSpriteAndHotspot(0, 0, 0);
168173
}
169174
torture_left_button = 0;
175+
torture_idle_start = LbTimerClock();
176+
torture_screen_start = torture_idle_start;
170177
}
171178

172179
TbBool fronttorture_draw(void)
@@ -236,6 +243,18 @@ void fronttorture_input(void)
236243
pckt->actn_par1 = GetMouseX();
237244
pckt->actn_par2 = GetMouseY();
238245
}
246+
if (network_is_active())
247+
{
248+
TbClockMSec now = LbTimerClock();
249+
if (now - torture_idle_start >= TORTURE_MULTIPLAYER_IDLE_TIMEOUT)
250+
{
251+
pckt->action |= 0x01;
252+
}
253+
if (now - torture_screen_start >= TORTURE_MULTIPLAYER_MAX_TIME)
254+
{
255+
pckt->action |= 0x01;
256+
}
257+
}
239258
// Exchange packet with other players
240259
if (network_is_active())
241260
{
@@ -254,6 +273,7 @@ void fronttorture_input(void)
254273
{
255274
x = pckt->actn_par1;
256275
y = pckt->actn_par2;
276+
torture_idle_start = LbTimerClock();
257277
} else
258278
{
259279
plyr_idx = my_player_number;

src/net_game.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,11 @@ void process_disconnected_network_players(void)
526526
resolve_network_quit_outcome(myplyr);
527527
}
528528
if (winning_quit && (plyr_count > 1)) {
529-
myplyr->additional_flags |= PlaAF_UnlockedLordTorture;
529+
if (game.conf.rules[myplyr->id_number].game.winner_tortures_loser) {
530+
myplyr->additional_flags |= PlaAF_UnlockedLordTorture;
531+
} else {
532+
myplyr->additional_flags &= ~PlaAF_UnlockedLordTorture;
533+
}
530534
}
531535
if (!host_disconnected && network_has_remote_users_remaining()) {
532536
return;

src/packets.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,11 @@ TbBool process_players_global_packet_action(PlayerNumber plyr_idx)
648648
if (network_is_active()) {
649649
if (victory_state == VicS_WonLevel) {
650650
player->victory_state = VicS_WonLevel;
651-
get_my_player()->additional_flags |= PlaAF_UnlockedLordTorture;
651+
if (game.conf.rules[player->id_number].game.winner_tortures_loser) {
652+
get_my_player()->additional_flags |= PlaAF_UnlockedLordTorture;
653+
} else {
654+
get_my_player()->additional_flags &= ~PlaAF_UnlockedLordTorture;
655+
}
652656
quit_game = 1;
653657
return 0;
654658
}

0 commit comments

Comments
 (0)