mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-09 20:18:17 +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 )
|
||||
{
|
||||
gi.Cvar_Set( "snd_currentmood", music->current.c_str() );
|
||||
gi.Cvar_Set( "snd_fallbackmood", music->fallback.c_str() );
|
||||
gi.Cvar_Set( "snd_currentmood", Director.GetString(music->current).c_str() );
|
||||
gi.Cvar_Set( "snd_fallbackmood", Director.GetString(music->fallback).c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
gi.Cvar_Set( "snd_currentmood", music->altcurrent.c_str() );
|
||||
gi.Cvar_Set( "snd_fallbackmood", music->altfallback.c_str() );
|
||||
gi.Cvar_Set( "snd_currentmood", Director.GetString(music->altcurrent).c_str() );
|
||||
gi.Cvar_Set( "snd_fallbackmood", Director.GetString(music->altfallback).c_str() );
|
||||
}
|
||||
}
|
||||
else if ( current->isSubclassOf( TriggerReverb ) )
|
||||
|
@ -1609,12 +1609,12 @@ void SoundManager::Save
|
|||
//
|
||||
// set current
|
||||
//
|
||||
buf += va( " current %s", music->current.c_str() );
|
||||
buf += va( " current %s", Director.GetString(music->current).c_str() );
|
||||
|
||||
//
|
||||
// set fallback
|
||||
//
|
||||
buf += va( " fallback %s", music->fallback.c_str() );
|
||||
buf += va( " fallback %s", Director.GetString(music->fallback).c_str() );
|
||||
|
||||
if ( music->GetMultiFaceted() )
|
||||
{
|
||||
|
@ -1626,12 +1626,12 @@ void SoundManager::Save
|
|||
//
|
||||
// set alt current
|
||||
//
|
||||
buf += va( " altcurrent %s", music->altcurrent.c_str() );
|
||||
buf += va( " altcurrent %s", Director.GetString(music->altcurrent).c_str() );
|
||||
|
||||
//
|
||||
// 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;
|
||||
|
||||
//noise = "environment/switch/switch2.wav";
|
||||
noise = "";
|
||||
noise = STRING_EMPTY;
|
||||
|
||||
respondto = spawnflags ^ TRIGGER_PLAYERS;
|
||||
|
||||
message = "";
|
||||
message = STRING_EMPTY;
|
||||
}
|
||||
|
||||
Trigger::~Trigger() {}
|
||||
|
@ -560,16 +560,16 @@ void Trigger::ActivateTargets(Event *ev)
|
|||
//
|
||||
// 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
|
||||
// if it is a camera, pass in default player
|
||||
if (!other->isClient()) {
|
||||
gi.centerprintf(&g_entities[0], message.c_str());
|
||||
gi.centerprintf(&g_entities[0], Director.GetString(message).c_str());
|
||||
} else {
|
||||
gi.centerprintf(other->edict, message.c_str());
|
||||
gi.centerprintf(other->edict, Director.GetString(message).c_str());
|
||||
}
|
||||
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) {
|
||||
message = str(text);
|
||||
message = Director.AddString(text);
|
||||
} else {
|
||||
message = "";
|
||||
message = STRING_EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
str& Trigger::Message(void)
|
||||
|
||||
{
|
||||
return message;
|
||||
return Director.GetString(message);
|
||||
}
|
||||
|
||||
void Trigger::EventSetNoise(Event *ev)
|
||||
|
@ -667,18 +667,18 @@ void Trigger::SetNoise(const char *text)
|
|||
|
||||
{
|
||||
if (text) {
|
||||
noise = str(text);
|
||||
noise = Director.AddString(text);
|
||||
//
|
||||
// cache in the sound
|
||||
//
|
||||
CacheResource(noise.c_str());
|
||||
CacheResource(Director.GetString(noise).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
str& Trigger::Noise(void)
|
||||
|
||||
{
|
||||
return noise;
|
||||
return Director.GetString(noise);
|
||||
}
|
||||
|
||||
void Trigger::SetMultiFaceted(int newFacet)
|
||||
|
@ -721,6 +721,32 @@ void Trigger::SetNotTriggerable(Event *ev)
|
|||
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
|
||||
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)
|
||||
{
|
||||
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") {
|
||||
|
@ -2050,8 +2082,8 @@ void TriggerDamageTargets::DamageTargets(Event *ev)
|
|||
//
|
||||
// print the message
|
||||
//
|
||||
if (message.length() && other && other->isClient()) {
|
||||
gi.centerprintf(other->edict, message.c_str());
|
||||
if (message != STRING_EMPTY && other && other->isClient()) {
|
||||
gi.centerprintf(other->edict, Director.GetString(message).c_str());
|
||||
if (Noise().length()) {
|
||||
other->Sound(Noise().c_str(), CHAN_VOICE);
|
||||
}
|
||||
|
@ -2383,68 +2415,68 @@ TriggerMusic::TriggerMusic()
|
|||
|
||||
SetOneShot(false);
|
||||
|
||||
noise = "";
|
||||
noise = STRING_EMPTY;
|
||||
|
||||
current = "normal";
|
||||
fallback = "normal";
|
||||
current = STRING_NORMAL;
|
||||
fallback = STRING_NORMAL;
|
||||
|
||||
altcurrent = "normal";
|
||||
altfallback = "normal";
|
||||
altcurrent = STRING_NORMAL;
|
||||
altfallback = STRING_NORMAL;
|
||||
|
||||
// setup sound based on spawn flags
|
||||
if (spawnflags & 1) {
|
||||
current = "normal";
|
||||
current = STRING_NORMAL;
|
||||
} else if (spawnflags & 2) {
|
||||
current = "action";
|
||||
current = STRING_ACTION;
|
||||
} else if (spawnflags & 32) {
|
||||
current = "suspense";
|
||||
current = STRING_SUSPENSE;
|
||||
} else if (spawnflags & 64) {
|
||||
current = "mystery";
|
||||
current = STRING_MYSTERY;
|
||||
} else if (spawnflags & 128) {
|
||||
current = "surprise";
|
||||
current = STRING_SURPRISE;
|
||||
}
|
||||
}
|
||||
|
||||
void TriggerMusic::SetMood(str crnt, str fback)
|
||||
{
|
||||
current = crnt;
|
||||
fallback = fback;
|
||||
current = Director.AddString(crnt);
|
||||
fallback = Director.AddString(fback);
|
||||
}
|
||||
|
||||
void TriggerMusic::SetAltMood(str crnt, str fback)
|
||||
{
|
||||
altcurrent = crnt;
|
||||
altfallback = fback;
|
||||
altcurrent = Director.AddString(crnt);
|
||||
altfallback = Director.AddString(fback);
|
||||
}
|
||||
|
||||
void TriggerMusic::SetCurrentMood(Event *ev)
|
||||
{
|
||||
current = ev->GetString(1);
|
||||
current = ev->GetConstString(1);
|
||||
}
|
||||
|
||||
void TriggerMusic::SetFallbackMood(Event *ev)
|
||||
{
|
||||
fallback = ev->GetString(1);
|
||||
fallback = ev->GetConstString(1);
|
||||
}
|
||||
|
||||
void TriggerMusic::SetAltCurrentMood(Event *ev)
|
||||
{
|
||||
altcurrent = ev->GetString(1);
|
||||
altcurrent = ev->GetConstString(1);
|
||||
}
|
||||
|
||||
void TriggerMusic::SetAltFallbackMood(Event *ev)
|
||||
{
|
||||
altfallback = ev->GetString(1);
|
||||
altfallback = ev->GetConstString(1);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
@ -2463,6 +2495,17 @@ void TriggerMusic::SetOneShot(Event *ev)
|
|||
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
|
||||
|
||||
|
@ -2580,7 +2623,7 @@ TriggerReverb::TriggerReverb()
|
|||
|
||||
SetOneShot(false);
|
||||
|
||||
noise = "";
|
||||
noise = STRING_EMPTY;
|
||||
|
||||
reverbtype = 0;
|
||||
altreverbtype = 0;
|
||||
|
@ -2689,15 +2732,15 @@ CLASS_DECLARATION(TriggerOnce, TriggerByPushObject, "trigger_pushobject") {
|
|||
|
||||
void TriggerByPushObject::setTriggerName(Event *event)
|
||||
{
|
||||
triggername = event->GetString(1);
|
||||
triggername = event->GetConstString(1);
|
||||
}
|
||||
|
||||
qboolean TriggerByPushObject::respondTo(Entity *other)
|
||||
|
||||
{
|
||||
if (other->isSubclassOf(PushObject)) {
|
||||
if (triggername.length()) {
|
||||
return (triggername == other->TargetName());
|
||||
if (triggername != STRING_EMPTY) {
|
||||
return (Director.GetString(triggername) == other->TargetName());
|
||||
}
|
||||
|
||||
return qtrue;
|
||||
|
@ -2722,6 +2765,13 @@ Entity *TriggerByPushObject::getActivator(Entity *other)
|
|||
return other;
|
||||
}
|
||||
|
||||
void TriggerByPushObject::Archive(Archiver& arc)
|
||||
{
|
||||
TriggerOnce::Archive(arc);
|
||||
|
||||
Director.ArchiveString(arc, triggername);
|
||||
}
|
||||
|
||||
Event EV_TriggerGivePowerup_OneShot
|
||||
(
|
||||
"oneshot",
|
||||
|
@ -2775,7 +2825,7 @@ TriggerGivePowerup::TriggerGivePowerup()
|
|||
oneshot = false;
|
||||
|
||||
count = -1;
|
||||
noise = "";
|
||||
noise = STRING_EMPTY;
|
||||
powerup_name = STRING_EMPTY;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,8 @@ protected:
|
|||
float trigger_time;
|
||||
qboolean triggerActivated;
|
||||
int count;
|
||||
str noise;
|
||||
str message;
|
||||
const_str noise;
|
||||
const_str message;
|
||||
ScriptThreadLabel label;
|
||||
EntityPtr activator;
|
||||
int respondto;
|
||||
|
@ -119,32 +119,6 @@ public:
|
|||
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
|
||||
{
|
||||
public:
|
||||
|
@ -230,12 +204,6 @@ public:
|
|||
void Archive(Archiver& arc) override;
|
||||
};
|
||||
|
||||
inline void TriggerSave::Archive(Archiver& arc)
|
||||
{
|
||||
Trigger::Archive(arc);
|
||||
arc.ArchiveString(&m_sSaveName);
|
||||
}
|
||||
|
||||
class TriggerRelay : public Trigger
|
||||
{
|
||||
public:
|
||||
|
@ -506,11 +474,11 @@ class TriggerMusic : public Trigger
|
|||
private:
|
||||
friend class SoundManager;
|
||||
|
||||
qboolean oneshot;
|
||||
str current;
|
||||
str fallback;
|
||||
str altcurrent;
|
||||
str altfallback;
|
||||
qboolean oneshot;
|
||||
const_str current;
|
||||
const_str fallback;
|
||||
const_str altcurrent;
|
||||
const_str altfallback;
|
||||
|
||||
public:
|
||||
CLASS_PROTOTYPE(TriggerMusic);
|
||||
|
@ -531,18 +499,6 @@ public:
|
|||
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
|
||||
{
|
||||
private:
|
||||
|
@ -588,7 +544,7 @@ inline void TriggerReverb::Archive(Archiver& arc)
|
|||
class TriggerByPushObject : public TriggerOnce
|
||||
{
|
||||
private:
|
||||
str triggername;
|
||||
const_str triggername;
|
||||
|
||||
void setTriggerName(Event *event);
|
||||
|
||||
|
@ -601,14 +557,6 @@ public:
|
|||
void Archive(Archiver& arc) override;
|
||||
};
|
||||
|
||||
inline void TriggerByPushObject::Archive(Archiver& arc)
|
||||
|
||||
{
|
||||
TriggerOnce::Archive(arc);
|
||||
|
||||
arc.ArchiveString(&triggername);
|
||||
}
|
||||
|
||||
class TriggerGivePowerup : public Trigger
|
||||
{
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue