Browse Source

ユーザ情報の保存

main
みてるぞ 1 year ago
parent
commit
4a1070103d
4 changed files with 57 additions and 3 deletions
  1. +8
    -1
      main.hsp
  2. +5
    -0
      modules/goatoh.mod.hsp
  3. +16
    -0
      modules/setting.mod.hsp
  4. +28
    -2
      modules/user.mod.hsp

+ 8
- 1
main.hsp View File

@@ -103,7 +103,14 @@

GMode GMODE_RGB0 ; アルファあり

Show@NameDialogue
Auth@User

If id@User > 0 {
;
}
Else {
Show@NameDialogue
}

Repeat
ReDraw False


+ 5
- 0
modules/goatoh.mod.hsp View File

@@ -1,3 +1,6 @@
#ifndef __GOATOH__
#define __GOATOH__

#module \
Goatoh

@@ -177,3 +180,5 @@ Interval

#global

#endif ; not __GOATOH__


+ 16
- 0
modules/setting.mod.hsp View File

@@ -1,3 +1,6 @@
#ifndef __SETTING__
#define __SETTING__

#module \
Setting

@@ -11,18 +14,26 @@ Setting
#const USER_PASSCODE_OFFSET (USER_ID_OFFSET + USER_ID_SIZE)
#const USER_PASSCODE_SIZE 16

; ユーザの引継ぎコード
#const USER_INHERITANCE_CODE_OFFSET (USER_PASSCODE_OFFSET + USER_PASSCODE_SIZE)
#const USER_INHERITANCE_CODE_SIZE 16

#deffunc local \
Load
userId = 0
SDim userPasscode, USER_PASSCODE_SIZE
SDim userInheritanceCode, USER_INHERITANCE_CODE_SIZE

Exist FILE_NAME
If strSize < 0 {
Save

Return
}

BLoad FILE_NAME, userId, USER_ID_SIZE, USER_ID_OFFSET
BLoad FILE_NAME, userPasscode, USER_PASSCODE_SIZE, USER_PASSCODE_OFFSET
BLoad FILE_NAME, userInheritanceCode, USER_INHERITANCE_CODE_SIZE, USER_INHERITANCE_CODE_OFFSET

Return

@@ -30,8 +41,13 @@ Load
Save
BSave FILE_NAME, userId, USER_ID_SIZE, USER_ID_OFFSET
BSave FILE_NAME, userPasscode, USER_PASSCODE_SIZE, USER_PASSCODE_OFFSET
BSave FILE_NAME, userInheritanceCode, USER_INHERITANCE_CODE_SIZE, USER_INHERITANCE_CODE_OFFSET

Load

Return

#global

#endif ; not __SETTING__


+ 28
- 2
modules/user.mod.hsp View File

@@ -1,4 +1,5 @@
#include "./modules/http.mod.hsp"
#include "./modules/setting.mod.hsp"


#ifndef __USER__
@@ -8,11 +9,11 @@
User

#define CREATE_URL (CONFIG_SERVER_URL + "/create_user.php")
#define FETCH_URL (CONFIG_SERVER_URL + "/fetch_user.php")
#define AUTH_URL (CONFIG_SERVER_URL + "/auth_user.php")

#deffunc local \
Create \
str p_name,
str p_name,\
local l_data
Fetch@Http CREATE_URL + "?name=" + p_name

@@ -29,15 +30,40 @@ Create \
inheritanceCode = ""
}

Save@Setting

Return

#deffunc local \
Auth \
int p_id,\
local l_data
Load@Setting

id = userId@Setting
pass = userPasscode@Setting

If id <= 0 {
Return
}

Fetch@Http AUTH_URL + "?id=" + id + "&pass=" + pass

If status@Http = STATUS_SUCCESS@Http {
Split data@Http, ",", l_data

If Int (l_data.0) = 0 {
id = 0

Return
}

name = l_data.1
}
Else {
id = 0
}

Return

#global


Loading…
Cancel
Save