Skip to content

Commit

Permalink
Merge pull request #85 from Conarnar/sx-bugfix
Browse files Browse the repository at this point in the history
Bug fixes regarding some stuff
  • Loading branch information
Natashi authored Dec 18, 2024
2 parents caa7714 + 2e1bf23 commit 035d051
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 34 deletions.
14 changes: 7 additions & 7 deletions source/GcLib/directx/DirectSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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) {
Expand Down
53 changes: 28 additions & 25 deletions source/GcLib/gstd/Script/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
Expand Down
8 changes: 6 additions & 2 deletions source/GcLib/gstd/Script/ScriptFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down

0 comments on commit 035d051

Please sign in to comment.