mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-09 12:08:12 +03:00
Using const_str for trigger
This commit is contained in:
parent
fa5b030522
commit
aa58bcf948
3 changed files with 106 additions and 108 deletions
|
@ -398,13 +398,13 @@ void SoundManager::UpdateUI
|
||||||
|
|
||||||
if ( !currentFacet )
|
if ( !currentFacet )
|
||||||
{
|
{
|
||||||
gi.Cvar_Set( "snd_currentmood", music->current.c_str() );
|
gi.Cvar_Set( "snd_currentmood", Director.GetString(music->current).c_str() );
|
||||||
gi.Cvar_Set( "snd_fallbackmood", music->fallback.c_str() );
|
gi.Cvar_Set( "snd_fallbackmood", Director.GetString(music->fallback).c_str() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gi.Cvar_Set( "snd_currentmood", music->altcurrent.c_str() );
|
gi.Cvar_Set( "snd_currentmood", Director.GetString(music->altcurrent).c_str() );
|
||||||
gi.Cvar_Set( "snd_fallbackmood", music->altfallback.c_str() );
|
gi.Cvar_Set( "snd_fallbackmood", Director.GetString(music->altfallback).c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( current->isSubclassOf( TriggerReverb ) )
|
else if ( current->isSubclassOf( TriggerReverb ) )
|
||||||
|
@ -1609,12 +1609,12 @@ void SoundManager::Save
|
||||||
//
|
//
|
||||||
// set current
|
// set current
|
||||||
//
|
//
|
||||||
buf += va( " current %s", music->current.c_str() );
|
buf += va( " current %s", Director.GetString(music->current).c_str() );
|
||||||
|
|
||||||
//
|
//
|
||||||
// set fallback
|
// set fallback
|
||||||
//
|
//
|
||||||
buf += va( " fallback %s", music->fallback.c_str() );
|
buf += va( " fallback %s", Director.GetString(music->fallback).c_str() );
|
||||||
|
|
||||||
if ( music->GetMultiFaceted() )
|
if ( music->GetMultiFaceted() )
|
||||||
{
|
{
|
||||||
|
@ -1626,12 +1626,12 @@ void SoundManager::Save
|
||||||
//
|
//
|
||||||
// set alt current
|
// set alt current
|
||||||
//
|
//
|
||||||
buf += va( " altcurrent %s", music->altcurrent.c_str() );
|
buf += va( " altcurrent %s", Director.GetString(music->altcurrent).c_str() );
|
||||||
|
|
||||||
//
|
//
|
||||||
// set alt fallback
|
// set alt fallback
|
||||||
//
|
//
|
||||||
buf += va( " altfallback %s", music->altfallback.c_str() );
|
buf += va( " altfallback %s", Director.GetString(music->altfallback).c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -302,11 +302,11 @@ Trigger::Trigger()
|
||||||
count = -1;
|
count = -1;
|
||||||
|
|
||||||
//noise = "environment/switch/switch2.wav";
|
//noise = "environment/switch/switch2.wav";
|
||||||
noise = "";
|
noise = STRING_EMPTY;
|
||||||
|
|
||||||
respondto = spawnflags ^ TRIGGER_PLAYERS;
|
respondto = spawnflags ^ TRIGGER_PLAYERS;
|
||||||
|
|
||||||
message = "";
|
message = STRING_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
Trigger::~Trigger() {}
|
Trigger::~Trigger() {}
|
||||||
|
@ -560,16 +560,16 @@ void Trigger::ActivateTargets(Event *ev)
|
||||||
//
|
//
|
||||||
// print the message
|
// print the message
|
||||||
//
|
//
|
||||||
if (message.length() && other && (other->isClient() || other->isSubclassOf(Camera))) {
|
if (message != STRING_EMPTY && other && (other->isClient() || other->isSubclassOf(Camera))) {
|
||||||
// HACK HACK HACK
|
// HACK HACK HACK
|
||||||
// if it is a camera, pass in default player
|
// if it is a camera, pass in default player
|
||||||
if (!other->isClient()) {
|
if (!other->isClient()) {
|
||||||
gi.centerprintf(&g_entities[0], message.c_str());
|
gi.centerprintf(&g_entities[0], Director.GetString(message).c_str());
|
||||||
} else {
|
} else {
|
||||||
gi.centerprintf(other->edict, message.c_str());
|
gi.centerprintf(other->edict, Director.GetString(message).c_str());
|
||||||
}
|
}
|
||||||
if (Noise().length()) {
|
if (Noise().length()) {
|
||||||
other->Sound(noise.c_str(), CHAN_VOICE);
|
other->Sound(Director.GetString(noise).c_str(), CHAN_VOICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,16 +645,16 @@ void Trigger::SetMessage(const char *text)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (text) {
|
if (text) {
|
||||||
message = str(text);
|
message = Director.AddString(text);
|
||||||
} else {
|
} else {
|
||||||
message = "";
|
message = STRING_EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
str& Trigger::Message(void)
|
str& Trigger::Message(void)
|
||||||
|
|
||||||
{
|
{
|
||||||
return message;
|
return Director.GetString(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::EventSetNoise(Event *ev)
|
void Trigger::EventSetNoise(Event *ev)
|
||||||
|
@ -667,18 +667,18 @@ void Trigger::SetNoise(const char *text)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (text) {
|
if (text) {
|
||||||
noise = str(text);
|
noise = Director.AddString(text);
|
||||||
//
|
//
|
||||||
// cache in the sound
|
// cache in the sound
|
||||||
//
|
//
|
||||||
CacheResource(noise.c_str());
|
CacheResource(Director.GetString(noise).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
str& Trigger::Noise(void)
|
str& Trigger::Noise(void)
|
||||||
|
|
||||||
{
|
{
|
||||||
return noise;
|
return Director.GetString(noise);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trigger::SetMultiFaceted(int newFacet)
|
void Trigger::SetMultiFaceted(int newFacet)
|
||||||
|
@ -721,6 +721,32 @@ void Trigger::SetNotTriggerable(Event *ev)
|
||||||
triggerable = qfalse;
|
triggerable = qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Trigger::Archive(Archiver& arc)
|
||||||
|
{
|
||||||
|
Animate::Archive(arc);
|
||||||
|
|
||||||
|
arc.ArchiveFloat(&wait);
|
||||||
|
arc.ArchiveFloat(&delay);
|
||||||
|
arc.ArchiveFloat(&trigger_time);
|
||||||
|
arc.ArchiveBoolean(&triggerActivated);
|
||||||
|
arc.ArchiveInteger(&count);
|
||||||
|
Director.ArchiveString(arc, noise);
|
||||||
|
if (arc.Loading()) {
|
||||||
|
SetNoise(Director.GetString(noise).c_str());
|
||||||
|
}
|
||||||
|
Director.ArchiveString(arc, message);
|
||||||
|
arc.ArchiveSafePointer(&activator);
|
||||||
|
arc.ArchiveInteger(&respondto);
|
||||||
|
arc.ArchiveBoolean(&useTriggerDir);
|
||||||
|
arc.ArchiveFloat(&triggerCone);
|
||||||
|
arc.ArchiveVector(&triggerDir);
|
||||||
|
arc.ArchiveFloat(&triggerDirYaw);
|
||||||
|
arc.ArchiveBoolean(&triggerable);
|
||||||
|
arc.ArchiveBoolean(&removable);
|
||||||
|
arc.ArchiveBoolean(&edgeTriggered);
|
||||||
|
arc.ArchiveInteger(&multiFaceted);
|
||||||
|
}
|
||||||
|
|
||||||
/*QUAKED trigger_vehicle (0.25 0.5 0.35) ? x x x x x x x x
|
/*QUAKED trigger_vehicle (0.25 0.5 0.35) ? x x x x x x x x
|
||||||
works exactly like a trigger_multiple but only responds to vehicles.
|
works exactly like a trigger_multiple but only responds to vehicles.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
@ -1107,7 +1133,13 @@ void TriggerSave::SaveGame(Event *ev)
|
||||||
|
|
||||||
void TriggerSave::EventSaveName(Event *ev)
|
void TriggerSave::EventSaveName(Event *ev)
|
||||||
{
|
{
|
||||||
m_sSaveName = ev->GetString(1);
|
m_sSaveName = ev->GetConstString(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriggerSave::Archive(Archiver& arc)
|
||||||
|
{
|
||||||
|
Trigger::Archive(arc);
|
||||||
|
arc.ArchiveString(&m_sSaveName);
|
||||||
}
|
}
|
||||||
|
|
||||||
CLASS_DECLARATION(Trigger, TriggerSave, "trigger_save") {
|
CLASS_DECLARATION(Trigger, TriggerSave, "trigger_save") {
|
||||||
|
@ -2050,8 +2082,8 @@ void TriggerDamageTargets::DamageTargets(Event *ev)
|
||||||
//
|
//
|
||||||
// print the message
|
// print the message
|
||||||
//
|
//
|
||||||
if (message.length() && other && other->isClient()) {
|
if (message != STRING_EMPTY && other && other->isClient()) {
|
||||||
gi.centerprintf(other->edict, message.c_str());
|
gi.centerprintf(other->edict, Director.GetString(message).c_str());
|
||||||
if (Noise().length()) {
|
if (Noise().length()) {
|
||||||
other->Sound(Noise().c_str(), CHAN_VOICE);
|
other->Sound(Noise().c_str(), CHAN_VOICE);
|
||||||
}
|
}
|
||||||
|
@ -2383,68 +2415,68 @@ TriggerMusic::TriggerMusic()
|
||||||
|
|
||||||
SetOneShot(false);
|
SetOneShot(false);
|
||||||
|
|
||||||
noise = "";
|
noise = STRING_EMPTY;
|
||||||
|
|
||||||
current = "normal";
|
current = STRING_NORMAL;
|
||||||
fallback = "normal";
|
fallback = STRING_NORMAL;
|
||||||
|
|
||||||
altcurrent = "normal";
|
altcurrent = STRING_NORMAL;
|
||||||
altfallback = "normal";
|
altfallback = STRING_NORMAL;
|
||||||
|
|
||||||
// setup sound based on spawn flags
|
// setup sound based on spawn flags
|
||||||
if (spawnflags & 1) {
|
if (spawnflags & 1) {
|
||||||
current = "normal";
|
current = STRING_NORMAL;
|
||||||
} else if (spawnflags & 2) {
|
} else if (spawnflags & 2) {
|
||||||
current = "action";
|
current = STRING_ACTION;
|
||||||
} else if (spawnflags & 32) {
|
} else if (spawnflags & 32) {
|
||||||
current = "suspense";
|
current = STRING_SUSPENSE;
|
||||||
} else if (spawnflags & 64) {
|
} else if (spawnflags & 64) {
|
||||||
current = "mystery";
|
current = STRING_MYSTERY;
|
||||||
} else if (spawnflags & 128) {
|
} else if (spawnflags & 128) {
|
||||||
current = "surprise";
|
current = STRING_SURPRISE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerMusic::SetMood(str crnt, str fback)
|
void TriggerMusic::SetMood(str crnt, str fback)
|
||||||
{
|
{
|
||||||
current = crnt;
|
current = Director.AddString(crnt);
|
||||||
fallback = fback;
|
fallback = Director.AddString(fback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerMusic::SetAltMood(str crnt, str fback)
|
void TriggerMusic::SetAltMood(str crnt, str fback)
|
||||||
{
|
{
|
||||||
altcurrent = crnt;
|
altcurrent = Director.AddString(crnt);
|
||||||
altfallback = fback;
|
altfallback = Director.AddString(fback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerMusic::SetCurrentMood(Event *ev)
|
void TriggerMusic::SetCurrentMood(Event *ev)
|
||||||
{
|
{
|
||||||
current = ev->GetString(1);
|
current = ev->GetConstString(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerMusic::SetFallbackMood(Event *ev)
|
void TriggerMusic::SetFallbackMood(Event *ev)
|
||||||
{
|
{
|
||||||
fallback = ev->GetString(1);
|
fallback = ev->GetConstString(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerMusic::SetAltCurrentMood(Event *ev)
|
void TriggerMusic::SetAltCurrentMood(Event *ev)
|
||||||
{
|
{
|
||||||
altcurrent = ev->GetString(1);
|
altcurrent = ev->GetConstString(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerMusic::SetAltFallbackMood(Event *ev)
|
void TriggerMusic::SetAltFallbackMood(Event *ev)
|
||||||
{
|
{
|
||||||
altfallback = ev->GetString(1);
|
altfallback = ev->GetConstString(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerMusic::ChangeMood(Event *ev)
|
void TriggerMusic::ChangeMood(Event *ev)
|
||||||
{
|
{
|
||||||
ChangeMusic(current.c_str(), fallback.c_str(), qfalse);
|
ChangeMusic(Director.GetString(current).c_str(), Director.GetString(fallback).c_str(), qfalse);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerMusic::AltChangeMood(Event *ev)
|
void TriggerMusic::AltChangeMood(Event *ev)
|
||||||
{
|
{
|
||||||
ChangeMusic(altcurrent.c_str(), altfallback.c_str(), qfalse);
|
ChangeMusic(Director.GetString(altcurrent).c_str(), Director.GetString(altfallback).c_str(), qfalse);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerMusic::SetOneShot(qboolean once)
|
void TriggerMusic::SetOneShot(qboolean once)
|
||||||
|
@ -2463,6 +2495,17 @@ void TriggerMusic::SetOneShot(Event *ev)
|
||||||
SetOneShot(true);
|
SetOneShot(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TriggerMusic::Archive(Archiver& arc)
|
||||||
|
{
|
||||||
|
Trigger::Archive(arc);
|
||||||
|
|
||||||
|
arc.ArchiveBoolean(&oneshot);
|
||||||
|
Director.ArchiveString(arc, current);
|
||||||
|
Director.ArchiveString(arc, fallback);
|
||||||
|
Director.ArchiveString(arc, altcurrent);
|
||||||
|
Director.ArchiveString(arc, altfallback);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*QUAKED trigger_reverb (1 0 0) ? x x NOT_PLAYERS MONSTERS PROJECTILES
|
/*QUAKED trigger_reverb (1 0 0) ? x x NOT_PLAYERS MONSTERS PROJECTILES
|
||||||
|
|
||||||
|
@ -2580,7 +2623,7 @@ TriggerReverb::TriggerReverb()
|
||||||
|
|
||||||
SetOneShot(false);
|
SetOneShot(false);
|
||||||
|
|
||||||
noise = "";
|
noise = STRING_EMPTY;
|
||||||
|
|
||||||
reverbtype = 0;
|
reverbtype = 0;
|
||||||
altreverbtype = 0;
|
altreverbtype = 0;
|
||||||
|
@ -2689,15 +2732,15 @@ CLASS_DECLARATION(TriggerOnce, TriggerByPushObject, "trigger_pushobject") {
|
||||||
|
|
||||||
void TriggerByPushObject::setTriggerName(Event *event)
|
void TriggerByPushObject::setTriggerName(Event *event)
|
||||||
{
|
{
|
||||||
triggername = event->GetString(1);
|
triggername = event->GetConstString(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
qboolean TriggerByPushObject::respondTo(Entity *other)
|
qboolean TriggerByPushObject::respondTo(Entity *other)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (other->isSubclassOf(PushObject)) {
|
if (other->isSubclassOf(PushObject)) {
|
||||||
if (triggername.length()) {
|
if (triggername != STRING_EMPTY) {
|
||||||
return (triggername == other->TargetName());
|
return (Director.GetString(triggername) == other->TargetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return qtrue;
|
return qtrue;
|
||||||
|
@ -2722,6 +2765,13 @@ Entity *TriggerByPushObject::getActivator(Entity *other)
|
||||||
return other;
|
return other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TriggerByPushObject::Archive(Archiver& arc)
|
||||||
|
{
|
||||||
|
TriggerOnce::Archive(arc);
|
||||||
|
|
||||||
|
Director.ArchiveString(arc, triggername);
|
||||||
|
}
|
||||||
|
|
||||||
Event EV_TriggerGivePowerup_OneShot
|
Event EV_TriggerGivePowerup_OneShot
|
||||||
(
|
(
|
||||||
"oneshot",
|
"oneshot",
|
||||||
|
@ -2775,7 +2825,7 @@ TriggerGivePowerup::TriggerGivePowerup()
|
||||||
oneshot = false;
|
oneshot = false;
|
||||||
|
|
||||||
count = -1;
|
count = -1;
|
||||||
noise = "";
|
noise = STRING_EMPTY;
|
||||||
powerup_name = STRING_EMPTY;
|
powerup_name = STRING_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,8 @@ protected:
|
||||||
float trigger_time;
|
float trigger_time;
|
||||||
qboolean triggerActivated;
|
qboolean triggerActivated;
|
||||||
int count;
|
int count;
|
||||||
str noise;
|
const_str noise;
|
||||||
str message;
|
const_str message;
|
||||||
ScriptThreadLabel label;
|
ScriptThreadLabel label;
|
||||||
EntityPtr activator;
|
EntityPtr activator;
|
||||||
int respondto;
|
int respondto;
|
||||||
|
@ -119,32 +119,6 @@ public:
|
||||||
void Archive(Archiver& arc) override;
|
void Archive(Archiver& arc) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void Trigger::Archive(Archiver& arc)
|
|
||||||
{
|
|
||||||
Animate::Archive(arc);
|
|
||||||
|
|
||||||
arc.ArchiveFloat(&wait);
|
|
||||||
arc.ArchiveFloat(&delay);
|
|
||||||
arc.ArchiveFloat(&trigger_time);
|
|
||||||
arc.ArchiveBoolean(&triggerActivated);
|
|
||||||
arc.ArchiveInteger(&count);
|
|
||||||
arc.ArchiveString(&noise);
|
|
||||||
if (arc.Loading()) {
|
|
||||||
SetNoise(noise.c_str());
|
|
||||||
}
|
|
||||||
arc.ArchiveString(&message);
|
|
||||||
arc.ArchiveSafePointer(&activator);
|
|
||||||
arc.ArchiveInteger(&respondto);
|
|
||||||
arc.ArchiveBoolean(&useTriggerDir);
|
|
||||||
arc.ArchiveFloat(&triggerCone);
|
|
||||||
arc.ArchiveVector(&triggerDir);
|
|
||||||
arc.ArchiveFloat(&triggerDirYaw);
|
|
||||||
arc.ArchiveBoolean(&triggerable);
|
|
||||||
arc.ArchiveBoolean(&removable);
|
|
||||||
arc.ArchiveBoolean(&edgeTriggered);
|
|
||||||
arc.ArchiveInteger(&multiFaceted);
|
|
||||||
}
|
|
||||||
|
|
||||||
class TriggerVehicle : public Trigger
|
class TriggerVehicle : public Trigger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -230,12 +204,6 @@ public:
|
||||||
void Archive(Archiver& arc) override;
|
void Archive(Archiver& arc) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void TriggerSave::Archive(Archiver& arc)
|
|
||||||
{
|
|
||||||
Trigger::Archive(arc);
|
|
||||||
arc.ArchiveString(&m_sSaveName);
|
|
||||||
}
|
|
||||||
|
|
||||||
class TriggerRelay : public Trigger
|
class TriggerRelay : public Trigger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -506,11 +474,11 @@ class TriggerMusic : public Trigger
|
||||||
private:
|
private:
|
||||||
friend class SoundManager;
|
friend class SoundManager;
|
||||||
|
|
||||||
qboolean oneshot;
|
qboolean oneshot;
|
||||||
str current;
|
const_str current;
|
||||||
str fallback;
|
const_str fallback;
|
||||||
str altcurrent;
|
const_str altcurrent;
|
||||||
str altfallback;
|
const_str altfallback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CLASS_PROTOTYPE(TriggerMusic);
|
CLASS_PROTOTYPE(TriggerMusic);
|
||||||
|
@ -531,18 +499,6 @@ public:
|
||||||
void Archive(Archiver& arc) override;
|
void Archive(Archiver& arc) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void TriggerMusic::Archive(Archiver& arc)
|
|
||||||
|
|
||||||
{
|
|
||||||
Trigger::Archive(arc);
|
|
||||||
|
|
||||||
arc.ArchiveBoolean(&oneshot);
|
|
||||||
arc.ArchiveString(¤t);
|
|
||||||
arc.ArchiveString(&fallback);
|
|
||||||
arc.ArchiveString(&altcurrent);
|
|
||||||
arc.ArchiveString(&altfallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
class TriggerReverb : public Trigger
|
class TriggerReverb : public Trigger
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -588,7 +544,7 @@ inline void TriggerReverb::Archive(Archiver& arc)
|
||||||
class TriggerByPushObject : public TriggerOnce
|
class TriggerByPushObject : public TriggerOnce
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
str triggername;
|
const_str triggername;
|
||||||
|
|
||||||
void setTriggerName(Event *event);
|
void setTriggerName(Event *event);
|
||||||
|
|
||||||
|
@ -601,14 +557,6 @@ public:
|
||||||
void Archive(Archiver& arc) override;
|
void Archive(Archiver& arc) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void TriggerByPushObject::Archive(Archiver& arc)
|
|
||||||
|
|
||||||
{
|
|
||||||
TriggerOnce::Archive(arc);
|
|
||||||
|
|
||||||
arc.ArchiveString(&triggername);
|
|
||||||
}
|
|
||||||
|
|
||||||
class TriggerGivePowerup : public Trigger
|
class TriggerGivePowerup : public Trigger
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue