diff --git a/source/GcLib/directx/DirectSound.cpp b/source/GcLib/directx/DirectSound.cpp index 3874b556..e007531c 100644 --- a/source/GcLib/directx/DirectSound.cpp +++ b/source/GcLib/directx/DirectSound.cpp @@ -854,7 +854,7 @@ SoundPlayer::SoundPlayer() { playStyle_.bLoop_ = false; playStyle_.timeLoopStart_ = 0; playStyle_.timeLoopEnd_ = 0; - playStyle_.timeStart_ = 0; + playStyle_.timeStart_ = -1; playStyle_.bResume_ = false; bDelete_ = false; @@ -1258,11 +1258,11 @@ bool SoundStreamingPlayer::Play() { SetFade(0); bStreamOver_ = false; - if (!bPause_ || !playStyle_.bResume_) { - this->Seek(playStyle_.timeStart_); + if (!bPause_ || !playStyle_.bResume_ || playStyle_.timeStart_ >= 0) { + this->Seek(playStyle_.timeStart_ >= 0 ? playStyle_.timeStart_ : 0); pDirectSoundBuffer_->SetCurrentPosition(0); } - playStyle_.timeStart_ = 0; + playStyle_.timeStart_ = -1; for (size_t iEvent = 0; iEvent < 3; ++iEvent) ::ResetEvent(hEvent_[iEvent]); @@ -1487,10 +1487,10 @@ bool SoundPlayerWave::Play() { if (playStyle_.bLoop_) dwFlags = DSBPLAY_LOOPING; - if (!bPause_ || !playStyle_.bResume_) { - this->Seek(playStyle_.timeStart_); + if (!bPause_ || !playStyle_.bResume_ || playStyle_.timeStart_ >= 0) { + this->Seek(playStyle_.timeStart_ >= 0 ? playStyle_.timeStart_ : 0); } - playStyle_.timeStart_ = 0; + playStyle_.timeStart_ = -1; HRESULT hr = pDirectSoundBuffer_->Play(0, 0, dwFlags); if (hr == DSERR_BUFFERLOST) { diff --git a/source/GcLib/gstd/Script/Parser.cpp b/source/GcLib/gstd/Script/Parser.cpp index 03a75690..0d453c62 100644 --- a/source/GcLib/gstd/Script/Parser.cpp +++ b/source/GcLib/gstd/Script/Parser.cpp @@ -187,17 +187,15 @@ parser::symbol* parser::scope_t::singular_insert(const std::string& name, const if (exists) { symbol* sPrev = &(itrStart->second); - //Check if the symbol can be overloaded - if (!sPrev->bAllowOverload && sPrev->level > 0) { - std::string error = ""; - if (!sPrev->bVariable) { //Scripter attempted to overload a default function - error = StringUtility::Format("\"%s\": Function cannot be overloaded.", - name.c_str()); - } - else { //Scripter duplicated parameter/variable name - error = StringUtility::Format("\"%s\": Duplicated parameter name.", - name.c_str()); - } + if (sPrev->bVariable) { //Scripter duplicated parameter/variable name + std::string error = StringUtility::Format("\"%s\": Duplicated parameter name.", + name.c_str()); + parser_assert(false, error); + } + else if (!sPrev->bAllowOverload && sPrev->level > 0) { + //Scripter attempted to overload a default function + std::string error = StringUtility::Format("\"%s\": Function cannot be overloaded.", + name.c_str()); parser_assert(false, error); } else { @@ -632,23 +630,28 @@ int parser::scan_current_scope(parser_state_t* state, int level, int initVar, co if (dup) { //Woohoo for detailed error messages. std::string typeSub; - switch (dup->sub->kind) { - case block_kind::bk_function: - typeSub = "function"; - break; - case block_kind::bk_microthread: - typeSub = "task"; - break; - case block_kind::bk_sub: - typeSub = "sub or an \'@\' block"; - break; - default: - typeSub = "block"; - break; + if (dup->bVariable) { + typeSub = "variable"; + } + else { + switch (dup->sub->kind) { + case block_kind::bk_function: + typeSub = "function"; + break; + case block_kind::bk_microthread: + typeSub = "task"; + break; + case block_kind::bk_sub: + typeSub = "sub or an \'@\' block"; + break; + default: + typeSub = "block"; + break; + } } std::string error; - if (dup->bAllowOverload && countArgs >= 0) { + if (dup->bVariable || (dup->bAllowOverload && countArgs >= 0)) { error = "A " + typeSub; error += StringUtility::Format(" of the same name was already defined " "in the current scope: \'%s\'\r\n", name.c_str()); diff --git a/source/GcLib/gstd/Script/ScriptFunction.cpp b/source/GcLib/gstd/Script/ScriptFunction.cpp index 32581032..04959ca8 100644 --- a/source/GcLib/gstd/Script/ScriptFunction.cpp +++ b/source/GcLib/gstd/Script/ScriptFunction.cpp @@ -588,8 +588,12 @@ namespace gstd { else { if (_type_check_two_any(argv[0].get_type(), argv[1].get_type(), type_data::tk_float)) return value(script_type_manager::get_float_type(), _fmod2(argv[0].as_float(), argv[1].as_float())); - else - return value(script_type_manager::get_int_type(), _mod2(argv[0].as_int(), argv[1].as_int())); + else { + int64_t deno = argv[1].as_int(); + if (deno == 0) + throw std::string("Invalid operation: integer modulo by zero.\r\n"); + return value(script_type_manager::get_int_type(), _mod2(argv[0].as_int(), deno)); + } } } SCRIPT_DECLARE_OP(remainder_);