• Register

Sound designer/Game Developer based in South Yorkshire, UK

RSS My Blogs  (0 - 10 of 11)

is possible!!

took a while for me to find it. sharing here in case anyone else has similar issue and somehow their search takes them here.. (as long as your device has SD card, anyway...)

first, if you haven't already, get the android sdk (or adb through some other method)..

connect android device with usb debugging enabled (wait for drivers to install if not already done).

only have 1 android device connected for -d to work later on.

navigate in command window to location of adb. (start menu/run/cmd, then go to C:\adt-bundle-windows-x86-20130219\sdk\platform-tools or wherever..)

type:
adb -d shell
(should connect, no error messages)

then
cat /data/data/com.square_enix.android_googleplay.FFIII_GP/files/save.bin > /sdcard/save.bin

and that's it! it's now on your sd card, in the root. putting it back may be more of an issue without rooting, but at least you have it!! :)

#include <cstdio>


class aclass
{
public:
    const int intvalue;
    const int intvalue2;

    aclass(int val = 89) : intvalue(val),intvalue2(val)//constructor
    {
     //stuff - intvalue = 23, but it could not be set here!
    }
};

main()
{
    aclass *nm = new aclass(66);
    aclass &amp;mm = *nm;

    printf ("%d\n" , mm.intvalue);
}

c++

int x
int* px = &amp;x;
int&amp; y = *px;

//y is now an int pointing to exactly the same data as x

initialisation list:-

class aclass
{
public:
    const int intvalue;
    const int intvalue2;
 
    aclass() : intvalue(23),intvalue2(25)//constructor
    {
     //stuff - intvalue = 23, but it could not be set here!
    }
};

c++ ref

int x = 9;
int &amp;y = x;

unity code:-

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	
	
	
	class qVector2
	{
		public float x;
		public float y;
		
		public qVector2(float a = 0.0f, float b = 0.0f)
		{
			x = a;
			y = b;
		}
	}
	
	void Start ()
	{
		Vector2 test = new Vector2(3.4f,2.2f);
		
		Vector2 test2 = test;//test2 is new'd and whole of test is copied into it - each Vector2 points to a different memory area.
		
		test2.x = 100.0f;
		
		Debug.Log (test.x);//still = 3.4
		
		
		
		
		
		
		qVector2 qtest = new qVector2(3.4f,2.2f);
		
		qVector2 qtest2 = qtest;//done as pointer, no data copy
		
		qtest2.x = 100.0f;
		
		Debug.Log (qtest.x);//now 100
		
		
	}
	

}

const in c++

TommyGoogle Blog

c++:-

#include <iostream>
using namespace std;

class testclass
{
    public:
    int t;
    int g;

    void cannotbreakme () const;//const means that the member variables of an instance of this class cannot be altered by this function.
};

    void testclass::cannotbreakme() const
    {
        //can't alter the value of t, just read it.
        cout << t;
    }

void copyit (testclass theclass)
{
    //will copy all of the data from theclass, so slow
    cout << theclass.t;
}


void nocons (testclass &amp;theclass)
{
    //passed by reference - fast, but can alter the values in the class
    theclass.t = 7;
}

void withcons (const testclass &amp;theclass)
{
    //passed by reference again, so fast - cannot alter any of it, just read
    cout << theclass.t;
}




int main ()
{

    testclass iamtestclass;

    copyit(iamtestclass);

    nocons(iamtestclass);

    cout << iamtestclass.t;

    withcons(iamtestclass);


    int const * valuepointedatcannotbechanged;//or const int *

    //int * const locationpointedtocannotbechanged;

    //int const * const neithercanbechanged;


    return 0;
}

int const * getvalue()
{
    static int send = 7;

    return &amp;send;
}

//values returned from functions can also be const - here the static int send within this function cannot be altered using the returned pointer.

also, this will not compile

void whatnow (const testclass *theclass)
{
    theclass->t = 7;
}

which is good!


I should look at unity now - try to do a gameobject.localposition = existingVector3, see what happens.. shouldn't let me?

c# in unity - pointers are going on - so arrays can be resized without massive memory copying...

using UnityEngine;
using System.Collections;

public class somedata
{
	
	public int first = 4;
	public int fishies = 99;
}
	

public class example : MonoBehaviour {
	
	
	void Start ()
	{
		somedata[] thearray = new somedata[5];
		
		thearray[2] = new somedata();
						
		thearray[1] = thearray[2];//the = here makes these both point to the same memory - not a copy!
		
		Debug.Log (thearray[1].first);
		
		thearray[2].first = 1987;
		
		Debug.Log (thearray[1].first);//so this now = 1987
		
		thearray[3] = new somedata();
		thearray[3] = thearray[2];//the memory created with the above new will now be marked for chucking away.
		
		thearray[3].first = 2000;
		Debug.Log (thearray[2].first);//as above, the = made these both point to the same memory - not a copy!
	}
	

}

Here's c++

#include <iostream>
using namespace std;



void byref (int&amp; theint)//byref(testint);
{
    theint = 1;
}



void usingpointer (int *ptotheint)//usingpointer(&amp;testint);
{
    *ptotheint = 1;
}



