Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes regarding some stuff #85

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions source/GcLib/directx/DirectSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,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 @@ -1141,11 +1141,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 @@ -1370,10 +1370,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 @@ -189,17 +189,15 @@ parser::symbol* parser::scope_t::singular_insert(const std::string& name, const
if (exists) {
symbol* sPrev = &(itr.first->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 @@ -634,23 +632,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 @@ -585,8 +585,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