diff --git a/common/sql/test.db3 b/common/sql/test.db3 index c9e1858..351cb55 100644 Binary files a/common/sql/test.db3 and b/common/sql/test.db3 differ diff --git a/fortran/client/app/main.f90 b/fortran/client/app/main.f90 index 083a830..530ce9d 100644 --- a/fortran/client/app/main.f90 +++ b/fortran/client/app/main.f90 @@ -31,8 +31,8 @@ program main me = player(username, vector3(0.0_c_float, 1.0_c_float, 2.0_c_float), PURPLE) players = me%login(password) - camera%position = vector3(0.0_c_float, 10.0_c_float, 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%position = vector3(me%position%x,me%position%y + 10.0_c_float , me%position%z + 10.0_c_float ) !Camera position + 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%fovy = 45.0_c_float !Camera field - of - view Y camera%projection = CAMERA_PERSPECTIVE !Camera projection type diff --git a/fortran/client/src/player.f90 b/fortran/client/src/player.f90 index c3f8346..bac4d0d 100644 --- a/fortran/client/src/player.f90 +++ b/fortran/client/src/player.f90 @@ -116,7 +116,7 @@ contains call json%serialize(root, str) call json%print(root) - + connection = suffix_attach(connection, TCP_SUFFIX, 2_c_size_t) rc = msend(connection, f_c_string(str, .true.), & @@ -157,6 +157,7 @@ contains call json%get(recv_users, "/users/"//istr//"/username", username, found) if (.not. found) stop 1 + if (username .ne. this%username) then if (allocated(players)) then players = [players, player(username, vector3(x_pos, 1.0_c_float, y_pos), & 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), & color(apperance_r, apperance_g, apperance_b, 255))] 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 if nullify (recv_users) call json%destroy() - + rc = tcp_close(connection, -1_c_int64_t) end function send_packet diff --git a/fortran/server/app/main.f90 b/fortran/server/app/main.f90 index 59057fa..c7fb0e5 100644 --- a/fortran/server/app/main.f90 +++ b/fortran/server/app/main.f90 @@ -81,7 +81,6 @@ program main rc = db_move_user(db, username, x_pos, y_pos) else ! (2) if logout update logged_in to database rc = db_logout_user(db, username) - exit server_loop end if rc = db_get_logged_in_users(db, connection) diff --git a/fortran/server/src/db.f90 b/fortran/server/src/db.f90 index 66e060a..fabe862 100644 --- a/fortran/server/src/db.f90 +++ b/fortran/server/src/db.f90 @@ -231,7 +231,7 @@ contains integer function db_logout_user(db, username) result(rc) type(db_type), intent(inout) :: db - character(len=24), intent(in) :: username + character(len=:), allocatable, intent(in) :: username type(c_ptr) :: stmt rc = sqlite3_prepare_v2(db%ptr, & diff --git a/fortran/server/test/server_test.f90 b/fortran/server/test/server_test.f90 new file mode 100644 index 0000000..68dc289 --- /dev/null +++ b/fortran/server/test/server_test.f90 @@ -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 \ No newline at end of file