2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
|
|
|
|
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
|
|
|
|
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
|
|
|
|
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
|
|
|
|
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
|
|
|
|
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
|
|
|
|
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
|
|
|
|
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
|
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Special effects, such as rotating fans, electrical walls, and
|
|
|
|
* other cool animations.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "gr.h"
|
|
|
|
#include "inferno.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "vclip.h"
|
|
|
|
#include "effects.h"
|
|
|
|
#include "bm.h"
|
|
|
|
#include "u_mem.h"
|
|
|
|
#include "textures.h"
|
2014-01-12 23:00:43 +00:00
|
|
|
#include "physfs-serial.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "cntrlcen.h"
|
2014-12-22 04:35:49 +00:00
|
|
|
#include "segment.h"
|
2012-07-07 18:35:06 +00:00
|
|
|
#include "dxxerror.h"
|
2019-08-15 01:34:22 +00:00
|
|
|
#include "object.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-01-18 18:02:02 +00:00
|
|
|
#include "compiler-range_for.h"
|
|
|
|
#include "partial_range.h"
|
|
|
|
|
|
|
|
unsigned Num_effects;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
void init_special_effects()
|
|
|
|
{
|
2019-03-03 00:31:09 +00:00
|
|
|
auto &Effects = LevelUniqueEffectsClipState.Effects;
|
2014-01-18 18:02:02 +00:00
|
|
|
range_for (eclip &ec, partial_range(Effects, Num_effects))
|
2014-01-19 22:58:24 +00:00
|
|
|
ec.time_left = ec.vc.frame_time;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void reset_special_effects()
|
|
|
|
{
|
2019-03-03 00:31:09 +00:00
|
|
|
auto &Effects = LevelUniqueEffectsClipState.Effects;
|
2014-01-18 18:02:02 +00:00
|
|
|
range_for (eclip &ec, partial_range(Effects, Num_effects))
|
|
|
|
{
|
2014-01-19 22:58:24 +00:00
|
|
|
ec.segnum = segment_none; //clear any active one-shots
|
|
|
|
ec.flags &= ~(EF_STOPPED|EF_ONE_SHOT); //restart any stopped effects
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//reset bitmap, which could have been changed by a crit_clip
|
2014-01-19 22:58:24 +00:00
|
|
|
if (ec.changing_wall_texture != -1)
|
|
|
|
Textures[ec.changing_wall_texture] = ec.vc.frames[ec.frame_count];
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
if (ec.changing_object_texture != -1)
|
|
|
|
ObjBitmaps[ec.changing_object_texture] = ec.vc.frames[ec.frame_count];
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void do_special_effects()
|
|
|
|
{
|
2019-08-15 01:34:22 +00:00
|
|
|
auto &LevelUniqueControlCenterState = LevelUniqueObjectState.ControlCenterState;
|
2019-03-03 00:31:09 +00:00
|
|
|
auto &Effects = LevelUniqueEffectsClipState.Effects;
|
2014-01-18 18:02:02 +00:00
|
|
|
range_for (eclip &ec, partial_range(Effects, Num_effects))
|
|
|
|
{
|
2014-01-19 22:58:24 +00:00
|
|
|
if ((ec.changing_wall_texture == -1) && (ec.changing_object_texture==-1) )
|
2006-03-20 17:12:09 +00:00
|
|
|
continue;
|
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
if (ec.flags & EF_STOPPED)
|
2006-03-20 17:12:09 +00:00
|
|
|
continue;
|
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
ec.time_left -= FrameTime;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
while (ec.time_left < 0) {
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
ec.time_left += ec.vc.frame_time;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
ec.frame_count++;
|
|
|
|
if (ec.frame_count >= ec.vc.num_frames) {
|
|
|
|
if (ec.flags & EF_ONE_SHOT) {
|
|
|
|
ec.flags &= ~EF_ONE_SHOT;
|
2018-12-13 02:31:38 +00:00
|
|
|
unique_segment &seg = *vmsegptr(ec.segnum);
|
2014-01-19 22:58:24 +00:00
|
|
|
ec.segnum = segment_none; //done with this
|
2016-12-24 22:44:08 +00:00
|
|
|
assert(ec.sidenum < 6);
|
|
|
|
auto &side = seg.sides[ec.sidenum];
|
|
|
|
assert(ec.dest_bm_num != 0 && side.tmap_num2 != 0);
|
|
|
|
side.tmap_num2 = ec.dest_bm_num | (side.tmap_num2 & 0xc000); //replace with destoyed
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
ec.frame_count = 0;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
if (ec.flags & EF_CRITICAL)
|
2006-03-20 17:12:09 +00:00
|
|
|
continue;
|
|
|
|
|
2019-08-15 01:34:22 +00:00
|
|
|
if (ec.crit_clip!=-1 && LevelUniqueControlCenterState.Control_center_destroyed)
|
|
|
|
{
|
2014-01-19 22:58:24 +00:00
|
|
|
int n = ec.crit_clip;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
if (ec.changing_wall_texture != -1)
|
|
|
|
Textures[ec.changing_wall_texture] = Effects[n].vc.frames[Effects[n].frame_count];
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
if (ec.changing_object_texture != -1)
|
|
|
|
ObjBitmaps[ec.changing_object_texture] = Effects[n].vc.frames[Effects[n].frame_count];
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else {
|
2014-01-19 22:58:24 +00:00
|
|
|
if (ec.changing_wall_texture != -1)
|
|
|
|
Textures[ec.changing_wall_texture] = ec.vc.frames[ec.frame_count];
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
if (ec.changing_object_texture != -1)
|
|
|
|
ObjBitmaps[ec.changing_object_texture] = ec.vc.frames[ec.frame_count];
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void restore_effect_bitmap_icons()
|
|
|
|
{
|
2019-03-03 00:31:09 +00:00
|
|
|
auto &Effects = LevelUniqueEffectsClipState.Effects;
|
2016-02-12 04:02:28 +00:00
|
|
|
range_for (auto &ec, partial_const_range(Effects, Num_effects))
|
2014-01-19 22:58:24 +00:00
|
|
|
{
|
|
|
|
if (! (ec.flags & EF_CRITICAL)) {
|
|
|
|
if (ec.changing_wall_texture != -1)
|
|
|
|
Textures[ec.changing_wall_texture] = ec.vc.frames[0];
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2014-01-19 22:58:24 +00:00
|
|
|
if (ec.changing_object_texture != -1)
|
|
|
|
ObjBitmaps[ec.changing_object_texture] = ec.vc.frames[0];
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
2014-01-19 22:58:24 +00:00
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//stop an effect from animating. Show first frame.
|
|
|
|
void stop_effect(int effect_num)
|
|
|
|
{
|
2019-03-03 00:31:09 +00:00
|
|
|
auto &Effects = LevelUniqueEffectsClipState.Effects;
|
2006-03-20 17:12:09 +00:00
|
|
|
eclip *ec = &Effects[effect_num];
|
|
|
|
|
|
|
|
//Assert(ec->bm_ptr != -1);
|
|
|
|
|
|
|
|
ec->flags |= EF_STOPPED;
|
|
|
|
|
|
|
|
ec->frame_count = 0;
|
|
|
|
//*ec->bm_ptr = &GameBitmaps[ec->vc.frames[0].index];
|
|
|
|
|
|
|
|
if (ec->changing_wall_texture != -1)
|
|
|
|
Textures[ec->changing_wall_texture] = ec->vc.frames[0];
|
|
|
|
|
|
|
|
if (ec->changing_object_texture != -1)
|
|
|
|
ObjBitmaps[ec->changing_object_texture] = ec->vc.frames[0];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//restart a stopped effect
|
|
|
|
void restart_effect(int effect_num)
|
|
|
|
{
|
2019-03-03 00:31:09 +00:00
|
|
|
auto &Effects = LevelUniqueEffectsClipState.Effects;
|
2006-03-20 17:12:09 +00:00
|
|
|
Effects[effect_num].flags &= ~EF_STOPPED;
|
|
|
|
|
|
|
|
//Assert(Effects[effect_num].bm_ptr != -1);
|
|
|
|
}
|
|
|
|
|
2014-01-12 23:00:43 +00:00
|
|
|
DEFINE_VCLIP_SERIAL_UDT();
|
2016-12-24 22:44:08 +00:00
|
|
|
DEFINE_SERIAL_UDT_TO_MESSAGE(eclip, ec, (ec.vc, ec.time_left, ec.frame_count, ec.changing_wall_texture, ec.changing_object_texture, ec.flags, ec.crit_clip, ec.dest_bm_num, ec.dest_vclip, ec.dest_eclip, ec.dest_size, ec.sound_num, ec.segnum, serial::pad<2>(), ec.sidenum, serial::pad<3>()));
|
2014-01-12 23:00:43 +00:00
|
|
|
ASSERT_SERIAL_UDT_MESSAGE_SIZE(eclip, 130);
|
2014-01-12 23:00:43 +00:00
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2016-01-09 16:38:14 +00:00
|
|
|
* reads n eclip structs from a PHYSFS_File
|
2006-03-20 17:12:09 +00:00
|
|
|
*/
|
2016-01-09 16:38:14 +00:00
|
|
|
void eclip_read(PHYSFS_File *fp, eclip &ec)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2014-01-12 23:00:43 +00:00
|
|
|
PHYSFSX_serialize_read(fp, ec);
|
|
|
|
}
|
|
|
|
|
2015-12-04 03:36:31 +00:00
|
|
|
#if 0
|
2016-01-09 16:38:14 +00:00
|
|
|
void eclip_write(PHYSFS_File *fp, const eclip &ec)
|
2014-01-12 23:00:43 +00:00
|
|
|
{
|
|
|
|
PHYSFSX_serialize_write(fp, ec);
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
2015-12-04 03:36:31 +00:00
|
|
|
#endif
|