Can you try subversion sources? As of r8341, AG_SetFoo() and the saving
of variables previously created with AG_BindFoo() should now be working
as expected.
I've also added a test case under demos/configsettings.
On Tue, Aug 25, 2009 at 10:46:26PM +0000, Olexandr Sydorchuk wrote:
> I want to continue topic. I'd like to see some this future its
> great, you don't need to catch exit hook of app to save variables, etc.
>
> Offcause variable not saved after bind* - agVariableTypes[]->typeTgt=-1
> for poiner, so here simple patch for Uint32 only:
>
> --8<---------------cut here---------------start------------->8---
> Index: variable.c
> ===================================================================
> --- variable.c (revision 8300)
> +++ variable.c (working copy)
> @@ -43,7 +43,7 @@
> { AG_VARIABLE_SINT16, 0, "Sint16",
> AG_VARIABLE_SINT16, 5 },
> { AG_VARIABLE_P_SINT16, 1, "Sint16 *",
> AG_VARIABLE_SINT16, -1 },
> { AG_VARIABLE_UINT32, 0, "Uint32",
> AG_VARIABLE_UINT32, 6 },
> - { AG_VARIABLE_P_UINT32, 1, "Uint32 *" ,
> AG_VARIABLE_UINT32, -1 },
> + { AG_VARIABLE_P_UINT32, 1, "Uint32 *" ,
> AG_VARIABLE_P_UINT32, 6 },
> { AG_VARIABLE_SINT32, 0, "Sint32",
> AG_VARIABLE_SINT32, 7 },
> { AG_VARIABLE_P_SINT32, 1, "Sint32 *",
> AG_VARIABLE_SINT32, -1 },
> { AG_VARIABLE_UINT64, 0, "Uint64",
> AG_VARIABLE_UINT64, 8 },
> Index: object.c
> ===================================================================
> --- object.c (revision 8300)
> +++ object.c (working copy)
> @@ -1229,6 +1229,7 @@
> case AG_VARIABLE_UINT16: AG_WriteUint16(ds, V->data.u16);
> break;
> case AG_VARIABLE_SINT16: AG_WriteSint16(ds, V->data.s16);
> break;
> case AG_VARIABLE_UINT32: AG_WriteUint32(ds, V->data.u32);
> break;
> + case AG_VARIABLE_P_UINT32: AG_WriteUint32(ds, (Uint)*(Uint8
> *)V->data.p); break;
> case AG_VARIABLE_SINT32: AG_WriteSint32(ds, V->data.s32);
> break;
> case AG_VARIABLE_FLOAT: AG_WriteFloat(ds, V->data.flt);
> break;
> case AG_VARIABLE_DOUBLE: AG_WriteDouble(ds, V->data.dbl);
> break;
> --8<---------------cut here---------------end--------------->8---
>
> It make possible to save pointer as uint32 to file and load him,
> but (maybe) need some api to setup variable when binding i.e instead of
>
> #v+
> value = AG_GetUint32(agConfig, "Value");
> // we wish set prev. saved value
> AG_BindUint32(agConfig, "Value", &value);
>
> #v-
>
> need some AG_BindAndSet or other, nut it no so important.
>
> Some test:
>
> --8<---------------cut here---------------start------------->8---
> Uint8 value = 0;
> int
> main(int argc, char *argv[])
> {
>
> if (AG_InitCore("ag-bind-test", 0) == -1) {
> fprintf(stderr, "%s\n", AG_GetError());
> return (1);
> }
> fprintf(stdout, "cheking for 'Value' (AG_GetUint32) %u\n",
> AG_GetUint32(agConfig, "Value"));
>
> value = AG_GetUint32(agConfig, "Value");
> AG_BindUint32(agConfig, "Value", &value);
>
> if (!AG_GetBool(agConfig, "not.first.run")){
> value = 1;
> fprintf(stdout, "Looks it run first! set 'Value' to %i\n",
> value);
> }
> value++; // inc binded variable
> fprintf(stdout, "AG_BindUint32, Value = %i\n", AG_GetUint32(agConfig,
> "Value"));
>
> AG_SetBool(agConfig, "not.first.run", 1);
> AG_ConfigSave();
> AG_Destroy();
> return (0);
> --8<---------------cut here---------------end--------------->8---
>
> and output:
>
> #v+
> %rm -r ~/.ag-bind-test/*
> %./loader
> cheking for 'Value' (AG_GetUint32) 0
> Looks it run first! set 'Value' to 1
> after AG_BindUint32, Value = 2
> %./loader
> cheking for 'Value' (AG_GetUint32) 2
> after AG_BindUint32, Value = 3
> #v-
>
> _______________________________________________
> Agar mailing list
> [email protected]
> http://libagar.org/lists.html
_______________________________________________
Agar mailing list
[email protected]
http://libagar.org/lists.html