Wintermute Engine Forum

Wintermute Engine => WME Lite => Topic started by: 2.0 on December 29, 2012, 03:30:35 AM

Title: Glitches in scripts
Post by: 2.0 on December 29, 2012, 03:30:35 AM
Hi!

Have some bugs at iPad. For example running this code in one script crushes the device.
Code: WME Script
  1. for (var t=0; t<=1; t=t+0.02)
  2. {
  3.         Twin.X = ToInt(Math.Pow((1-t),2)*this.X + 2*t*(1-t)*O1.X + t*t*P2.X);
  4.         Twin.Y = ToInt(Math.Pow((1-t),2)*this.Y + 2*t*(1-t)*O1.Y + t*t*P2.Y);
  5.        
  6.         if (t<0.6) d = d*1.025;
  7.         else d = d*1.05;
  8.                        
  9.         Sleep(20);
  10. }

All variables are initialized.
In other script this kind of code works properly.
In device emulator, and in lite and full versions of WME on PC all works correctly too.
What it can be?
Title: Re: Glitches in scripts
Post by: Mnemonic on December 30, 2012, 01:58:45 PM
I believe it's related to aligned memory access on arm7 processors. Namely the CScScript::GetFloat() method is probably the culprit. It should be changed to something like this:

Code: [Select]
double CScScript::GetFloat()
{
  double ret;
  memcpy(&ret, m_Buffer+m_IP, sizeof(double));
  m_IP += sizeof(double);
  return ret;
}
I'm just guessing here, though.
Title: Re: Glitches in scripts
Post by: 2.0 on January 08, 2013, 02:17:17 AM
Hmm... Seems in my case it works.
Thanks :)

I believe it's related to aligned memory access on arm7 processors. Namely the CScScript::GetFloat() method is probably the culprit. It should be changed to something like this:

Code: [Select]
double CScScript::GetFloat()
{
  double ret;
  memcpy(&ret, m_Buffer+m_IP, sizeof(double));
  m_IP += sizeof(double);
  return ret;
}
I'm just guessing here, though.