|
Script Crash!!! :P
#411107
11/13/12 10:36
11/13/12 10:36
|
Joined: Nov 2011
Posts: 139 India
Yashas
OP
Member
|
OP
Member
Joined: Nov 2011
Posts: 139
India
|
int WriteProfileToFile(STRING * ProfileFile,UserProfile* profile)
{
STRING * ResultString;
var filehandle = file_open_write(ProfileFile);
file_str_write(filehandle,profile->Password);
file_str_write(filehandle,",");
file_str_write(filehandle,profile->Name);
file_str_write(filehandle,",");
str_for_num(ResultString,profile->DOB.day);
error(ResultString);
file_str_write(filehandle,ResultString);
file_str_write(filehandle,",");
str_for_num(ResultString,profile->DOB.month);
file_str_write(filehandle,ResultString);
file_str_write(filehandle,",");
str_for_num(ResultString,profile->DOB.year);
file_str_write(filehandle,ResultString);
file_str_write(filehandle,",");
str_for_num(ResultString,profile->DOC.day);
file_str_write(filehandle,ResultString);
file_str_write(filehandle,",");
str_for_num(ResultString,profile->DOC.month);
file_str_write(filehandle,ResultString);
file_str_write(filehandle,",");
str_for_num(ResultString,profile->DOC.year);
file_str_write(filehandle,ResultString);
file_str_write(filehandle,",");
file_close(filehandle);
return 0;
}
The above code is causing Script Crash , error gives "Script Crash in WriteProfileToFile." This how I submit the arguments and call WriteProfileToFile.
void RegisterUser ()
{
STRING * ProfileFile = str_cat(str_cat(str_create("Accounts\\"),((LoginPrompt_Name->pstring)[0])),".ini");
if(file_exists(ProfileFile))
{
snd_play(ErrorSound,MenuVolume,MenuBalance);
(LoginStatus_Message->pstring)[0] = "Username already in use(Choose another Username)";
LoginStatus_Message->red = 255;
LoginStatus_Message->blue = 0;
LoginStatus_Message->green = 0;
return;
}
else
{
ActiveProfile.DOC.day = sys_day;
ActiveProfile.DOC.month = sys_month;
ActiveProfile.DOC.year = sys_year;
ActiveProfile.DOB.day = 0;
ActiveProfile.DOB.month = 0;
ActiveProfile.DOB.year = 0;
ActiveProfile.BPI = 0;
ActiveProfile.XP = 10;
ActiveProfile.RegionSpeed = 0;
ActiveProfile.RegionMemory = 0;
ActiveProfile.RegionAttentition = 0;
ActiveProfile.RegionFlexibility = 0;
ActiveProfile.RegionLogic = 0;
ActiveProfile.MostCommonRegion = 0;
ActiveProfile.SelectedRegion = 0;
ActiveProfile.BestRegion = 0;
ActiveProfile.Name = (LoginPrompt_Name->pstring)[0];
ActiveProfile.Password = (LoginPrompt_Pass->pstring)[0];
WriteProfileToFile(ProfileFile,&ActiveProfile);
(LoginStatus_Message->pstring)[0] = "User Profile Registered";
LoginStatus_Message->red = 160;
LoginStatus_Message->blue = 160;
LoginStatus_Message->green = 160;
LoginUser();
}
}
Just want to know whats causing the script crash. Thanks and Regards!
|
|
|
Re: Script Crash!!! :P
[Re: Yashas]
#411109
11/13/12 10:41
11/13/12 10:41
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
Remember our discussion about intializing pointers?
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Script Crash!!! :P
[Re: Yashas]
#411120
11/13/12 11:59
11/13/12 11:59
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
It almost slaps in your face. First line in WriteProfileToFile. ^^ And RegisterUser again contains a memory leak. 
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Script Crash!!! :P
[Re: Uhrwerk]
#411125
11/13/12 13:32
11/13/12 13:32
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
And RegisterUser again contains a memory leak.  It's STRING * ProfileFile = "[...]";, isn't it? ( I'm just asking because I'm not sure whether I am right or not. )
Last edited by Kartoffel; 11/13/12 13:39.
POTATO-MAN saves the day! - Random
|
|
|
Re: Script Crash!!! :P
[Re: Yashas]
#411142
11/13/12 17:18
11/13/12 17:18
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Someone ban me for a day else I will not learn :'( I think I am REALLY STUPID.
btw Thanks lol, what? is this related to the memory leak?
POTATO-MAN saves the day! - Random
|
|
|
Re: Script Crash!!! :P
[Re: Yashas]
#411147
11/13/12 18:49
11/13/12 18:49
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
I think I am REALLY STUPID. Relax. You just overlooked something. Happens to everyone sometimes. @Kartoffel: I guess it's related to the unitialized pointer. We had exactly this topic a few days ago.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|