examples: fix compilation with -prod
parent
cf497623dc
commit
0567cbe431
|
@ -455,7 +455,6 @@ fn (mut app App) ai_move() {
|
||||||
move_idx := int(move)
|
move_idx := int(move)
|
||||||
predictions[move_idx].move = move
|
predictions[move_idx].move = move
|
||||||
mut mpoints := 0
|
mut mpoints := 0
|
||||||
mut mshifts := 0
|
|
||||||
mut mcmoves := 0
|
mut mcmoves := 0
|
||||||
for _ in 0 .. predictions_per_move {
|
for _ in 0 .. predictions_per_move {
|
||||||
mut cboard := app.board
|
mut cboard := app.board
|
||||||
|
@ -479,7 +478,6 @@ fn (mut app App) ai_move() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mpoints += cboard.points
|
mpoints += cboard.points
|
||||||
mshifts += cboard.shifts
|
|
||||||
mcmoves += cmoves
|
mcmoves += cmoves
|
||||||
}
|
}
|
||||||
predictions[move_idx].mpoints = f64(mpoints) / predictions_per_move
|
predictions[move_idx].mpoints = f64(mpoints) / predictions_per_move
|
||||||
|
|
|
@ -23,6 +23,7 @@ pub fn (a &A2D) set(x int, y int, newval int) {
|
||||||
mut e := &int(0)
|
mut e := &int(0)
|
||||||
e = a.data + y * a.maxx + x
|
e = a.data + y * a.maxx + x
|
||||||
*e = newval
|
*e = newval
|
||||||
|
_ = e // TODO compiler bug, this is not necessary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ pub fn (a &A2D) get(x int, y int) int {
|
||||||
unsafe {
|
unsafe {
|
||||||
mut e := &int(0)
|
mut e := &int(0)
|
||||||
e = a.data + y * a.maxx + x
|
e = a.data + y * a.maxx + x
|
||||||
|
_ = e
|
||||||
return *e
|
return *e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// that can be found in the LICENSE file.
|
// that can be found in the LICENSE file.
|
||||||
module ui
|
module ui
|
||||||
|
|
||||||
|
|
||||||
struct ExtraContext {
|
struct ExtraContext {
|
||||||
mut:
|
mut:
|
||||||
read_buf []byte
|
read_buf []byte
|
||||||
|
@ -15,16 +14,16 @@ const (
|
||||||
|
|
||||||
pub fn init(cfg Config) &Context {
|
pub fn init(cfg Config) &Context {
|
||||||
mut ctx := &Context{
|
mut ctx := &Context{
|
||||||
cfg: cfg,
|
cfg: cfg
|
||||||
}
|
}
|
||||||
ctx.read_buf = []byte{cap: cfg.buffer_size}
|
ctx.read_buf = []byte{cap: cfg.buffer_size}
|
||||||
|
|
||||||
// lmao
|
// lmao
|
||||||
unsafe {
|
unsafe {
|
||||||
x := &ctx_ptr
|
x := &ui.ctx_ptr
|
||||||
*x = ctx
|
*x = ctx
|
||||||
|
_ = x
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,12 +49,12 @@ pub fn (mut ctx Context) run() ? {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[inline]
|
|
||||||
// shifts the array left, to remove any data that was just read, and updates its len
|
// shifts the array left, to remove any data that was just read, and updates its len
|
||||||
// TODO: remove
|
// TODO: remove
|
||||||
|
[inline]
|
||||||
fn (mut ctx Context) shift(len int) {
|
fn (mut ctx Context) shift(len int) {
|
||||||
unsafe {
|
unsafe {
|
||||||
C.memmove(ctx.read_buf.data, byteptr(ctx.read_buf.data) + len, ctx.read_buf.cap - len)
|
C.memmove(ctx.read_buf.data, &byte(ctx.read_buf.data) + len, ctx.read_buf.cap - len)
|
||||||
ctx.resize_arr(ctx.read_buf.len - len)
|
ctx.resize_arr(ctx.read_buf.len - len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,5 +63,8 @@ fn (mut ctx Context) shift(len int) {
|
||||||
[inline]
|
[inline]
|
||||||
fn (mut ctx Context) resize_arr(size int) {
|
fn (mut ctx Context) resize_arr(size int) {
|
||||||
mut l := &ctx.read_buf.len
|
mut l := &ctx.read_buf.len
|
||||||
unsafe { *l = size }
|
unsafe {
|
||||||
|
*l = size
|
||||||
|
_ = l
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ pub fn info() &LiveReloadInfo {
|
||||||
unsafe {
|
unsafe {
|
||||||
mut p := &u64(&C.g_live_info)
|
mut p := &u64(&C.g_live_info)
|
||||||
*p = &u64(x)
|
*p = &u64(x)
|
||||||
|
_ = p
|
||||||
}
|
}
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ pub fn (mut bmp BitMap) draw_text_block(text string, block Text_block) {
|
||||||
|
|
||||||
for txt in text.split_into_lines() {
|
for txt in text.split_into_lines() {
|
||||||
bmp.space_cw = old_space_cw
|
bmp.space_cw = old_space_cw
|
||||||
mut w, mut h := bmp.get_bbox(txt)
|
mut w, _ := bmp.get_bbox(txt)
|
||||||
if w <= block.w || block.cut_lines == false {
|
if w <= block.w || block.cut_lines == false {
|
||||||
// println("Solid block!")
|
// println("Solid block!")
|
||||||
left_offset := int((block.w - w) * offset_flag)
|
left_offset := int((block.w - w) * offset_flag)
|
||||||
|
@ -83,13 +83,13 @@ pub fn (mut bmp BitMap) draw_text_block(text string, block Text_block) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bmp.space_cw = old_space_cw
|
bmp.space_cw = old_space_cw
|
||||||
w, h = bmp.get_bbox(tmp_str)
|
w, _ = bmp.get_bbox(tmp_str)
|
||||||
if w <= block.w {
|
if w <= block.w {
|
||||||
mut left_offset := int((block.w - w) * offset_flag)
|
mut left_offset := int((block.w - w) * offset_flag)
|
||||||
if bmp.justify && (f32(w) / f32(block.w)) >= bmp.justify_fill_ratio {
|
if bmp.justify && (f32(w) / f32(block.w)) >= bmp.justify_fill_ratio {
|
||||||
// println("cut phase!")
|
// println("cut phase!")
|
||||||
bmp.space_cw = 0.0
|
bmp.space_cw = 0.0
|
||||||
w, h = bmp.get_bbox(tmp_str)
|
w, _ = bmp.get_bbox(tmp_str)
|
||||||
left_offset = int((block.w - w) * offset_flag)
|
left_offset = int((block.w - w) * offset_flag)
|
||||||
bmp.space_cw = bmp.get_justify_space_cw(tmp_str, w, block.w, space_cw)
|
bmp.space_cw = bmp.get_justify_space_cw(tmp_str, w, block.w, space_cw)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -334,14 +334,14 @@ pub fn (mut ws Client) close(code int, message string) ? {
|
||||||
ws.reset_state()
|
ws.reset_state()
|
||||||
}
|
}
|
||||||
ws.set_state(.closing)
|
ws.set_state(.closing)
|
||||||
mut code32 := 0
|
// mut code32 := 0
|
||||||
if code > 0 {
|
if code > 0 {
|
||||||
code_ := C.htons(code)
|
code_ := C.htons(code)
|
||||||
message_len := message.len + 2
|
message_len := message.len + 2
|
||||||
mut close_frame := []byte{len: message_len}
|
mut close_frame := []byte{len: message_len}
|
||||||
close_frame[0] = byte(code_ & 0xFF)
|
close_frame[0] = byte(code_ & 0xFF)
|
||||||
close_frame[1] = byte(code_ >> 8)
|
close_frame[1] = byte(code_ >> 8)
|
||||||
code32 = (close_frame[0] << 8) + close_frame[1]
|
// code32 = (close_frame[0] << 8) + close_frame[1]
|
||||||
for i in 0 .. message.len {
|
for i in 0 .. message.len {
|
||||||
close_frame[i + 2] = message[i]
|
close_frame[i + 2] = message[i]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue