Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Glitches in scripts  (Read 5949 times)

0 Members and 1 Guest are viewing this topic.

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Glitches in scripts
« 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?
« Last Edit: December 29, 2012, 03:35:03 AM by 2.0 »
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Glitches in scripts
« Reply #1 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.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

2.0

  • Regular poster
  • ***
  • Karma: 4
  • Offline Offline
  • Posts: 217
    • View Profile
Re: Glitches in scripts
« Reply #2 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.
Logged
 

Page created in 0.148 seconds with 21 queries.