int main ()
{
    int testint = 0;
    byref(testint);
    cout << testint;//1

    testint = 0;
    usingpointer(&amp;testint);
    cout << testint;//1



    return 0;
}

c sharp in unity

using UnityEngine;
using System.Collections;

public class byreferenceexample : MonoBehaviour {

	void byref (ref int theint)
	{
		theint = 1;
	}
	
	
	
	void Start ()
	{
		int testint = 0;
		
		byref (ref testint);
		
		Debug.Log (testint);// =1
	}
	

}

C++ Array stuff

TommyGoogle Blog

OK, so here's some C++ array stuff to remember..

class theclassname
{
    public:
    int myint;

    theclassname(int givemeanint = 23);//constructor
};

    theclassname::theclassname(int givemeanint)
    {
     myint = givemeanint;
    }



main()
{
    theclassname instanceofclass;//can be done - as all arguments in constructor have default values, likewise:-
    theclassname[55] arrayofit;//is also fine - myint in all of them will be 23. If a default value had not been given, i don't believe an array could be created..
}

edit 3 - just deleted this whole post in one click that was misdirected by stupid android web browser.. but no confirmation from desura?? not good!!

was still in laptop's history.. so i got it back..

anyway - my fix worked! and got other stuff working in android..

gonna have a belter of a thing soon!!

:)


any ideas about this:-

#pragma strict

function Start () {

var arrayofclass:iamaclass[] = new iamaclass[2];

}


class iamaclass
{

  function iamaclass()
  {
  Debug.Log("i am not happenning - no constructors with arrays??");
  }

}  

??

is it even possible to set multiple constructors at once for an array of classes, or do i need a for loop to do this manually after each time that i want to do it?? is that how it should be done??

edit:-
Turns out that constructors are run for each instance in an array of class instances, but only if they don't want anything in the brackets..

#pragma strict

var arrayofclass:iamaclass[];

function Start () {

arrayofclass = new iamaclass[2];

}


class iamaclass
{

var hooter:int;

var dooter:int;

  function iamaclass(passed:int)
  {
  hooter = passed;
  dooter = 34;
  }

} 

in this example, the constructor won't be run!

#pragma strict

var arrayofclass:iamaclass[];

function Start () {

arrayofclass = new iamaclass[2];

}


class iamaclass
{

var spooter:int;

var dooter:int;

  function iamaclass()
  {
  var passed:int = 33;
  spooter = passed;
  dooter = 34;
  }

} 

but here, it will!!

edit 2- got some valuable tips from here:-
Answers.unity3d.com
regarding instantiation of built in arrays of classes

if you are going to do:-
var personArray : Person[] = new Person[700];

and then instantly attempt to access
personArray[352].name
or similar, you'll get an error...this object doesn't exist!! (though accessing it "a while" later will work fine!?!?!)
what is needed, as stated at the above address:-

"You need to instantiate a Person object for each element of the newly-declared array. The easiest way to do this would be in a for loop that iterates through the array, calling personArray[i]= new Person(); "

(cheers noony!)

if you DON'T do this, however, it seems that unity's explorer WILL automatically instantiate person objects for this array if you run your code within the unity environment, though it will take a while (seemingly 2 update frames every time on my pc..) for this to occur.. potentially leading to some very hard to spot bugs, and almost certainly leading to code that works fine in the unity environment thingy (what's the actual word for this!?!) but won't run when compiled for anything else!!

at least i think that this is what is happening.. i'm gonna see if altering this fixes my thing that isn't working anywhere except within unity...

Arrays!!

TommyGoogle Blog

ok - so here's some Unity Javascript kind of explaining what i've found out about arrays...

#pragma strict


var javascriptarray:Array = ["hello",9];//each is untyped, so this doesn't appear in inspector.. this can be resized at runtime - but sloooow...
//or.. var javascriptarray:Array = new Array();//needs = new Array(); if not giving data to begin with, or there will be no instance to add anything to..
javascriptarray.Push ("yep");//adds "yep" to next slot..


var arraylist:ArrayList = new ArrayList();//not viewable in inspector, CAN be resized, untyped, slower than built in...
arraylist.Add ("hello");//can be done here


var builtinarrayofints:int[] = [0,1,2,3,4,5,6,7];//has a type - so visible in inspector, and can be resized there - but not resizeable at runtime!!.
var builtin2darrayofints:String[,] = new String[3,9];;//a 2 dimensional array (3*9).. not visible in inspector..
builtin2darrayofints[2,8] = "last one!";//this can be done here (not in a function)!



function Start () {

//these come from the above things.
Debug.Log(arraylist[0]);//"hello"
Debug.Log(builtin2darrayofints[2,8]);//"last one!"



//you can have trouble with whether you are passing a value or a reference to the original data.. see below..

var integer:int = 0;
var arrayofints:int[] = [10,20];

Debug.Log(integer);
Debug.Log(arrayofints[0]);
Debug.Log(arrayofints[1]);


mangler (integer, arrayofints);


Debug.Log(integer);//still shows 0
Debug.Log(arrayofints[0]);//now shows 1000000
Debug.Log(arrayofints[1]);


}



function mangler (integer:int, array:int[])
{
integer = 1000000;
array[0] = 1000000;

}