handle login better, get rid of ghost self

This commit is contained in:
zongor 2023-10-13 19:55:10 -04:00
parent f323d09d9f
commit b44d3e03ca
6 changed files with 27 additions and 6 deletions

Binary file not shown.

View File

@ -31,8 +31,8 @@ program main
me = player(username, vector3(0.0_c_float, 1.0_c_float, 2.0_c_float), PURPLE) me = player(username, vector3(0.0_c_float, 1.0_c_float, 2.0_c_float), PURPLE)
players = me%login(password) players = me%login(password)
camera%position = vector3(0.0_c_float, 10.0_c_float, 10.0_c_float) !Camera position camera%position = vector3(me%position%x,me%position%y + 10.0_c_float , me%position%z + 10.0_c_float ) !Camera position
camera%target = vector3(0.0_c_float, 0.0_c_float, 0.0_c_float) !Camera looking at point camera%target = vector3(me%position%x,me%position%y,me%position%z) !Camera looking at point
camera%up = vector3(0.0_c_float, 1.0_c_float, 0.0_c_float) !Camera up vector(rotation towards target) camera%up = vector3(0.0_c_float, 1.0_c_float, 0.0_c_float) !Camera up vector(rotation towards target)
camera%fovy = 45.0_c_float !Camera field - of - view Y camera%fovy = 45.0_c_float !Camera field - of - view Y
camera%projection = CAMERA_PERSPECTIVE !Camera projection type camera%projection = CAMERA_PERSPECTIVE !Camera projection type

View File

@ -116,7 +116,7 @@ contains
call json%serialize(root, str) call json%serialize(root, str)
call json%print(root) call json%print(root)
connection = suffix_attach(connection, TCP_SUFFIX, 2_c_size_t) connection = suffix_attach(connection, TCP_SUFFIX, 2_c_size_t)
rc = msend(connection, f_c_string(str, .true.), & rc = msend(connection, f_c_string(str, .true.), &
@ -157,6 +157,7 @@ contains
call json%get(recv_users, "/users/"//istr//"/username", username, found) call json%get(recv_users, "/users/"//istr//"/username", username, found)
if (.not. found) stop 1 if (.not. found) stop 1
if (username .ne. this%username) then
if (allocated(players)) then if (allocated(players)) then
players = [players, player(username, vector3(x_pos, 1.0_c_float, y_pos), & players = [players, player(username, vector3(x_pos, 1.0_c_float, y_pos), &
color(apperance_r, apperance_g, apperance_b, 255))] color(apperance_r, apperance_g, apperance_b, 255))]
@ -164,12 +165,26 @@ contains
players = [player(username, vector3(x_pos, 1.0_c_float, y_pos), & players = [player(username, vector3(x_pos, 1.0_c_float, y_pos), &
color(apperance_r, apperance_g, apperance_b, 255))] color(apperance_r, apperance_g, apperance_b, 255))]
end if end if
else
if (request_type .eq. 1) then
print *, 'login, setting pos'
this%position%x = x_pos
this%position%y = y_pos
print *, x_pos, y_pos
print *, 'login, setting apperance'
this%apperance%r = apperance_r
this%apperance%g = apperance_g
this%apperance%b = apperance_b
print *, apperance_r, apperance_g, apperance_b
end if
end if
end do end do
end if end if
nullify (recv_users) nullify (recv_users)
call json%destroy() call json%destroy()
rc = tcp_close(connection, -1_c_int64_t) rc = tcp_close(connection, -1_c_int64_t)
end function send_packet end function send_packet

View File

@ -81,7 +81,6 @@ program main
rc = db_move_user(db, username, x_pos, y_pos) rc = db_move_user(db, username, x_pos, y_pos)
else ! (2) if logout update logged_in to database else ! (2) if logout update logged_in to database
rc = db_logout_user(db, username) rc = db_logout_user(db, username)
exit server_loop
end if end if
rc = db_get_logged_in_users(db, connection) rc = db_get_logged_in_users(db, connection)

View File

@ -231,7 +231,7 @@ contains
integer function db_logout_user(db, username) result(rc) integer function db_logout_user(db, username) result(rc)
type(db_type), intent(inout) :: db type(db_type), intent(inout) :: db
character(len=24), intent(in) :: username character(len=:), allocatable, intent(in) :: username
type(c_ptr) :: stmt type(c_ptr) :: stmt
rc = sqlite3_prepare_v2(db%ptr, & rc = sqlite3_prepare_v2(db%ptr, &

View File

@ -0,0 +1,7 @@
program main
use iso_fortran_env
implicit none
write(output_unit, "(i3, 1x, a24, 1x, f8.2, 1x, f8.2)") 0, 'chakr', 0.0, 0.0
end program main