id
int64
4
16.3M
file_name
stringlengths
3
68
file_path
stringlengths
14
181
content
stringlengths
39
9.06M
size
int64
39
9.06M
language
stringclasses
1 value
extension
stringclasses
2 values
total_lines
int64
1
711k
avg_line_length
float64
3.18
138
max_line_length
int64
10
140
alphanum_fraction
float64
0.02
0.93
repo_name
stringlengths
7
69
repo_stars
int64
2
61.6k
repo_forks
int64
12
7.81k
repo_open_issues
int64
0
1.13k
repo_license
stringclasses
10 values
repo_extraction_date
stringclasses
657 values
exact_duplicates_stackv2
bool
1 class
exact_duplicates_stackv1
bool
1 class
exact_duplicates_redpajama
bool
1 class
exact_duplicates_githubcode
bool
2 classes
near_duplicates_stackv2
bool
1 class
near_duplicates_stackv1
bool
1 class
near_duplicates_redpajama
bool
1 class
near_duplicates_githubcode
bool
2 classes
13,343,368
queue.h
weynhamz_GNOME-anjuta/plugins/debug-manager/queue.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* queue.h Copyright (C) 2005 Sébastien Granjoux This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef QUEUE_H #define QUEUE_H /*---------------------------------------------------------------------------*/ #include "plugin.h" #include "command.h" #include <libanjuta/anjuta-plugin.h> #include <libanjuta/interfaces/ianjuta-debugger.h> #include <libanjuta/interfaces/ianjuta-debugger-breakpoint.h> #include <glib.h> typedef enum { HAS_BREAKPOINT = 1 << 1, HAS_ADDRESS_BREAKPOINT = IANJUTA_DEBUGGER_BREAKPOINT_SET_AT_ADDRESS * HAS_BREAKPOINT * 2, HAS_FUNCTION_BREAKPOINT = IANJUTA_DEBUGGER_BREAKPOINT_SET_AT_FUNCTION * HAS_BREAKPOINT * 2, HAS_ENABLE_BREAKPOINT = IANJUTA_DEBUGGER_BREAKPOINT_ENABLE * HAS_BREAKPOINT * 2, HAS_IGNORE_BREAKPOINT = IANJUTA_DEBUGGER_BREAKPOINT_IGNORE * HAS_BREAKPOINT * 2, HAS_CONDITION_BREAKPOINT = IANJUTA_DEBUGGER_BREAKPOINT_CONDITION * HAS_BREAKPOINT * 2, HAS_VARIABLE = 1 << 8, HAS_REGISTER = 1 << 9, HAS_MEMORY = 1 << 10, HAS_INSTRUCTION = 1 << 11 } DmaDebuggerCapability; typedef struct _DmaDebuggerQueueClass DmaDebuggerQueueClass; #define DMA_DEBUGGER_QUEUE_TYPE (dma_debugger_queue_get_type ()) #define DMA_DEBUGGER_QUEUE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DMA_DEBUGGER_QUEUE_TYPE, DmaDebuggerQueue)) #define DMA_DEBUGGER_QUEUE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DMA_DEBUGGER_QUEUE_TYPE, DmaDebuggerQueueClass)) #define IS_DMA_DEBUGGER_QUEUE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DMA_DEBUGGER_QUEUE_TYPE)) #define IS_DMA_DEBUGGER_QUEUE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DMA_DEBUGGER_QUEUE_TYPE)) GType dma_debugger_queue_get_type (void); DmaDebuggerQueue *dma_debugger_queue_new (AnjutaPlugin *plugin); void dma_debugger_queue_free (DmaDebuggerQueue *this); gboolean dma_debugger_queue_append (DmaDebuggerQueue *self, DmaQueueCommand *cmd); gboolean dma_debugger_queue_start (DmaDebuggerQueue *self, const gchar *mime_type); void dma_debugger_queue_stop (DmaDebuggerQueue *self); void dma_debugger_queue_enable_log (DmaDebuggerQueue *self, IAnjutaMessageView *log); void dma_debugger_queue_disable_log (DmaDebuggerQueue *self); gboolean dma_debugger_queue_is_supported (DmaDebuggerQueue *self, DmaDebuggerCapability capability); IAnjutaDebuggerState dma_debugger_queue_get_state (DmaDebuggerQueue *self); void dma_debugger_queue_command_callback (const gpointer data, gpointer user_data, GError* err); #endif
3,212
C
.h
56
54.892857
126
0.749681
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,370
info.h
weynhamz_GNOME-anjuta/plugins/debug-manager/info.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* gdb_info.h Copyright (C) Naba Kumar <[email protected]> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __GDB_INFO_H__ #define __GDB_INFO_H__ #include <stdio.h> gboolean gdb_info_show_file (GtkWindow *parent, const gchar * path, gint height, gint width); gboolean gdb_info_show_command (GtkWindow *parent, const gchar * command_line, gint height, gint width); gboolean gdb_info_show_string (GtkWindow *parent, const gchar * s, gint height, gint width); gboolean gdb_info_show_filestream (GtkWindow *parent, FILE * f, gint height, gint width); gboolean gdb_info_show_fd (GtkWindow *parent, int file_descriptor, gint height, gint width); void gdb_info_show_list (GtkWindow *parent, const GList* list, gint height, gint width); #endif
1,576
C
.h
33
42.969697
82
0.717831
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,375
chunk_view.h
weynhamz_GNOME-anjuta/plugins/debug-manager/chunk_view.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* chunk_view.h Copyright (C) 2006 Sebastien Granjoux This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _CHUNK_VIEW_H #define _CHUNK_VIEW_H #include <gtk/gtk.h> #define DMA_CHUNK_VIEW_TYPE (dma_chunk_view_get_type ()) #define DMA_CHUNK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DMA_CHUNK_VIEW_TYPE, DmaChunkView)) #define DMA_CHUNK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DMA_CHUNK_VIEW_TYPE, DmaChunkViewClass)) #define IS_DMA_CHUNK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DMA_CHUNK_VIEW_TYPE)) #define IS_DMA_CHUNK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DMA_CHUNK_VIEW_TYPE)) #define GET_DMA_CHUNK_VIEW_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DMA_CHUNK_VIEW_TYPE, DmaChunkViewClass)) typedef struct _DmaChunkView DmaChunkView; typedef struct _DmaChunkViewClass DmaChunkViewClass; GType dma_chunk_view_get_type (void); GtkWidget *dma_chunk_view_new (void); void dma_chunk_view_free (DmaChunkView *this); void dma_chunk_view_set_scroll_adjustment (DmaChunkView *this, GtkAdjustment* hadjustment); #endif /* _CHUNK_VIEW_H */
1,895
C
.h
32
56.25
117
0.733261
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,376
sharedlib.h
weynhamz_GNOME-anjuta/plugins/debug-manager/sharedlib.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* sharedlibs.h Copyright (C) 2000 Kh. Naba Kumar Singh This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _SHAREDLIBS_H_ #define _SHAREDLIBS_H_ #include "plugin.h" #include "queue.h" #include <libanjuta/anjuta-plugin.h> #include <libanjuta/interfaces/ianjuta-debugger.h> #include <glib.h> #include <gtk/gtk.h> typedef struct _SharedlibsGui SharedlibsGui; typedef struct _Sharedlibs Sharedlibs; struct _SharedlibsGui { GtkWidget* window; GtkWidget* menu; GtkWidget* treeview; GtkListStore* store; }; struct _Sharedlibs { SharedlibsGui widgets; DmaDebuggerQueue *debugger; AnjutaPlugin *plugin; GtkActionGroup *action_group; gboolean is_showing; gint win_pos_x, win_pos_y, win_width, win_height; }; Sharedlibs* sharedlibs_new (DebugManagerPlugin *plugin); void sharedlibs_clear (Sharedlibs *ew); void sharedlibs_free (Sharedlibs*ew); void sharedlibs_show (Sharedlibs * ew); void sharedlibs_hide (Sharedlibs * ew); #endif
1,719
C
.h
53
29.962264
82
0.766667
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,381
utilities.h
weynhamz_GNOME-anjuta/plugins/debug-manager/utilities.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* utilities.h Copyright (C) 2000 Kh. Naba Kumar Singh This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _UTILITIES_H_ #define _UTILITIES_H_ #include <libanjuta/anjuta-plugin.h> #include <libanjuta/interfaces/ianjuta-editor.h> #include <glib.h> /* Functions that dynamic allocate memory. Return value(s) should be g_freed * Removes while spaces in the text *---------------------------------------------------------------------------*/ gchar* gdb_util_remove_white_spaces(const gchar* text); /* In this case only GList must be freed and not the data * Because output data are the input data. Only GList is allocated *---------------------------------------------------------------------------*/ GList* gdb_util_remove_blank_lines(const GList* lines); /* Get current editor or NULL *---------------------------------------------------------------------------*/ IAnjutaEditor* dma_get_current_editor(AnjutaPlugin *plugin); #endif
1,712
C
.h
33
48.848485
82
0.648503
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,383
variable.h
weynhamz_GNOME-anjuta/plugins/debug-manager/variable.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* variable.h Copyright (C) 2008 Sébastien Granjoux This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _VARIABLE_H_ #define _VARIABLE_H_ #include "plugin.h" typedef struct _DmaVariableDBase DmaVariableDBase; DmaVariableDBase *dma_variable_dbase_new (DebugManagerPlugin *plugin); void dma_variable_dbase_free (DmaVariableDBase *self); #endif
1,118
C
.h
23
45
82
0.75621
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,384
start.h
weynhamz_GNOME-anjuta/plugins/debug-manager/start.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* start.h Copyright (C) 2000 Kh. Naba Kumar Singh This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _START_H_ #define _START_H_ #include "plugin.h" #include <libanjuta/interfaces/ianjuta-debugger.h> typedef struct _DmaStart DmaStart; DmaStart *dma_start_new (DebugManagerPlugin *plugin); void dma_start_free (DmaStart *this); void dma_add_source_path (DmaStart *self); void dma_attach_to_process (DmaStart *this); gboolean dma_run_target (DmaStart *this, const gchar* target); gboolean dma_run_remote_target (DmaStart *this, const gchar *remote, const gchar *target); gboolean dma_rerun_target (DmaStart *this); gboolean dma_quit_debugger (DmaStart *this); #endif
1,444
C
.h
30
45.066667
90
0.754274
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,385
data_view.h
weynhamz_GNOME-anjuta/plugins/debug-manager/data_view.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* data_view.h Copyright (C) 2006 Sebastien Granjoux This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _DATA_VIEW_H #define _DATA_VIEW_H #include "data_buffer.h" #include <gtk/gtk.h> #define DMA_DATA_VIEW_TYPE (dma_data_view_get_type ()) #define DMA_DATA_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DMA_DATA_VIEW_TYPE, DmaDataView)) #define DMA_DATA_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DMA_DATA_VIEW_TYPE, DmaDataViewClass)) #define IS_DMA_DATA_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DMA_DATA_VIEW_TYPE)) #define IS_DMA_DATA_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DMA_DATA_VIEW_TYPE)) #define GET_DMA_DATA_VIEW_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DMA_DATA_VIEW_TYPE, DmaDataViewClass)) typedef struct _DmaDataView DmaDataView; typedef struct _DmaDataViewClass DmaDataViewClass; GType dma_data_view_get_type (void); GtkWidget *dma_data_view_new_with_buffer (DmaDataBuffer *buffer); void dma_data_view_goto_address (DmaDataView *view, const void *address); void dma_data_view_refresh (DmaDataView *view); GtkWidget *dma_data_view_get_address (DmaDataView *view); GtkWidget *dma_data_view_get_data (DmaDataView *view); GtkWidget *dma_data_view_get_ascii (DmaDataView *view); #endif /* _DATA_VIEW_H */
2,078
C
.h
36
54.916667
114
0.733859
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,386
sparse_buffer.h
weynhamz_GNOME-anjuta/plugins/debug-manager/sparse_buffer.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* sparse_buffer.h Copyright (C) 2006 Sebastien Granjoux This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _SPARSE_BUFFER_H #define _SPARSE_BUFFER_H #include <gtk/gtk.h> #define DMA_SPARSE_BUFFER_TYPE (dma_sparse_buffer_get_type ()) #define DMA_SPARSE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DMA_SPARSE_BUFFER_TYPE, DmaSparseBuffer)) #define DMA_SPARSE_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DMA_SPARSE_BUFFER_TYPE, DmaSparseBufferClass)) #define DMA_IS_SPARSE_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DMA_SPARSE_BUFFER_TYPE)) #define DMA_IS_SPARSE_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DMA_SPARSE_BUFFER_TYPE)) #define DMA_GET_SPARSE_BUFFER_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DMA_SPARSE_BUFFER_TYPE, DmaSparseBufferClass)) typedef struct _DmaSparseBuffer DmaSparseBuffer; typedef struct _DmaSparseBufferClass DmaSparseBufferClass; typedef struct _DmaSparseBufferNode DmaSparseBufferNode; typedef struct _DmaSparseIter DmaSparseIter; typedef struct _DmaSparseBufferTransport DmaSparseBufferTransport; GType dma_sparse_buffer_get_type (void); DmaSparseBuffer *dma_sparse_buffer_new (guint lower, guint upper); void dma_sparse_buffer_free (DmaSparseBuffer *buffer); void dma_sparse_buffer_insert (DmaSparseBuffer *buffer, DmaSparseBufferNode *node); void dma_sparse_buffer_remove (DmaSparseBuffer *buffer, DmaSparseBufferNode *node); void dma_sparse_buffer_remove_all (DmaSparseBuffer *buffer); DmaSparseBufferNode *dma_sparse_buffer_lookup (DmaSparseBuffer *self, guint address); DmaSparseBufferNode *dma_sparse_buffer_first (DmaSparseBuffer *self); guint dma_sparse_buffer_get_lower (const DmaSparseBuffer *buffer); guint dma_sparse_buffer_get_upper (const DmaSparseBuffer *buffer); void dma_sparse_buffer_changed (const DmaSparseBuffer *buffer); void dma_sparse_buffer_add_mark (DmaSparseBuffer *buffer, guint address, gint mark); void dma_sparse_buffer_remove_mark (DmaSparseBuffer *buffer, guint address, gint mark); void dma_sparse_buffer_remove_all_mark (DmaSparseBuffer *buffer, gint mark); gint dma_sparse_buffer_get_marks (DmaSparseBuffer *buffer, guint address); void dma_sparse_buffer_get_iterator_at_address (DmaSparseBuffer *buffer, DmaSparseIter *iter, guint address); void dma_sparse_buffer_get_iterator_near_address (DmaSparseBuffer *buffer, DmaSparseIter *iter, guint address); void dma_sparse_iter_copy (DmaSparseIter *dst, const DmaSparseIter *src); void dma_sparse_iter_move_at (DmaSparseIter *iter, guint address); void dma_sparse_iter_move_near (DmaSparseIter *iter, guint address); void dma_sparse_iter_refresh (DmaSparseIter *iter); void dma_sparse_iter_round (DmaSparseIter *iter, gboolean round_up); void dma_sparse_iter_insert_lines (DmaSparseIter *iter, GtkTextIter *dst, guint count); gboolean dma_sparse_iter_forward_lines (DmaSparseIter *iter, gint count); gulong dma_sparse_iter_get_address (DmaSparseIter *iter); DmaSparseBufferTransport* dma_sparse_buffer_alloc_transport (DmaSparseBuffer *buffer, guint lines, guint chars); void dma_sparse_buffer_free_transport (DmaSparseBufferTransport *trans); struct _DmaSparseBuffer { GObject parent; guint lower; guint upper; struct { DmaSparseBufferNode *head; DmaSparseBufferNode *tail; } cache; DmaSparseBufferNode *head; gint stamp; DmaSparseBufferTransport *pending; GHashTable* mark; }; struct _DmaSparseBufferClass { GObjectClass parent; void (*changed) (const DmaSparseBuffer *buffer); void (*insert_line) (DmaSparseIter *iter, GtkTextIter *dst); gboolean (*refresh_iter) (DmaSparseIter *iter); void (*round_iter) (DmaSparseIter *iter, gboolean round_up); gboolean (*forward_line) (DmaSparseIter *iter); gboolean (*backward_line) (DmaSparseIter *iter); gulong (*get_address) (DmaSparseIter *iter); }; struct _DmaSparseBufferNode { struct { DmaSparseBufferNode *prev; DmaSparseBufferNode *next; } cache; DmaSparseBufferNode *prev; DmaSparseBufferNode *next; guint lower; /* Lowest address of block */ guint upper; /* Highest address in the block (avoid overflow) */ }; struct _DmaSparseIter { DmaSparseBuffer *buffer; gint stamp; DmaSparseBufferNode *node; gulong base; glong offset; gint line; }; struct _DmaSparseBufferTransport { DmaSparseBuffer *buffer; gulong start; gulong length; guint lines; guint chars; guint stamp; gint tag; DmaSparseBufferTransport *next; }; #endif /* _SPARSE_BUFFER_H */
5,242
C
.h
116
43.025862
126
0.783147
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,387
signals.h
weynhamz_GNOME-anjuta/plugins/debug-manager/signals.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* signals.h Copyright (C) 2000 Kh. Naba Kumar Singh This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _SIGNALS_H_ #define _SIGNALS_H_ #include "plugin.h" #include "queue.h" #include <libanjuta/anjuta-plugin.h> #include <libanjuta/interfaces/ianjuta-debugger.h> #include <gtk/gtk.h> #include <glib.h> typedef struct _SignalsGui SignalsGui; typedef struct _Signals Signals; struct _SignalsGui { GtkWidget* window; GtkWidget* treeview; GtkWidget* menu; GtkListStore* store; }; struct _Signals { SignalsGui widgets; AnjutaPlugin *plugin; DmaDebuggerQueue *debugger; GtkActionGroup *action_group_program_stopped; GtkActionGroup *action_group_program_running; gboolean is_showing; gint win_pos_x, win_pos_y, win_width, win_height; }; Signals* signals_new (DebugManagerPlugin *plugin); void signals_clear (Signals *ew); void signals_free (Signals*ew); void signals_show (Signals *ew); void signals_hide (Signals *ew); #endif
1,722
C
.h
49
32.510204
82
0.759662
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,388
registers.h
weynhamz_GNOME-anjuta/plugins/debug-manager/registers.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* cpu_registers.h Copyright (C) 2000 Kh. Naba Kumar Singh This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _REGISTERS_H_ #define _REGISTERS_H_ #include "plugin.h" #include <libanjuta/anjuta-plugin.h> #include <libanjuta/interfaces/ianjuta-debugger.h> #include <libanjuta/interfaces/ianjuta-debugger-register.h> typedef struct _CpuRegisters CpuRegisters; CpuRegisters* cpu_registers_new (DebugManagerPlugin *plugin); void cpu_registers_free(CpuRegisters *this); #endif
1,248
C
.h
26
44.653846
82
0.761748
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,423
anjuta-utils-priv.h
weynhamz_GNOME-anjuta/libanjuta/anjuta-utils-priv.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * anjuta-utils-priv.h * Copyright (C) Naba Kumar <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _ANJUTA_UTILS_PRIV_H_ #define _ANJUTA_UTILS_PRIV_H_ #include "config.h" #ifdef EMULATE_FORKPTY #include <grp.h> int forkpty(int *amaster, char *name, struct termios *termp, struct winsize *winp); #endif /* EMULATE_FORKPTY */ #endif
1,119
C
.h
27
39.592593
83
0.741047
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,450
libanjuta.h
weynhamz_GNOME-anjuta/libanjuta/libanjuta.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * libanjuta.h * Copyright (C) Naba Kumar <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef LIBANJUTA_H #define LIBANJUTA_H /* FIXME: Update required */ #include <libanjuta/anjuta-debug.h> #include <libanjuta/anjuta-encodings.h> #include <libanjuta/anjuta-convert.h> #include <libanjuta/anjuta-enum-types.h> #include <libanjuta/anjuta-launcher.h> #include <libanjuta/anjuta-marshal.h> #include <libanjuta/anjuta-plugin-description.h> #include <libanjuta/anjuta-plugin.h> #include <libanjuta/anjuta-plugin-manager.h> #include <libanjuta/anjuta-plugin-handle.h> #include <libanjuta/anjuta-preferences-dialog.h> #include <libanjuta/anjuta-preferences.h> #include <libanjuta/anjuta-profile.h> #include <libanjuta/anjuta-profile-manager.h> #include <libanjuta/anjuta-save-prompt.h> #include <libanjuta/anjuta-serializer.h> #include <libanjuta/anjuta-session.h> #include <libanjuta/anjuta-shell.h> #include <libanjuta/anjuta-status.h> #include <libanjuta/anjuta-ui.h> #include <libanjuta/anjuta-utils.h> #include <libanjuta/anjuta-version.h> #include <libanjuta/resources.h> #include <libanjuta/anjuta-vcs-status-tree-view.h> #include <libanjuta/anjuta-command.h> #include <libanjuta/anjuta-async-command.h> #include <libanjuta/anjuta-async-notify.h> #include <libanjuta/anjuta-sync-command.h> #include <libanjuta/anjuta-project.h> #include <libanjuta/anjuta-command-queue.h> #include <libanjuta/anjuta-command-bar.h> #include <libanjuta/anjuta-dock.h> #include <libanjuta/anjuta-dock-pane.h> #include <libanjuta/anjuta-token.h> #include <libanjuta/anjuta-autogen.h> #include <libanjuta/anjuta-cell-renderer-captioned-image.h> #include <libanjuta/anjuta-column-text-view.h> #include <libanjuta/anjuta-completion.h> #include <libanjuta/anjuta-drop-entry.h> #include <libanjuta/anjuta-entry.h> #include <libanjuta/anjuta-environment-editor.h> #include <libanjuta/anjuta-file-drop-entry.h> #include <libanjuta/anjuta-file-list.h> #include <libanjuta/anjuta-language-provider.h> #include <libanjuta/anjuta-pkg-config.h> #include <libanjuta/anjuta-pkg-config-chooser.h> #include <libanjuta/anjuta-pkg-scanner.h> #include <libanjuta/anjuta-tabber.h> #include <libanjuta/anjuta-token-file.h> #include <libanjuta/anjuta-token-list.h> #include <libanjuta/anjuta-token-stream.h> #include <libanjuta/anjuta-tree-combo.h> #include <libanjuta/anjuta-vcs-status.h> #include <libanjuta/anjuta-close-button.h> #include <libanjuta/anjuta-modeline.h> #endif
3,220
C
.h
78
40
81
0.789809
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,459
anjuta-debug.h
weynhamz_GNOME-anjuta/libanjuta/anjuta-debug.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* anjuta-debug.h Copyright (C) 2003 Naba Kumar <[email protected]> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef __ANJUTA_DEBUG__ #define __ANJUTA_DEBUG__ /** * SECTION:anjuta-debug * @title: Debugging * @short_description: Debug functions * @see_also: * @stability: stable * @include: libanjuta/anjuta-debug.h * * Anjuta debug messages are displayed using the g_debug() function from GLib. * * To display debug messages, Anjuta must have been compiled with * --enable-debug and the environment variable G_MESSAGES_DEBUG should be set * to "all" or to a list separated by whitespace of domains to display. * * By example *<programlisting> * G_MESSAGE_DEBUG=Gtk Anjuta libanjuta-gdb *</programlisting> * will display debug messages from Gtk, Anjuta and gdb plugin only. */ /** * DEBUG_PRINT: * * Equivalent to g_debug() showing the FILE, the LINE and the FUNC, * except it has only effect when DEBUG is defined . Used for printing debug * messages. */ #if defined (DEBUG) #if defined (__GNUC__) && (__GNUC__ >= 3) && !defined(__STRICT_ANSI__) #define DEBUG_PRINT(format, ...) g_debug ("%s:%d (%s) " format, __FILE__, __LINE__, G_STRFUNC, ##__VA_ARGS__) #else #define DEBUG_PRINT g_debug #endif #else #define DEBUG_PRINT(...) #endif #endif /* _ANJUTA_DEBUG_H_ */
2,078
C
.h
55
35
111
0.712302
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,343,470
shell.h
weynhamz_GNOME-anjuta/src/shell.h
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */ /* * shell.h * Copyright (C) 2003 Naba Kumar <[email protected]> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., 59 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _ANJUTA_TEST_SHELL_H_ #define _ANJUTA_TEST_SHELL_H_ #include <glib.h> #include <gtk/gtk.h> #include <libanjuta/anjuta-ui.h> #include <libanjuta/anjuta-preferences.h> #define ANJUTA_TYPE_TEST_SHELL (anjuta_test_shell_get_type ()) #define ANJUTA_TEST_SHELL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), ANJUTA_TYPE_TEST_SHELL, AnjutaTestShell)) #define ANJUTA_TEST_SHELL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), ANJUTA_TYPE_TEST_SHELL, AnjutaTestShellClass)) #define ANJUTA_IS_TEST_SHELL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), ANJUTA_TYPE_TEST_SHELL)) #define ANJUTA_IS_TEST_SHELL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), ANJUTA_TYPE_TEST_SHELL)) typedef struct _AnjutaTestShell AnjutaTestShell; typedef struct _AnjutaTestShellClass AnjutaTestShellClass; struct _AnjutaTestShell { GtkWindow parent; GtkWidget *box; GHashTable *values; GHashTable *widgets; AnjutaStatus *status; AnjutaUI *ui; AnjutaPreferences *preferences; AnjutaPluginManager *plugin_manager; gint merge_id; }; struct _AnjutaTestShellClass { GtkWindowClass klass; }; GType anjuta_test_shell_get_type (void); GtkWidget* anjuta_test_shell_new (void); #endif
2,039
C
.h
50
38.86
114
0.754173
weynhamz/GNOME-anjuta
3
12
0
GPL-2.0
9/7/2024, 2:05:24 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,343
dma.c
anta0_mupen64-rr-lua-/memory/dma.c
/** * Mupen64 - dma.c * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ #include "dma.h" #include "memory.h" #include "../main/rom.h" #include <stdio.h> #include "../r4300/r4300.h" #include "../r4300/interupt.h" #include "../r4300/macros.h" #include <malloc.h> #include "pif.h" #include "flashram.h" #include "../main/guifuncs.h" #include "../r4300/ops.h" unsigned char sram[0x8000]; void dma_pi_read() { int i; if (pi_register.pi_cart_addr_reg >= 0x08000000 && pi_register.pi_cart_addr_reg < 0x08010000) { if (use_flashram != 1) { char *filename; FILE *f; filename = (char*)malloc(strlen(get_savespath())+ strlen(ROM_SETTINGS.goodname)+4+1); strcpy(filename, get_savespath()); strcat(filename, ROM_SETTINGS.goodname); strcat(filename, ".sra"); f = fopen(filename, "rb"); if (f) { fread(sram, 1, 0x8000, f); fclose(f); } else for (i=0; i<0x8000; i++) sram[i] = 0; for (i=0; i<(pi_register.pi_rd_len_reg & 0xFFFFFF)+1; i++) sram[((pi_register.pi_cart_addr_reg-0x08000000)+i)^S8]= ((unsigned char*)rdram)[(pi_register.pi_dram_addr_reg+i)^S8]; f = fopen(filename, "wb"); fwrite(sram, 1, 0x8000, f); fclose(f); free(filename); use_flashram = -1; } else dma_write_flashram(); } else printf("unknown dma read\n"); pi_register.read_pi_status_reg |= 1; update_count(); add_interupt_event(PI_INT, 0x1000/*pi_register.pi_rd_len_reg*/); } void dma_pi_write() { unsigned long longueur; int i; if (pi_register.pi_cart_addr_reg < 0x10000000) { if (pi_register.pi_cart_addr_reg >= 0x08000000 && pi_register.pi_cart_addr_reg < 0x08010000) { if (use_flashram != 1) { char *filename; FILE *f; int i; filename = (char*)malloc(strlen(get_savespath())+ strlen(ROM_SETTINGS.goodname)+4+1); strcpy(filename, get_savespath()); strcat(filename, ROM_SETTINGS.goodname); strcat(filename, ".sra"); f = fopen(filename, "rb"); if (f) { fread(sram, 1, 0x8000, f); fclose(f); } else for (i=0; i<0x8000; i++) sram[i] = 0x0; free(filename); for (i=0; i<(pi_register.pi_wr_len_reg & 0xFFFFFF)+1; i++) ((unsigned char*)rdram)[(pi_register.pi_dram_addr_reg+i)^S8]= sram[(((pi_register.pi_cart_addr_reg-0x08000000)&0xFFFF)+i)^S8]; use_flashram = -1; } else dma_read_flashram(); } else if (pi_register.pi_cart_addr_reg >= 0x06000000 && pi_register.pi_cart_addr_reg < 0x08000000) { } else printf("unknown dma write:%x\n", (int)pi_register.pi_cart_addr_reg); pi_register.read_pi_status_reg |= 1; update_count(); add_interupt_event(PI_INT, /*pi_register.pi_wr_len_reg*/0x1000); return; } if (pi_register.pi_cart_addr_reg >= 0x1fc00000) // for paper mario { pi_register.read_pi_status_reg |= 1; update_count(); add_interupt_event(PI_INT, 0x1000); return; } longueur = (pi_register.pi_wr_len_reg & 0xFFFFFF)+1; i = (pi_register.pi_cart_addr_reg-0x10000000)&0x3FFFFFF; longueur = (i + longueur) > taille_rom ? (taille_rom - i) : longueur; longueur = (pi_register.pi_dram_addr_reg + longueur) > 0x7FFFFF ? (0x7FFFFF - pi_register.pi_dram_addr_reg) : longueur; if(i>taille_rom || pi_register.pi_dram_addr_reg > 0x7FFFFF) { pi_register.read_pi_status_reg |= 3; update_count(); add_interupt_event(PI_INT, longueur/8); return; } if(!interpcore) { for (i=0; i<longueur; i++) { unsigned long rdram_address1 = pi_register.pi_dram_addr_reg+i+0x80000000; unsigned long rdram_address2 = pi_register.pi_dram_addr_reg+i+0xa0000000; ((unsigned char*)rdram)[(pi_register.pi_dram_addr_reg+i)^S8]= rom[(((pi_register.pi_cart_addr_reg-0x10000000)&0x3FFFFFF)+i)^S8]; if(!invalid_code[rdram_address1>>12]) if(blocks[rdram_address1>>12]->block[(rdram_address1&0xFFF)/4].ops != NOTCOMPILED) invalid_code[rdram_address1>>12] = 1; if(!invalid_code[rdram_address2>>12]) if(blocks[rdram_address2>>12]->block[(rdram_address2&0xFFF)/4].ops != NOTCOMPILED) invalid_code[rdram_address2>>12] = 1; } } else { for (i=0; i<longueur; i++) { ((unsigned char*)rdram)[(pi_register.pi_dram_addr_reg+i)^S8]= rom[(((pi_register.pi_cart_addr_reg-0x10000000)&0x3FFFFFF)+i)^S8]; } } /*for (i=0; i<=((longueur+0x800)>>12); i++) invalid_code[(((pi_register.pi_dram_addr_reg&0xFFFFFF)|0x80000000)>>12)+i] = 1;*/ if ((debug_count+Count) < 0x100000) { switch(CIC_Chip) { case 1: case 2: case 3: case 6: rdram[0x318/4] = 0x800000; break; case 5: rdram[0x3F0/4] = 0x800000; break; } } pi_register.read_pi_status_reg |= 3; update_count(); add_interupt_event(PI_INT, longueur/8); return; } void dma_sp_write() { int i; if ((sp_register.sp_mem_addr_reg & 0x1000) > 0) { for (i=0; i<((sp_register.sp_rd_len_reg & 0xFFF)+1); i++) ((unsigned char *)(SP_IMEM))[((sp_register.sp_mem_addr_reg & 0xFFF)+i)^S8]= ((unsigned char *)(rdram))[((sp_register.sp_dram_addr_reg & 0xFFFFFF)+i)^S8]; } else { for (i=0; i<((sp_register.sp_rd_len_reg & 0xFFF)+1); i++) ((unsigned char *)(SP_DMEM))[((sp_register.sp_mem_addr_reg & 0xFFF)+i)^S8]= ((unsigned char *)(rdram))[((sp_register.sp_dram_addr_reg & 0xFFFFFF)+i)^S8]; } } void dma_sp_read() { int i; if ((sp_register.sp_mem_addr_reg & 0x1000) > 0) { for (i=0; i<((sp_register.sp_wr_len_reg & 0xFFF)+1); i++) ((unsigned char *)(rdram))[((sp_register.sp_dram_addr_reg & 0xFFFFFF)+i)^S8]= ((unsigned char *)(SP_IMEM))[((sp_register.sp_mem_addr_reg & 0xFFF)+i)^S8]; } else { for (i=0; i<((sp_register.sp_wr_len_reg & 0xFFF)+1); i++) ((unsigned char *)(rdram))[((sp_register.sp_dram_addr_reg & 0xFFFFFF)+i)^S8]= ((unsigned char *)(SP_DMEM))[((sp_register.sp_mem_addr_reg & 0xFFF)+i)^S8]; } } void dma_si_write() { int i; if (si_register.si_pif_addr_wr64b != 0x1FC007C0) { printf("unknown SI use\n"); stop=1; } for (i=0; i<(64/4); i++) PIF_RAM[i] = sl(rdram[si_register.si_dram_addr/4+i]); update_pif_write(); update_count(); add_interupt_event(SI_INT, /*0x100*/0x900); } void dma_si_read() { int i; if (si_register.si_pif_addr_rd64b != 0x1FC007C0) { printf("unknown SI use\n"); stop=1; } update_pif_read(); for (i=0; i<(64/4); i++) rdram[si_register.si_dram_addr/4+i] = sl(PIF_RAM[i]); update_count(); add_interupt_event(SI_INT, /*0x100*/0x900); }
7,662
C
.c
253
25.758893
90
0.627796
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,344
tlb.c
anta0_mupen64-rr-lua-/memory/tlb.c
/** * Mupen64 - tlb.c * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ #include "tlb.h" #include "memory.h" #include "../r4300/r4300.h" #include "../r4300/exception.h" #include "../r4300/macros.h" unsigned long tlb_LUT_r[0x100000]; unsigned long tlb_LUT_w[0x100000]; extern unsigned long interp_addr; unsigned long virtual_to_physical_address(unsigned long addresse, int w) { if (addresse >= 0x7f000000 && addresse < 0x80000000) // golden eye hack { if (ROM_HEADER->CRC1 == sl(0xDCBC50D1)) // US return 0xb0034b30 + (addresse & 0xFFFFFF); if (ROM_HEADER->CRC1 == sl(0x0414CA61)) // E return 0xb00329f0 + (addresse & 0xFFFFFF); if (ROM_HEADER->CRC1 == sl(0xA24F4CF1)) // J return 0xb0034b70 + (addresse & 0xFFFFFF); } if (w == 1) { if (tlb_LUT_w[addresse>>12]) return (tlb_LUT_w[addresse>>12]&0xFFFFF000)|(addresse&0xFFF); } else { if (tlb_LUT_r[addresse>>12]) return (tlb_LUT_r[addresse>>12]&0xFFFFF000)|(addresse&0xFFF); } //printf("tlb exception !!! @ %x, %x, add:%x\n", addresse, w, interp_addr); //getchar(); TLB_refill_exception(addresse,w); //return 0x80000000; return 0x00000000; /*int i; for (i=0; i<32; i++) { if ((tlb_e[i].vpn2 & ~(tlb_e[i].mask)) == ((addresse >> 13) & ~(tlb_e[i].mask))) { if (tlb_e[i].g || (tlb_e[i].asid == (EntryHi & 0xFF))) { if (addresse & tlb_e[i].check_parity_mask) { if (tlb_e[i].v_odd) { if (tlb_e[i].d_odd && w) { TLB_mod_exception(); return 0; } return ((addresse & ((tlb_e[i].mask << 12)|0xFFF)) | ((tlb_e[i].pfn_odd << 12) & ~((tlb_e[i].mask << 12)|0xFFF)) | 0x80000000); } else { TLB_invalid_exception(); return 0; } } else { if (tlb_e[i].v_even) { if (tlb_e[i].d_even && w) { TLB_mod_exception(); return 0; } return ((addresse & ((tlb_e[i].mask << 12)|0xFFF)) | ((tlb_e[i].pfn_even << 12) & ~((tlb_e[i].mask << 12)|0xFFF)) | 0x80000000); } else { TLB_invalid_exception(); return 0; } } } else { printf("tlb refill inconnu\n"); TLB_refill_exception(addresse,w); } } } BadVAddr = addresse; TLB_refill_exception(addresse,w); //printf("TLB refill exception\n"); return 0x80000000;*/ } int probe_nop(unsigned long address) { unsigned long a; if (address < 0x80000000 || address > 0xc0000000) { if (tlb_LUT_r[address>>12]) a = (tlb_LUT_r[address>>12]&0xFFFFF000)|(address&0xFFF); else return 0; } else a = address; if (a >= 0xa4000000 && a < 0xa4001000) { if (!SP_DMEM[(a&0xFFF)/4]) return 1; else return 0; } else if (a >= 0x80000000 && a < 0x80800000) { if (!rdram[(a&0x7FFFFF)/4]) return 1; else return 0; } else return 0; }
3,890
C
.c
147
21.843537
78
0.604122
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,346
flashram.c
anta0_mupen64-rr-lua-/memory/flashram.c
/** * Mupen64 - flashram.c * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ #include <stdio.h> #include <stdlib.h> #include "../r4300/r4300.h" #include "memory.h" #include "../main/guifuncs.h" int use_flashram; typedef enum flashram_mode { NOPES_MODE = 0, ERASE_MODE, WRITE_MODE, READ_MODE, STATUS_MODE } Flashram_mode; static int mode; static unsigned long long status; static unsigned char flashram[0x20000]; static unsigned long erase_offset, write_pointer; void save_flashram_infos(char *buf) { memcpy(buf+0 , &use_flashram , 4); memcpy(buf+4 , &mode , 4); memcpy(buf+8 , &status , 8); memcpy(buf+16, &erase_offset , 4); memcpy(buf+20, &write_pointer, 4); } void load_flashram_infos(char *buf) { memcpy(&use_flashram , buf+0 , 4); memcpy(&mode , buf+4 , 4); memcpy(&status , buf+8 , 8); memcpy(&erase_offset , buf+16, 4); memcpy(&write_pointer, buf+20, 4); } void init_flashram() { mode = NOPES_MODE; status = 0; } unsigned long flashram_status() { return (status >> 32); } void flashram_command(unsigned long command) { switch(command & 0xff000000) { case 0x4b000000: erase_offset = (command & 0xffff) * 128; break; case 0x78000000: mode = ERASE_MODE; status = 0x1111800800c20000LL; break; case 0xa5000000: erase_offset = (command & 0xffff) * 128; status = 0x1111800400c20000LL; break; case 0xb4000000: mode = WRITE_MODE; break; case 0xd2000000: // execute switch (mode) { case NOPES_MODE: break; case ERASE_MODE: { char *filename; FILE *f; int i; filename = (char*)malloc(strlen(get_savespath())+ strlen(ROM_SETTINGS.goodname)+4+1); strcpy(filename, get_savespath()); strcat(filename, ROM_SETTINGS.goodname); strcat(filename, ".fla"); f = fopen(filename, "rb"); if (f) { fread(flashram, 1, 0x20000, f); fclose(f); } else for (i=0; i<0x20000; i++) flashram[i] = 0xff; for (i=erase_offset; i<(erase_offset+128); i++) flashram[i^S8] = 0xff; f = fopen(filename, "wb"); fwrite(flashram, 1, 0x20000, f); fclose(f); free(filename); } break; case WRITE_MODE: { char *filename; FILE *f; int i; filename = (char*)malloc(strlen(get_savespath())+ strlen(ROM_SETTINGS.goodname)+4+1); strcpy(filename, get_savespath()); strcat(filename, ROM_SETTINGS.goodname); strcat(filename, ".fla"); f = fopen(filename, "rb"); if (f) { fread(flashram, 1, 0x20000, f); fclose(f); } else for (i=0; i<0x20000; i++) flashram[i] = 0xff; for (i=0; i<128; i++) flashram[(erase_offset+i)^S8]= ((unsigned char*)rdram)[(write_pointer+i)^S8]; f = fopen(filename, "wb"); fwrite(flashram, 1, 0x20000, f); fclose(f); free(filename); } break; case STATUS_MODE: break; default: printf("unknown flashram command with mode:%x\n", (int)mode); stop=1; } mode = NOPES_MODE; break; case 0xe1000000: mode = STATUS_MODE; status = 0x1111800100c20000LL; break; case 0xf0000000: mode = READ_MODE; status = 0x11118004f0000000LL; break; default: printf("unknown flashram command:%x\n", (int)command); //stop=1; } } void dma_read_flashram() { int i; char *filename; FILE *f; switch(mode) { case STATUS_MODE: rdram[pi_register.pi_dram_addr_reg/4] = (unsigned long)(status >> 32); rdram[pi_register.pi_dram_addr_reg/4+1] = (unsigned long)(status); break; case READ_MODE: filename = (char*)malloc(strlen(get_savespath())+ strlen(ROM_SETTINGS.goodname)+4+1); strcpy(filename, get_savespath()); strcat(filename, ROM_SETTINGS.goodname); strcat(filename, ".fla"); f = fopen(filename, "rb"); if (f) { fread(flashram, 1, 0x20000, f); fclose(f); } else for (i=0; i<0x20000; i++) flashram[i] = 0xff; free(filename); for (i=0; i<(pi_register.pi_wr_len_reg & 0x0FFFFFF)+1; i++) ((unsigned char*)rdram)[(pi_register.pi_dram_addr_reg+i)^S8]= flashram[(((pi_register.pi_cart_addr_reg-0x08000000)&0xFFFF)*2+i)^S8]; break; default: printf("unknown dma_read_flashram:%x\n", mode); stop=1; } } void dma_write_flashram() { switch(mode) { case WRITE_MODE: write_pointer = pi_register.pi_dram_addr_reg; break; default: printf("unknown dma_read_flashram:%x\n", mode); stop=1; } }
5,427
C
.c
212
21.764151
73
0.651087
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,349
profile.c
anta0_mupen64-rr-lua-/r4300/profile.c
/** * Mupen64 - profile.c * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ #include "r4300.h" #ifndef _MSC_VER #include "sys/time.h" #endif #ifdef PROFILE static unsigned int time_in_section[5]; static unsigned int last_start[5]; static unsigned int last_refresh; void start_section(int section_type) { struct timeval tv; gettimeofday(&tv, NULL); last_start[section_type] = ((tv.tv_sec % 1000000) * 1000) + (tv.tv_usec / 1000); } void end_section(int section_type) { struct timeval tv; gettimeofday(&tv, NULL); unsigned int end = ((tv.tv_sec % 1000000) * 1000) + (tv.tv_usec / 1000); time_in_section[section_type] += end - last_start[section_type]; } void refresh_stat() { struct timeval tv; gettimeofday(&tv, NULL); if(tv.tv_sec - last_refresh >= 2) { unsigned int end = ((tv.tv_sec % 1000000) * 1000) + (tv.tv_usec / 1000); time_in_section[0] = end - last_start[0]; printf("gfx=%f%% - audio=%f%% - compiler=%f%%, idle=%f%%\r", 100.0f * (float)time_in_section[1] / (float)time_in_section[0], 100.0f * (float)time_in_section[2] / (float)time_in_section[0], 100.0f * (float)time_in_section[3] / (float)time_in_section[0], 100.0f * (float)time_in_section[4] / (float)time_in_section[0]); fflush(stdout); time_in_section[1] = 0; time_in_section[2] = 0; time_in_section[3] = 0; time_in_section[4] = 0; last_start[0] = end; last_refresh = tv.tv_sec; } } #endif
2,378
C
.c
75
28.973333
72
0.688589
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,351
recomp.h
anta0_mupen64-rr-lua-/r4300/recomp.h
/** * Mupen64 - recomp.h * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ #ifndef RECOMP_H #define RECOMP_H #include "x86/assemble.h" #include "../lua/LuaDefine.h" typedef struct _precomp_instr { void (*ops)(); union { struct { long long int *rs; long long int *rt; short immediate; } i; struct { unsigned long inst_index; } j; struct { long long int *rs; long long int *rt; long long int *rd; unsigned char sa; unsigned char nrd; } r; struct { unsigned char base; unsigned char ft; short offset; } lf; struct { unsigned char ft; unsigned char fs; unsigned char fd; } cf; #ifdef LUA_BREAKPOINTSYNC_INTERP unsigned char stype; #endif } f; unsigned long addr; unsigned long local_addr; reg_cache_struct reg_cache_infos; #ifdef LUA_TRACEINTERP void (*s_ops)(); unsigned long src; #endif } precomp_instr; typedef struct _precomp_block { precomp_instr *block; unsigned int start; unsigned int end; unsigned char *code; unsigned int code_length; unsigned int max_code_length; void *jumps_table; int jumps_number; //unsigned char md5[16]; unsigned long adler32; } precomp_block; void recompile_block(long *source, precomp_block *block, unsigned long func); void init_block(long *source, precomp_block *block); void recompile_opcode(); void prefetch_opcode(unsigned long op); void dyna_jump(); void dyna_start(void (*code)()); void dyna_stop(); extern precomp_instr *dst; #include "x86/regcache.h" #endif
2,510
C
.c
102
21.441176
77
0.707083
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,354
r4300.c
anta0_mupen64-rr-lua-/r4300/r4300.c
/** * Mupen64 - r4300.c * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ //#include "../config.h" #include "../main/vcr.h" #include "r4300.h" #include "ops.h" #include "../memory/memory.h" #include "exception.h" #include "interupt.h" #include "macros.h" #include "recomp.h" #include "recomph.h" #include <malloc.h> #define LUACONSOLE_H_NOINCLUDE_WINDOWS_H #include "../lua/LuaConsole.h" #ifdef DBG extern int debugger_mode; extern void update_debugger(); #endif unsigned long i, dynacore = 0, interpcore = 0; int no_audio_delay = 0; int no_compiled_jump = 0; int stop, llbit; long long int reg[32], hi, lo; long long int local_rs, local_rt; unsigned long reg_cop0[32]; long local_rs32, local_rt32; unsigned long jump_target; float *reg_cop1_simple[32]; double *reg_cop1_double[32]; long reg_cop1_fgr_32[32]; long long int reg_cop1_fgr_64[32]; long FCR0, FCR31; tlb tlb_e[32]; unsigned long delay_slot, skip_jump = 0, dyna_interp = 0, last_addr; unsigned long long int debug_count = 0; unsigned int next_interupt, CIC_Chip; precomp_instr *PC; char invalid_code[0x100000]; precomp_block *blocks[0x100000], *actual; int rounding_mode = 0x33F, trunc_mode = 0xF3F, round_mode = 0x33F, ceil_mode = 0xB3F, floor_mode = 0x73F; void (*code)(); /*#define check_memory() \ if (!invalid_code[address>>12]) \ invalid_code[address>>12] = 1;*/ #define check_memory() \ if (!invalid_code[address>>12]) \ if (blocks[address>>12]->block[(address&0xFFF)/4].ops != NOTCOMPILED) \ invalid_code[address>>12] = 1; void NI() { printf("NI() @ %x\n", (int)PC->addr); printf("opcode not implemented : "); if (PC->addr >= 0xa4000000 && PC->addr < 0xa4001000) printf("%x:%x\n", (int)PC->addr, (int)SP_DMEM[(PC->addr-0xa4000000)/4]); else printf("%x:%x\n", (int)PC->addr, (int)rdram[(PC->addr-0x80000000)/4]); stop=1; } void RESERVED() { printf("reserved opcode : "); if (PC->addr >= 0xa4000000 && PC->addr < 0xa4001000) printf("%x:%x\n", (int)PC->addr, (int)SP_DMEM[(PC->addr-0xa4000000)/4]); else printf("%x:%x\n", (int)PC->addr, (int)rdram[(PC->addr-0x80000000)/4]); stop=1; } void FIN_BLOCK() { if (!delay_slot) { jump_to((PC-1)->addr+4); PC->ops(); if (dynacore) dyna_jump(); } else { precomp_block *blk = actual; precomp_instr *inst = PC; jump_to((PC-1)->addr+4); if (!skip_jump) { PC->ops(); actual = blk; PC = inst+1; } else PC->ops(); if (dynacore) dyna_jump(); } } void J() { PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump) PC=actual->block+ (((((PC-2)->f.j.inst_index<<2) | ((PC-1)->addr & 0xF0000000))-actual->start)>>2); last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void J_OUT() { jump_target = (PC->addr & 0xF0000000) | (PC->f.j.inst_index<<2); PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump) jump_to(jump_target); last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void J_IDLE() { long skip; update_count(); skip = next_interupt - Count; if (skip > 3) Count += (skip & 0xFFFFFFFC); else J(); } void JAL() { PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump) { reg[31]=PC->addr; sign_extended(reg[31]); PC=actual->block+ (((((PC-2)->f.j.inst_index<<2) | ((PC-1)->addr & 0xF0000000))-actual->start)>>2); } last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void JAL_OUT() { jump_target = (PC->addr & 0xF0000000) | (PC->f.j.inst_index<<2); PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump) { reg[31]=PC->addr; sign_extended(reg[31]); jump_to(jump_target); } last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void JAL_IDLE() { long skip; update_count(); skip = next_interupt - Count; if (skip > 3) Count += (skip & 0xFFFFFFFC); else JAL(); } void BEQ() { local_rs = irs; local_rt = irt; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (local_rs == local_rt && !skip_jump) PC += (PC-2)->f.i.immediate-1; last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BEQ_OUT() { local_rs = irs; local_rt = irt; jump_target = (long)PC->f.i.immediate; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump && local_rs == local_rt) jump_to(PC->addr + ((jump_target-1)<<2)); last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BEQ_IDLE() { long skip; if (irs == irt) { update_count(); skip = next_interupt - Count; if (skip > 3) Count += (skip & 0xFFFFFFFC); else BEQ(); } else BEQ(); } void BNE() { local_rs = irs; local_rt = irt; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (local_rs != local_rt && !skip_jump) PC += (PC-2)->f.i.immediate-1; last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BNE_OUT() { local_rs = irs; local_rt = irt; jump_target = (long)PC->f.i.immediate; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump && local_rs != local_rt) jump_to(PC->addr + ((jump_target-1)<<2)); last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BNE_IDLE() { long skip; if (irs != irt) { update_count(); skip = next_interupt - Count; if (skip > 3) Count += (skip & 0xFFFFFFFC); else BNE(); } else BNE(); } void BLEZ() { local_rs = irs; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (local_rs <= 0 && !skip_jump) PC += (PC-2)->f.i.immediate-1; last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BLEZ_OUT() { local_rs = irs; jump_target = (long)PC->f.i.immediate; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump && local_rs <= 0) jump_to(PC->addr + ((jump_target-1)<<2)); last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BLEZ_IDLE() { long skip; if (irs <= irt) { update_count(); skip = next_interupt - Count; if (skip > 3) Count += (skip & 0xFFFFFFFC); else BLEZ(); } else BLEZ(); } void BGTZ() { local_rs = irs; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (local_rs > 0 && !skip_jump) PC += (PC-2)->f.i.immediate-1; last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BGTZ_OUT() { local_rs = irs; jump_target = (long)PC->f.i.immediate; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump && local_rs > 0) jump_to(PC->addr + ((jump_target-1)<<2)); last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BGTZ_IDLE() { long skip; if (irs > irt) { update_count(); skip = next_interupt - Count; if (skip > 3) Count += (skip & 0xFFFFFFFC); else BGTZ(); } else BGTZ(); } void ADDI() { irt32 = irs32 + iimmediate; sign_extended(irt); PC++; } void ADDIU() { irt32 = irs32 + iimmediate; sign_extended(irt); PC++; } void SLTI() { if (irs < iimmediate) irt = 1; else irt = 0; PC++; } void SLTIU() { if ((unsigned long long)irs < (unsigned long long)((long long)iimmediate)) irt = 1; else irt = 0; PC++; } void ANDI() { irt = irs & (unsigned short)iimmediate; PC++; } void ORI() { irt = irs | (unsigned short)iimmediate; PC++; } void XORI() { irt = irs ^ (unsigned short)iimmediate; PC++; } void LUI() { irt32 = iimmediate << 16; sign_extended(irt); PC++; } void BEQL() { if (irs == irt) { PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if(!skip_jump) PC += (PC-2)->f.i.immediate-1; } else { PC+=2; update_count(); } last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BEQL_OUT() { if (irs == irt) { jump_target = (long)PC->f.i.immediate; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump) jump_to(PC->addr + ((jump_target-1)<<2)); } else { PC+=2; update_count(); } last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BEQL_IDLE() { long skip; if (irs == irt) { update_count(); skip = next_interupt - Count; if (skip > 3) Count += (skip & 0xFFFFFFFC); else BEQL(); } else BEQL(); } void BNEL() { if (irs != irt) { PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if(!skip_jump) PC += (PC-2)->f.i.immediate-1; } else { PC+=2; update_count(); } last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BNEL_OUT() { if (irs != irt) { jump_target = (long)PC->f.i.immediate; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump) jump_to(PC->addr + ((jump_target-1)<<2)); } else { PC+=2; update_count(); } last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BNEL_IDLE() { long skip; if (irs != irt) { update_count(); skip = next_interupt - Count; if (skip > 3) Count += (skip & 0xFFFFFFFC); else BNEL(); } else BNEL(); } void BLEZL() { if (irs <= 0) { PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if(!skip_jump) PC += (PC-2)->f.i.immediate-1; } else { PC+=2; update_count(); } last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BLEZL_OUT() { if (irs <= 0) { jump_target = (long)PC->f.i.immediate; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump) jump_to(PC->addr + ((jump_target-1)<<2)); } else { PC+=2; update_count(); } last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BLEZL_IDLE() { long skip; if (irs <= irt) { update_count(); skip = next_interupt - Count; if (skip > 3) Count += (skip & 0xFFFFFFFC); else BLEZL(); } else BLEZL(); } void BGTZL() { if (irs > 0) { PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if(!skip_jump) PC += (PC-2)->f.i.immediate-1; } else { PC+=2; update_count(); } last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BGTZL_OUT() { if (irs > 0) { jump_target = (long)PC->f.i.immediate; PC++; delay_slot=1; PC->ops(); update_count(); delay_slot=0; if (!skip_jump) jump_to(PC->addr + ((jump_target-1)<<2)); } else { PC+=2; update_count(); } last_addr = PC->addr; if (next_interupt <= Count) gen_interupt(); } void BGTZL_IDLE() { long skip; if (irs > irt) { update_count(); skip = next_interupt - Count; if (skip > 3) Count += (skip & 0xFFFFFFFC); else BGTZL(); } else BGTZL(); } void DADDI() { irt = irs + iimmediate; PC++; } void DADDIU() { irt = irs + iimmediate; PC++; } void LDL() { unsigned long long int word = 0; PC++; switch ((lsaddr) & 7) { case 0: address = lsaddr; rdword = (unsigned long long int*) &lsrt; read_dword_in_memory(); break; case 1: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFF) | (word << 8); break; case 2: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFF) | (word << 16); break; case 3: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFF) | (word << 24); break; case 4: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFFFF) | (word << 32); break; case 5: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFFFFFFLL) | (word << 40); break; case 6: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFFFFFFFFLL) | (word << 48); break; case 7: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFFFFFFFFFFLL) | (word << 56); break; } } void LDR() { unsigned long long int word = 0; PC++; switch ((lsaddr) & 7) { case 0: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFFFFFFFFFF00LL) | (word >> 56); break; case 1: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFFFFFFFF0000LL) | (word >> 48); break; case 2: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFFFFFF000000LL) | (word >> 40); break; case 3: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFFFF00000000LL) | (word >> 32); break; case 4: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFF0000000000LL) | (word >> 24); break; case 5: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFFFF000000000000LL) | (word >> 16); break; case 6: address = (lsaddr) & 0xFFFFFFF8; rdword = &word; read_dword_in_memory(); if(address) lsrt = (lsrt & 0xFF00000000000000LL) | (word >> 8); break; case 7: address = (lsaddr) & 0xFFFFFFF8; rdword = (unsigned long long int*) &lsrt; read_dword_in_memory(); break; } } void LB() { PC++; address = lsaddr; rdword = (unsigned long long int*) &lsrt; read_byte_in_memory(); if (address) sign_extendedb(lsrt); } void LH() { PC++; address = lsaddr; rdword = (unsigned long long int*) &lsrt; read_hword_in_memory(); if (address) sign_extendedh(lsrt); } void LWL() { unsigned long long int word = 0; PC++; switch ((lsaddr) & 3) { case 0: address = lsaddr; rdword = (unsigned long long int*) &lsrt; read_word_in_memory(); break; case 1: address = (lsaddr) & 0xFFFFFFFC; rdword = &word; read_word_in_memory(); if(address) lsrt = (lsrt & 0xFF) | (word << 8); break; case 2: address = (lsaddr) & 0xFFFFFFFC; rdword = &word; read_word_in_memory(); if(address) lsrt = (lsrt & 0xFFFF) | (word << 16); break; case 3: address = (lsaddr) & 0xFFFFFFFC; rdword = &word; read_word_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFF) | (word << 24); break; } if(address) sign_extended(lsrt); } void LW() { PC++; address = lsaddr; rdword = (unsigned long long int*) &lsrt; read_word_in_memory(); if (address) sign_extended(lsrt); } void LBU() { PC++; address = lsaddr; rdword = (unsigned long long int*) &lsrt; read_byte_in_memory(); } void LHU() { PC++; address = lsaddr; rdword = (unsigned long long int*) &lsrt; read_hword_in_memory(); } void LWR() { unsigned long long int word = 0; PC++; switch ((lsaddr) & 3) { case 0: address = (lsaddr) & 0xFFFFFFFC; rdword = &word; read_word_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFFFFFFFFFF00LL) | ((word >> 24) & 0xFF); break; case 1: address = (lsaddr) & 0xFFFFFFFC; rdword = &word; read_word_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFFFFFFFF0000LL) | ((word >> 16) & 0xFFFF); break; case 2: address = (lsaddr) & 0xFFFFFFFC; rdword = &word; read_word_in_memory(); if(address) lsrt = (lsrt & 0xFFFFFFFFFF000000LL) | ((word >> 8) & 0XFFFFFF); break; case 3: address = (lsaddr) & 0xFFFFFFFC; rdword = (unsigned long long int*) &lsrt; read_word_in_memory(); if(address) sign_extended(lsrt); } } void LWU() { PC++; address = lsaddr; rdword = (unsigned long long int*) &lsrt; read_word_in_memory(); } void SB() { PC++; address = lsaddr; g_byte = (unsigned char)(lsrt & 0xFF); write_byte_in_memory(); check_memory(); } void SH() { PC++; address = lsaddr; hword = (unsigned short)(lsrt & 0xFFFF); write_hword_in_memory(); check_memory(); } void SWL() { unsigned long long int old_word = 0; PC++; switch ((lsaddr) & 3) { case 0: address = (lsaddr) & 0xFFFFFFFC; word = (unsigned long)lsrt; write_word_in_memory(); check_memory(); break; case 1: address = (lsaddr) & 0xFFFFFFFC; rdword = &old_word; read_word_in_memory(); if(address) { word = ((unsigned long)lsrt >> 8) | (old_word & 0xFF000000); write_word_in_memory(); check_memory(); } break; case 2: address = (lsaddr) & 0xFFFFFFFC; rdword = &old_word; read_word_in_memory(); if(address) { word = ((unsigned long)lsrt >> 16) | (old_word & 0xFFFF0000); write_word_in_memory(); check_memory(); } break; case 3: address = lsaddr; g_byte = (unsigned char)(lsrt >> 24); write_byte_in_memory(); check_memory(); break; } } void SW() { PC++; address = lsaddr; word = (unsigned long)(lsrt & 0xFFFFFFFF); write_word_in_memory(); check_memory(); } void SDL() { unsigned long long int old_word = 0; PC++; switch ((lsaddr) & 7) { case 0: address = (lsaddr) & 0xFFFFFFF8; dword = lsrt; write_dword_in_memory(); check_memory(); break; case 1: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = ((unsigned long long)lsrt >> 8)|(old_word & 0xFF00000000000000LL); write_dword_in_memory(); check_memory(); } break; case 2: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = ((unsigned long long)lsrt >> 16)|(old_word & 0xFFFF000000000000LL); write_dword_in_memory(); check_memory(); } break; case 3: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = ((unsigned long long)lsrt >> 24)|(old_word & 0xFFFFFF0000000000LL); write_dword_in_memory(); check_memory(); } break; case 4: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = ((unsigned long long)lsrt >> 32)|(old_word & 0xFFFFFFFF00000000LL); write_dword_in_memory(); check_memory(); } break; case 5: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = ((unsigned long long)lsrt >> 40)|(old_word & 0xFFFFFFFFFF000000LL); write_dword_in_memory(); check_memory(); } break; case 6: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = ((unsigned long long)lsrt >> 48)|(old_word & 0xFFFFFFFFFFFF0000LL); write_dword_in_memory(); check_memory(); } break; case 7: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = ((unsigned long long)lsrt >> 56)|(old_word & 0xFFFFFFFFFFFFFF00LL); write_dword_in_memory(); check_memory(); } break; } } void SDR() { unsigned long long int old_word = 0; PC++; switch ((lsaddr) & 7) { case 0: address = lsaddr; rdword = &old_word; read_dword_in_memory(); if(address) { dword = (lsrt << 56) | (old_word & 0x00FFFFFFFFFFFFFFLL); write_dword_in_memory(); check_memory(); } break; case 1: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = (lsrt << 48) | (old_word & 0x0000FFFFFFFFFFFFLL); write_dword_in_memory(); check_memory(); } break; case 2: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = (lsrt << 40) | (old_word & 0x000000FFFFFFFFFFLL); write_dword_in_memory(); check_memory(); } break; case 3: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = (lsrt << 32) | (old_word & 0x00000000FFFFFFFFLL); write_dword_in_memory(); check_memory(); } break; case 4: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = (lsrt << 24) | (old_word & 0x0000000000FFFFFFLL); write_dword_in_memory(); check_memory(); } break; case 5: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = (lsrt << 16) | (old_word & 0x000000000000FFFFLL); write_dword_in_memory(); check_memory(); } break; case 6: address = (lsaddr) & 0xFFFFFFF8; rdword = &old_word; read_dword_in_memory(); if(address) { dword = (lsrt << 8) | (old_word & 0x00000000000000FFLL); write_dword_in_memory(); check_memory(); } break; case 7: address = (lsaddr) & 0xFFFFFFF8; dword = lsrt; write_dword_in_memory(); check_memory(); break; } } void SWR() { unsigned long long int old_word = 0; PC++; switch ((lsaddr) & 3) { case 0: address = lsaddr; rdword = &old_word; read_word_in_memory(); if(address) { word = ((unsigned long)lsrt << 24) | (old_word & 0x00FFFFFF); write_word_in_memory(); check_memory(); } break; case 1: address = (lsaddr) & 0xFFFFFFFC; rdword = &old_word; read_word_in_memory(); if(address) { word = ((unsigned long)lsrt << 16) | (old_word & 0x0000FFFF); write_word_in_memory(); check_memory(); } break; case 2: address = (lsaddr) & 0xFFFFFFFC; rdword = &old_word; read_word_in_memory(); if(address) { word = ((unsigned long)lsrt << 8) | (old_word & 0x000000FF); write_word_in_memory(); check_memory(); } break; case 3: address = (lsaddr) & 0xFFFFFFFC; word = (unsigned long)lsrt; write_word_in_memory(); check_memory(); break; } } void CACHE() { PC++; } void LL() { PC++; address = lsaddr; rdword = (unsigned long long int*) &lsrt; read_word_in_memory(); if (address) { sign_extended(lsrt); llbit = 1; } } void LWC1() { unsigned long long int temp; if (check_cop1_unusable()) return; PC++; address = lslfaddr; rdword = &temp; read_word_in_memory(); if (address) *((long*)reg_cop1_simple[lslfft]) = *rdword; } void LDC1() { if (check_cop1_unusable()) return; PC++; address = lslfaddr; rdword = (unsigned long long int*) reg_cop1_double[lslfft]; read_dword_in_memory(); } void LD() { PC++; address = lsaddr; rdword = (unsigned long long int*) &lsrt; read_dword_in_memory(); } void SC() { /*PC++; printf("SC\n"); if (llbit) { address = lsaddr; word = (unsigned long)(lsrt & 0xFFFFFFFF); write_word_in_memory(); } lsrt = llbit;*/ PC++; if(llbit) { address = lsaddr; word = (unsigned long)(lsrt & 0xFFFFFFFF); write_word_in_memory(); check_memory(); llbit = 0; lsrt = 1; } else { lsrt = 0; } } void SWC1() { if (check_cop1_unusable()) return; PC++; address = lslfaddr; word = *((long*)reg_cop1_simple[lslfft]); write_word_in_memory(); check_memory(); } void SDC1() { if (check_cop1_unusable()) return; PC++; address = lslfaddr; dword = *((unsigned long long*)reg_cop1_double[lslfft]); write_dword_in_memory(); check_memory(); } void SD() { PC++; address = lsaddr; dword = lsrt; write_dword_in_memory(); check_memory(); } void NOTCOMPILED() { if ((PC->addr>>16) == 0xa400) recompile_block((long*)SP_DMEM, blocks[0xa4000000>>12], PC->addr); else { unsigned long paddr = 0; if (PC->addr >= 0x80000000 && PC->addr < 0xc0000000) paddr = PC->addr; //else paddr = (tlb_LUT_r[PC->addr>>12]&0xFFFFF000)|(PC->addr&0xFFF); else paddr = virtual_to_physical_address(PC->addr, 2); if (paddr) { if ((paddr & 0x1FFFFFFF) >= 0x10000000) { //printf("not compiled rom:%x\n", paddr); recompile_block((long*)rom+((((paddr-(PC->addr-blocks[PC->addr>>12]->start)) & 0x1FFFFFFF) - 0x10000000)>>2), blocks[PC->addr>>12], PC->addr); } else recompile_block((long*)(rdram+(((paddr-(PC->addr-blocks[PC->addr>>12]->start)) & 0x1FFFFFFF)>>2)), blocks[PC->addr>>12], PC->addr); } else printf("not compiled exception\n"); } PC->ops(); if (dynacore) dyna_jump(); //*return_address = (unsigned long)(blocks[PC->addr>>12]->code + PC->local_addr); //else //PC->ops(); } void NOTCOMPILED2() { NOTCOMPILED(); } static inline unsigned long update_invalid_addr(unsigned long addr) { if (addr >= 0x80000000 && addr < 0xa0000000) { if (invalid_code[addr>>12]) invalid_code[(addr+0x20000000)>>12] = 1; if (invalid_code[(addr+0x20000000)>>12]) invalid_code[addr>>12] = 1; return addr; } else if (addr >= 0xa0000000 && addr < 0xc0000000) { if (invalid_code[addr>>12]) invalid_code[(addr-0x20000000)>>12] = 1; if (invalid_code[(addr-0x20000000)>>12]) invalid_code[addr>>12] = 1; return addr; } else { unsigned long paddr = virtual_to_physical_address(addr, 2); if (paddr) { unsigned long beg_paddr = paddr - (addr - (addr&~0xFFF)); update_invalid_addr(paddr); if (invalid_code[(beg_paddr+0x000)>>12]) invalid_code[addr>>12] = 1; if (invalid_code[(beg_paddr+0xFFC)>>12]) invalid_code[addr>>12] = 1; if (invalid_code[addr>>12]) invalid_code[(beg_paddr+0x000)>>12] = 1; if (invalid_code[addr>>12]) invalid_code[(beg_paddr+0xFFC)>>12] = 1; } return paddr; } } #define addr jump_to_address unsigned long jump_to_address; inline void jump_to_func() { unsigned long paddr; if (skip_jump) return; paddr = update_invalid_addr(addr); if (!paddr) return; actual = blocks[addr>>12]; if (invalid_code[addr>>12]) { if (!blocks[addr>>12]) { blocks[addr>>12] = (precomp_block*) malloc(sizeof(precomp_block)); actual = blocks[addr>>12]; blocks[addr>>12]->code = NULL; blocks[addr>>12]->block = NULL; blocks[addr>>12]->jumps_table = NULL; } blocks[addr>>12]->start = addr & ~0xFFF; blocks[addr>>12]->end = (addr & ~0xFFF) + 0x1000; init_block((long*)(rdram+(((paddr-(addr-blocks[addr>>12]->start)) & 0x1FFFFFFF)>>2)), blocks[addr>>12]); } PC=actual->block+((addr-actual->start)>>2); if (dynacore) dyna_jump(); } #undef addr int check_cop1_unusable() { if (!(Status & 0x20000000)) { Cause = (11 << 2) | 0x10000000; exception_general(); return 1; } return 0; } void update_count() { if (interpcore) { Count = Count + (interp_addr - last_addr)/2; last_addr = interp_addr; } else { if (PC->addr < last_addr) { printf("PC->addr < last_addr\n"); } Count = Count + (PC->addr - last_addr)/2; last_addr = PC->addr; } #ifdef COMPARE_CORE if (delay_slot) compare_core(); #endif #ifdef DBG if (debugger_mode) update_debugger(); #endif } void init_blocks() { int i; for (i=0; i<0x100000; i++) { invalid_code[i] = 1; blocks[i] = NULL; } blocks[0xa4000000>>12] = (precomp_block*)malloc(sizeof(precomp_block)); invalid_code[0xa4000000>>12] = 1; blocks[0xa4000000>>12]->code = NULL; blocks[0xa4000000>>12]->block = NULL; blocks[0xa4000000>>12]->jumps_table = NULL; blocks[0xa4000000>>12]->start = 0xa4000000; blocks[0xa4000000>>12]->end = 0xa4001000; actual=blocks[0xa4000000>>12]; init_block((long*)SP_DMEM, blocks[0xa4000000>>12]); PC=actual->block+(0x40/4); #ifdef DBG if (debugger_mode) // debugger shows initial state (before 1st instruction). update_debugger(); #endif } void go() { long long CRC = 0; unsigned int j; j=0; debug_count = 0; printf("demarrage r4300\n"); memcpy((char *)SP_DMEM+0x40, rom+0x40, 0xFBC); delay_slot=0; stop = 0; for (i=0;i<32;i++) { reg[i]=0; reg_cop0[i]=0; reg_cop1_fgr_32[i]=0; reg_cop1_fgr_64[i]=0; reg_cop1_double[i]=(double *)&reg_cop1_fgr_64[i]; reg_cop1_simple[i]=(float *)&reg_cop1_fgr_64[i]; // --------------tlb------------------------ tlb_e[i].mask=0; tlb_e[i].vpn2=0; tlb_e[i].g=0; tlb_e[i].asid=0; tlb_e[i].pfn_even=0; tlb_e[i].c_even=0; tlb_e[i].d_even=0; tlb_e[i].v_even=0; tlb_e[i].pfn_odd=0; tlb_e[i].c_odd=0; tlb_e[i].d_odd=0; tlb_e[i].v_odd=0; tlb_e[i].r=0; //tlb_e[i].check_parity_mask=0x1000; tlb_e[i].start_even=0; tlb_e[i].end_even=0; tlb_e[i].phys_even=0; tlb_e[i].start_odd=0; tlb_e[i].end_odd=0; tlb_e[i].phys_odd=0; } for (i=0; i<0x100000; i++) { tlb_LUT_r[i] = 0; tlb_LUT_w[i] = 0; } llbit=0; hi=0; lo=0; FCR0=0x511; FCR31=0; //-------- /*reg[20]=1; reg[22]=0x3F; reg[29]=0xFFFFFFFFA0400000LL; Random=31; Status=0x70400004; Config=0x66463; PRevID=0xb00;*/ //-------- // the following values are extracted from the pj64 source code // thanks to Zilmar and Jabo reg[6] = 0xFFFFFFFFA4001F0CLL; reg[7] = 0xFFFFFFFFA4001F08LL; reg[8] = 0x00000000000000C0LL; reg[10]= 0x0000000000000040LL; reg[11]= 0xFFFFFFFFA4000040LL; reg[29]= 0xFFFFFFFFA4001FF0LL; Random = 31; Status= 0x34000000; Config= 0x6e463; PRevID = 0xb00; Count = 0x5000; Cause = 0x5C; Context = 0x7FFFF0; EPC = 0xFFFFFFFF; BadVAddr = 0xFFFFFFFF; ErrorEPC = 0xFFFFFFFF; for (i = 0x40/4; i < (0x1000/4); i++) CRC += SP_DMEM[i]; switch(CRC) { case 0x000000D0027FDF31LL: case 0x000000CFFB631223LL: CIC_Chip = 1; break; case 0x000000D057C85244LL: CIC_Chip = 2; break; case 0x000000D6497E414BLL: CIC_Chip = 3; break; case 0x0000011A49F60E96LL: CIC_Chip = 5; break; case 0x000000D6D5BE5580LL: CIC_Chip = 6; break; default: CIC_Chip = 2; } switch(ROM_HEADER->Country_code&0xFF) { case 0x44: case 0x46: case 0x49: case 0x50: case 0x53: case 0x55: case 0x58: case 0x59: switch (CIC_Chip) { case 2: reg[5] = 0xFFFFFFFFC0F1D859LL; reg[14]= 0x000000002DE108EALL; break; case 3: reg[5] = 0xFFFFFFFFD4646273LL; reg[14]= 0x000000001AF99984LL; break; case 5: SP_IMEM[1] = 0xBDA807FC; reg[5] = 0xFFFFFFFFDECAAAD1LL; reg[14]= 0x000000000CF85C13LL; reg[24]= 0x0000000000000002LL; break; case 6: reg[5] = 0xFFFFFFFFB04DC903LL; reg[14]= 0x000000001AF99984LL; reg[24]= 0x0000000000000002LL; break; } reg[23]= 0x0000000000000006LL; reg[31]= 0xFFFFFFFFA4001554LL; break; case 0x37: case 0x41: case 0x45: case 0x4A: default: switch (CIC_Chip) { case 2: reg[5] = 0xFFFFFFFFC95973D5LL; reg[14]= 0x000000002449A366LL; break; case 3: reg[5] = 0xFFFFFFFF95315A28LL; reg[14]= 0x000000005BACA1DFLL; break; case 5: SP_IMEM[1] = 0x8DA807FC; reg[5] = 0x000000005493FB9ALL; reg[14]= 0xFFFFFFFFC2C20384LL; break; case 6: reg[5] = 0xFFFFFFFFE067221FLL; reg[14]= 0x000000005CD2B70FLL; break; } reg[20]= 0x0000000000000001LL; reg[24]= 0x0000000000000003LL; reg[31]= 0xFFFFFFFFA4001550LL; } switch (CIC_Chip) { case 1: reg[22]= 0x000000000000003FLL; break; case 2: reg[1] = 0x0000000000000001LL; reg[2] = 0x000000000EBDA536LL; reg[3] = 0x000000000EBDA536LL; reg[4] = 0x000000000000A536LL; reg[12]= 0xFFFFFFFFED10D0B3LL; reg[13]= 0x000000001402A4CCLL; reg[15]= 0x000000003103E121LL; reg[22]= 0x000000000000003FLL; reg[25]= 0xFFFFFFFF9DEBB54FLL; break; case 3: reg[1] = 0x0000000000000001LL; reg[2] = 0x0000000049A5EE96LL; reg[3] = 0x0000000049A5EE96LL; reg[4] = 0x000000000000EE96LL; reg[12]= 0xFFFFFFFFCE9DFBF7LL; reg[13]= 0xFFFFFFFFCE9DFBF7LL; reg[15]= 0x0000000018B63D28LL; reg[22]= 0x0000000000000078LL; reg[25]= 0xFFFFFFFF825B21C9LL; break; case 5: SP_IMEM[0] = 0x3C0DBFC0; SP_IMEM[2] = 0x25AD07C0; SP_IMEM[3] = 0x31080080; SP_IMEM[4] = 0x5500FFFC; SP_IMEM[5] = 0x3C0DBFC0; SP_IMEM[6] = 0x8DA80024; SP_IMEM[7] = 0x3C0BB000; reg[2] = 0xFFFFFFFFF58B0FBFLL; reg[3] = 0xFFFFFFFFF58B0FBFLL; reg[4] = 0x0000000000000FBFLL; reg[12]= 0xFFFFFFFF9651F81ELL; reg[13]= 0x000000002D42AAC5LL; reg[15]= 0x0000000056584D60LL; reg[22]= 0x0000000000000091LL; reg[25]= 0xFFFFFFFFCDCE565FLL; break; case 6: reg[2] = 0xFFFFFFFFA95930A4LL; reg[3] = 0xFFFFFFFFA95930A4LL; reg[4] = 0x00000000000030A4LL; reg[12]= 0xFFFFFFFFBCB59510LL; reg[13]= 0xFFFFFFFFBCB59510LL; reg[15]= 0x000000007A3C07F4LL; reg[22]= 0x0000000000000085LL; reg[25]= 0x00000000465E3F72LL; break; } rounding_mode = 0x33F; last_addr = 0xa4000040; next_interupt = 624999; init_interupt(); interpcore = 0; if (!dynacore) { printf ("interpreter\n"); init_blocks(); last_addr = PC->addr; while (!stop) { //if ((debug_count+Count) >= 0x78a8091) break; // obj 0x16aeb8a //if ((debug_count+Count) >= 0x16b1360) /*if ((debug_count+Count) >= 0xf203ae0) { printf ("PC=%x:%x\n", (unsigned int)(PC->addr), (unsigned int)(rdram[(PC->addr&0xFFFFFF)/4])); for (j=0; j<16; j++) printf ("reg[%2d]:%8x%8x reg[%d]:%8x%8x\n", j, (unsigned int)(reg[j] >> 32), (unsigned int)reg[j], j+16, (unsigned int)(reg[j+16] >> 32), (unsigned int)reg[j+16]); printf("hi:%8x%8x lo:%8x%8x\n", (unsigned int)(hi >> 32), (unsigned int)hi, (unsigned int)(lo >> 32), (unsigned int)lo); printf("après %d instructions soit %x\n",(unsigned int)(debug_count+Count) ,(unsigned int)(debug_count+Count)); getchar(); }*/ /*if ((debug_count+Count) >= 0x80000000) printf("%x:%x, %x\n", (int)PC->addr, (int)rdram[(PC->addr & 0xFFFFFF)/4], (int)(debug_count+Count));*/ #ifdef COMPARE_CORE if (PC->ops == FIN_BLOCK && (PC->addr < 0x80000000 || PC->addr >= 0xc0000000)) virtual_to_physical_address(PC->addr, 2); compare_core(); #endif #ifdef LUA_PCBREAK_INTERP if(enablePCBreak)LuaPCBreakInterp(); #endif PC->ops(); /*if (j!= (Count & 0xFFF00000)) { j = (Count & 0xFFF00000); printf("%x\n", j); }*/ //check_PC; #ifdef DBG if (debugger_mode) update_debugger(); #endif } } else if (dynacore == 2) { dynacore = 0; interpcore = 1; pure_interpreter(); } else { dynacore = 1; printf("dynamic recompiler\n"); init_blocks(); code = (void (*)(void))(actual->code+(actual->block[0x40/4].local_addr)); dyna_start(code); PC++; } debug_count+= Count; printf ("PC=%x:%x\n", (unsigned int)(PC->addr), (unsigned int)(rdram[(PC->addr&0xFFFFFF)/4])); for (j=0; j<16; j++) printf ("reg[%2d]:%8x%8x reg[%d]:%8x%8x\n", j, (unsigned int)(reg[j] >> 32), (unsigned int)reg[j], j+16, (unsigned int)(reg[j+16] >> 32), (unsigned int)reg[j+16]); printf("hi:%8x%8x lo:%8x%8x\n", (unsigned int)(hi >> 32), (unsigned int)hi, (unsigned int)(lo >> 32), (unsigned int)lo); printf("après %d instructions soit %x\n",(unsigned int)debug_count ,(unsigned int)debug_count); for (i=0; i<0x100000; i++) { if (blocks[i] != NULL) { if (blocks[i]->block) { free(blocks[i]->block); blocks[i]->block = NULL; } if (blocks[i]->code) { free(blocks[i]->code); blocks[i]->code = NULL; } if (blocks[i]->jumps_table) { free(blocks[i]->jumps_table); blocks[i]->jumps_table = NULL; } free(blocks[i]); blocks[i] = NULL; } } if (!dynacore && interpcore) free(PC); #ifdef VCR_SUPPORT VCR_coreStopped(); #endif }
39,254
C
.c
1,737
17.864709
114
0.579306
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,364
compare_core.c
anta0_mupen64-rr-lua-/r4300/compare_core.c
/** * Mupen64 - compare_core.c * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ #include <sys/stat.h> #include "r4300.h" #include "../memory/memory.h" #include "../main/plugin.h" #include "../r4300/recomph.h" #ifdef _MSC_VER #include <Windows.h> #else #include "../main/winlnxdefs.h" #endif static FILE *f; static int pipe_opened = 0; static long long int comp_reg[32]; extern unsigned long op; extern unsigned long interp_addr; static unsigned long old_op; int compare_core_mode = 0; void display_error(char *txt) { int i; unsigned long *comp_reg2 = (unsigned long *)comp_reg; printf("err: %s\n", txt); if (interpcore) { printf("addr:%x\n", (int)interp_addr); if (!strcmp(txt, "PC")) printf("%x - %x\n", (int)interp_addr, *(int*)&comp_reg[0]); } else { printf("addr:%x\n", (int)PC->addr); if (!strcmp(txt, "PC")) printf("%x - %x\n", (int)PC->addr, *(int*)&comp_reg[0]); } printf("%x, %x\n", (unsigned int)reg_cop0[9], (unsigned int)comp_reg2[9]); printf("erreur @:%x\n", (int)old_op); printf("erreur @:%x\n", (int)op); if (!strcmp(txt, "gpr")) { for (i=0; i<32; i++) { if (reg[i] != comp_reg[i]) printf("reg[%d]=%llx != reg[%d]=%llx\n", i, reg[i], i, comp_reg[i]); } } if (!strcmp(txt, "cop0")) { for (i=0; i<32; i++) { if (reg_cop0[i] != comp_reg2[i]) printf("reg_cop0[%d]=%x != reg_cop0[%d]=%x\n", i, (unsigned int)reg_cop0[i], i, (unsigned int)comp_reg2[i]); } } /*for (i=0; i<32; i++) { if (reg_cop0[i] != comp_reg[i]) printf("reg_cop0[%d]=%llx != reg[%d]=%llx\n", i, reg_cop0[i], i, comp_reg[i]); }*/ stop_it(); } void check_input_sync(unsigned char *value) { if (compare_core_mode == 0) return; if (compare_core_mode == 3 ? dynacore || interpcore : compare_core_mode == 1) { fread(value, 4, 1, f); } else { fwrite(value, 4, 1, f); } } void compare_core() { //static int wait=1; if (compare_core_mode == 0) { if (pipe_opened) { pipe_opened = 0; if (f) fclose(f); f = NULL; } return; } if (compare_core_mode == 3 ? dynacore || interpcore : compare_core_mode == 1) { if (pipe_opened != 1) { #ifdef _MSC_VER // TODO: “K“–‚É‘‚¢‚½B‚ ‚ÆACloseHandle() //HANDLE pipe = CreateNamedPipe( // "compare_pipe", // PIPE_ACCESS_DUPLEX, // PIPE_WAIT // | PIPE_READMODE_BYTE // | PIPE_TYPE_BYTE, // PIPE_UNLIMITED_INSTANCES, // 1024, // 1024, // 120 * 1000, // NULL); //::ConnectNamedPipe(pipe, NULL); #else mkfifo("compare_pipe", 0600); #endif if (f) fclose(f); f = fopen("compare_pipe", "rb"); pipe_opened = 1; } /*if(wait == 1 && reg_cop0[9] > 0x35000000) wait=0; if(wait) return;*/ fread (comp_reg, 1, sizeof(long), f); if (feof(f)) { pipe_opened = 0; fclose(f); f = NULL; compare_core_mode = 0; return; } if (interpcore) { if (memcmp(&interp_addr, comp_reg, 4)) display_error("PC"); } else { if (memcmp(&PC->addr, comp_reg, 4)) display_error("PC"); } /* fread (comp_reg, 32, sizeof(long long int), f); if (memcmp(reg, comp_reg, 32*sizeof(long long int))) display_error("gpr"); fread (comp_reg, 32, sizeof(long), f); if (memcmp(reg_cop0, comp_reg, 32*sizeof(long))) display_error("cop0"); fread (comp_reg, 32, sizeof(long long int), f); if (memcmp(reg_cop1_fgr_64, comp_reg, 32*sizeof(long long int))) display_error("cop1"); */ /*fread(comp_reg, 1, sizeof(long), f); if (memcmp(&rdram[0x31280/4], comp_reg, sizeof(long))) display_error("mem");*/ /*fread (comp_reg, 4, 1, f); if (memcmp(&FCR31, comp_reg, 4)) display_error();*/ old_op = op; } else { //if (reg_cop0[9] > 0x6800000) printf("PC=%x\n", (int)PC->addr); if (pipe_opened != 2) { if (f) fclose(f); f = fopen("compare_pipe", "wb"); pipe_opened = 2; } /*if(wait == 1 && reg_cop0[9] > 0x35000000) wait=0; if(wait) return;*/ if (interpcore) fwrite(&interp_addr, 1, sizeof(long), f); else fwrite(&PC->addr, 1, sizeof(long), f); /* fwrite(reg, 32, sizeof(long long int), f); fwrite(reg_cop0, 32, sizeof(long), f); fwrite(reg_cop1_fgr_64, 32, sizeof(long long int), f); */ //fwrite(&rdram[0x31280/4], 1, sizeof(long), f); /*fwrite(&FCR31, 4, 1, f);*/ } }
5,539
C
.c
204
22.529412
85
0.583239
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,356,380
rjump.c
anta0_mupen64-rr-lua-/r4300/x86/rjump.c
/** * Mupen64 - rjump.c * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ #include <stdlib.h> #include "../recomp.h" #include "../r4300.h" #include "../macros.h" #include "../ops.h" #include "../recomph.h" #include <csetjmp> void dyna_jump() { if (PC->reg_cache_infos.need_map) *return_address = (unsigned long)(PC->reg_cache_infos.jump_wrapper); else *return_address = (unsigned long)(actual->code + PC->local_addr); /*asm("mov return_address, %%esp \n" "ret \n" : : : "memory");*/ } jmp_buf g_jmp_state; void dyna_start(void (*code)()) { // code() のどこかで stop が true になった時、dyna_stop() が呼ばれ、longjmp() で setjmp() したところに戻る // 戻ってきた setjmp() は 1 を返すので、dyna_start() 終了 // レジスタ ebx, esi, edi, ebp の保存と復元が必要だが、setjmp() がやってくれる if(setjmp(g_jmp_state) == 0) { code(); } } void dyna_stop() { longjmp(g_jmp_state, 1); // goto dyna_start() }
1,898
C
.c
62
27.129032
81
0.685342
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,356,383
gr4300.c
anta0_mupen64-rr-lua-/r4300/x86/gr4300.c
/** * Mupen64 - gr4300.c * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ #include "assemble.h" #include "../r4300.h" #include "../macros.h" #include "../../memory/memory.h" #include "../interupt.h" #include "../ops.h" #include "../recomph.h" #include "regcache.h" #include "../exception.h" #include "interpret.h" extern unsigned long op; //pure_interp.c extern unsigned long src; //recomp.c precomp_instr fake_instr; static int eax, ebx, ecx, edx, esp, ebp, esi, edi; int branch_taken; void gennotcompiled() { free_all_registers(); simplify_access(); if (dst->addr == 0xa4000040) { mov_m32_reg32((unsigned long*)(&return_address), ESP); sub_m32_imm32((unsigned long*)(&return_address), 4); } mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(dst)); mov_reg32_imm32(EAX, (unsigned long)NOTCOMPILED); call_reg32(EAX); } void genlink_subblock() { free_all_registers(); jmp(dst->addr+4); } void gendebug() { //free_all_registers(); mov_m32_reg32((unsigned long*)&eax, EAX); mov_m32_reg32((unsigned long*)&ebx, EBX); mov_m32_reg32((unsigned long*)&ecx, ECX); mov_m32_reg32((unsigned long*)&edx, EDX); mov_m32_reg32((unsigned long*)&esp, ESP); mov_m32_reg32((unsigned long*)&ebp, EBP); mov_m32_reg32((unsigned long*)&esi, ESI); mov_m32_reg32((unsigned long*)&edi, EDI); mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(dst)); mov_m32_imm32((unsigned long*)(&op), (unsigned long)(src)); mov_reg32_imm32(EAX, (unsigned long)debug); call_reg32(EAX); mov_reg32_m32(EAX, (unsigned long*)&eax); mov_reg32_m32(EBX, (unsigned long*)&ebx); mov_reg32_m32(ECX, (unsigned long*)&ecx); mov_reg32_m32(EDX, (unsigned long*)&edx); mov_reg32_m32(ESP, (unsigned long*)&esp); mov_reg32_m32(EBP, (unsigned long*)&ebp); mov_reg32_m32(ESI, (unsigned long*)&esi); mov_reg32_m32(EDI, (unsigned long*)&edi); } void gencallinterp(unsigned long addr, int jump) { free_all_registers(); simplify_access(); if (jump) mov_m32_imm32((unsigned long*)(&dyna_interp), 1); mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(dst)); mov_reg32_imm32(EAX, addr); call_reg32(EAX); if (jump) { mov_m32_imm32((unsigned long*)(&dyna_interp), 0); mov_reg32_imm32(EAX, (unsigned long)dyna_jump); call_reg32(EAX); } } void genupdate_count(unsigned long addr) { #ifndef COMPARE_CORE #ifndef DBG mov_reg32_imm32(EAX, addr); sub_reg32_m32(EAX, (unsigned long*)(&last_addr)); shr_reg32_imm8(EAX, 1); add_m32_reg32((unsigned long*)(&Count), EAX); #else mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(dst+1)); mov_reg32_imm32(EAX, (unsigned long)update_count); call_reg32(EAX); #endif #else mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(dst+1)); mov_reg32_imm32(EAX, (unsigned long)update_count); call_reg32(EAX); #endif } void gendelayslot() { mov_m32_imm32((void*)(&delay_slot), 1); recompile_opcode(); free_all_registers(); genupdate_count(dst->addr+4); mov_m32_imm32((void*)(&delay_slot), 0); } void genni() { #ifdef EMU64_DEBUG gencallinterp((unsigned long)NI, 0); #endif } void genreserved() { #ifdef EMU64_DEBUG gencallinterp((unsigned long)RESERVED, 0); #endif } void genfin_block() { gencallinterp((unsigned long)FIN_BLOCK, 0); } void gencheck_interupt(unsigned long instr_structure) { mov_eax_memoffs32((void*)(&next_interupt)); cmp_reg32_m32(EAX, (void*)&Count); ja_rj(17); mov_m32_imm32((unsigned long*)(&PC), instr_structure); // 10 mov_reg32_imm32(EAX, (unsigned long)gen_interupt); // 5 call_reg32(EAX); // 2 } void gencheck_interupt_out(unsigned long addr) { mov_eax_memoffs32((void*)(&next_interupt)); cmp_reg32_m32(EAX, (void*)&Count); ja_rj(27); mov_m32_imm32((unsigned long*)(&fake_instr.addr), addr); mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(&fake_instr)); mov_reg32_imm32(EAX, (unsigned long)gen_interupt); call_reg32(EAX); } void gencheck_interupt_reg() // addr is in EAX { mov_reg32_m32(EBX, (void*)&next_interupt); cmp_reg32_m32(EBX, (void*)&Count); ja_rj(22); mov_memoffs32_eax((unsigned long*)(&fake_instr.addr)); // 5 mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(&fake_instr)); // 10 mov_reg32_imm32(EAX, (unsigned long)gen_interupt); // 5 call_reg32(EAX); // 2 } void gennop() { } void genj() { #ifdef INTERPRET_J gencallinterp((unsigned long)J, 1); #else unsigned long naddr; if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)J, 1); return; } gendelayslot(); naddr = ((dst-1)->f.j.inst_index<<2) | (dst->addr & 0xF0000000); mov_m32_imm32((void*)(&last_addr), naddr); gencheck_interupt((unsigned long)&actual->block[(naddr-actual->start)/4]); jmp(naddr); #endif } void genj_out() { #ifdef INTERPRET_J_OUT gencallinterp((unsigned long)J_OUT, 1); #else unsigned long naddr; if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)J_OUT, 1); return; } gendelayslot(); naddr = ((dst-1)->f.j.inst_index<<2) | (dst->addr & 0xF0000000); mov_m32_imm32((void*)(&last_addr), naddr); gencheck_interupt_out(naddr); mov_m32_imm32(&jump_to_address, naddr); mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(dst+1)); mov_reg32_imm32(EAX, (unsigned long)jump_to_func); call_reg32(EAX); #endif } void genj_idle() { #ifdef INTERPRET_J_IDLE gencallinterp((unsigned long)J_IDLE, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)J_IDLE, 1); return; } mov_eax_memoffs32((unsigned long *)(&next_interupt)); sub_reg32_m32(EAX, (unsigned long *)(&Count)); cmp_reg32_imm8(EAX, 3); jbe_rj(11); and_eax_imm32(0xFFFFFFFC); add_m32_reg32((unsigned long *)(&Count), EAX); genj(); #endif } void genjal() { #ifdef INTERPRET_JAL gencallinterp((unsigned long)JAL, 1); #else unsigned long naddr; if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)JAL, 1); return; } gendelayslot(); mov_m32_imm32((unsigned long *)(reg + 31), dst->addr + 4); if (((dst->addr + 4) & 0x80000000)) mov_m32_imm32((unsigned long *)(&reg[31])+1, 0xFFFFFFFF); else mov_m32_imm32((unsigned long *)(&reg[31])+1, 0); naddr = ((dst-1)->f.j.inst_index<<2) | (dst->addr & 0xF0000000); mov_m32_imm32((void*)(&last_addr), naddr); gencheck_interupt((unsigned long)&actual->block[(naddr-actual->start)/4]); jmp(naddr); #endif } void genjal_out() { #ifdef INTERPRET_JAL_OUT gencallinterp((unsigned long)JAL_OUT, 1); #else unsigned long naddr; if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)JAL_OUT, 1); return; } gendelayslot(); mov_m32_imm32((unsigned long *)(reg + 31), dst->addr + 4); if (((dst->addr + 4) & 0x80000000)) mov_m32_imm32((unsigned long *)(&reg[31])+1, 0xFFFFFFFF); else mov_m32_imm32((unsigned long *)(&reg[31])+1, 0); naddr = ((dst-1)->f.j.inst_index<<2) | (dst->addr & 0xF0000000); mov_m32_imm32((void*)(&last_addr), naddr); gencheck_interupt_out(naddr); mov_m32_imm32(&jump_to_address, naddr); mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(dst+1)); mov_reg32_imm32(EAX, (unsigned long)jump_to_func); call_reg32(EAX); #endif } void genjal_idle() { #ifdef INTERPRET_JAL_IDLE gencallinterp((unsigned long)JAL_IDLE, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)JAL_IDLE, 1); return; } mov_eax_memoffs32((unsigned long *)(&next_interupt)); sub_reg32_m32(EAX, (unsigned long *)(&Count)); cmp_reg32_imm8(EAX, 3); jbe_rj(11); and_eax_imm32(0xFFFFFFFC); add_m32_reg32((unsigned long *)(&Count), EAX); genjal(); #endif } void genbeq_test() { int rs_64bit = is64((unsigned long *)dst->f.i.rs); int rt_64bit = is64((unsigned long *)dst->f.i.rt); if (!rs_64bit && !rt_64bit) { int rs = allocate_register((unsigned long *)dst->f.i.rs); int rt = allocate_register((unsigned long *)dst->f.i.rt); cmp_reg32_reg32(rs, rt); jne_rj(12); mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 } else if (rs_64bit == -1) { int rt1 = allocate_64_register1((unsigned long *)dst->f.i.rt); int rt2 = allocate_64_register2((unsigned long *)dst->f.i.rt); cmp_reg32_m32(rt1, (unsigned long *)dst->f.i.rs); jne_rj(20); cmp_reg32_m32(rt2, ((unsigned long *)dst->f.i.rs)+1); // 6 jne_rj(12); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 } else if (rt_64bit == -1) { int rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); int rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); cmp_reg32_m32(rs1, (unsigned long *)dst->f.i.rt); jne_rj(20); cmp_reg32_m32(rs2, ((unsigned long *)dst->f.i.rt)+1); // 6 jne_rj(12); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 } else { int rs1, rs2, rt1, rt2; if (!rs_64bit) { rt1 = allocate_64_register1((unsigned long *)dst->f.i.rt); rt2 = allocate_64_register2((unsigned long *)dst->f.i.rt); rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); } else { rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); rt1 = allocate_64_register1((unsigned long *)dst->f.i.rt); rt2 = allocate_64_register2((unsigned long *)dst->f.i.rt); } cmp_reg32_reg32(rs1, rt1); jne_rj(16); cmp_reg32_reg32(rs2, rt2); // 2 jne_rj(12); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 } } void gentest() { unsigned long temp, temp2; cmp_m32_imm32((unsigned long *)(&branch_taken), 0); je_near_rj(0); temp = code_length; mov_m32_imm32((void*)(&last_addr), dst->addr + (dst-1)->f.i.immediate*4); gencheck_interupt((unsigned long)(dst + (dst-1)->f.i.immediate)); jmp(dst->addr + (dst-1)->f.i.immediate*4); temp2 = code_length; code_length = temp-4; put32(temp2 - temp); code_length = temp2; mov_m32_imm32((void*)(&last_addr), dst->addr + 4); gencheck_interupt((unsigned long)(dst + 1)); jmp(dst->addr + 4); } void genbeq() { #ifdef INTERPRET_BEQ gencallinterp((unsigned long)BEQ, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BEQ, 1); return; } genbeq_test(); gendelayslot(); gentest(); #endif } void gentest_out() { unsigned long temp, temp2; cmp_m32_imm32((unsigned long *)(&branch_taken), 0); je_near_rj(0); temp = code_length; mov_m32_imm32((void*)(&last_addr), dst->addr + (dst-1)->f.i.immediate*4); gencheck_interupt_out(dst->addr + (dst-1)->f.i.immediate*4); mov_m32_imm32(&jump_to_address, dst->addr + (dst-1)->f.i.immediate*4); mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(dst+1)); mov_reg32_imm32(EAX, (unsigned long)jump_to_func); call_reg32(EAX); temp2 = code_length; code_length = temp-4; put32(temp2 - temp); code_length = temp2; mov_m32_imm32((void*)(&last_addr), dst->addr + 4); gencheck_interupt((unsigned long)(dst + 1)); jmp(dst->addr + 4); } void genbeq_out() { #ifdef INTERPRET_BEQ_OUT gencallinterp((unsigned long)BEQ_OUT, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BEQ_OUT, 1); return; } genbeq_test(); gendelayslot(); gentest_out(); #endif } void gentest_idle() { unsigned long temp, temp2; int reg; reg = lru_register(); free_register(reg); cmp_m32_imm32((unsigned long *)(&branch_taken), 0); je_near_rj(0); temp = code_length; mov_reg32_m32(reg, (unsigned long *)(&next_interupt)); sub_reg32_m32(reg, (unsigned long *)(&Count)); cmp_reg32_imm8(reg, 3); jbe_rj(12); and_reg32_imm32(reg, 0xFFFFFFFC); // 6 add_m32_reg32((unsigned long *)(&Count), reg); // 6 temp2 = code_length; code_length = temp-4; put32(temp2 - temp); code_length = temp2; } void genbeq_idle() { #ifdef INTERPRET_BEQ_IDLE gencallinterp((unsigned long)BEQ_IDLE, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BEQ_IDLE, 1); return; } genbeq_test(); gentest_idle(); genbeq(); #endif } void genbne_test() { int rs_64bit = is64((unsigned long *)dst->f.i.rs); int rt_64bit = is64((unsigned long *)dst->f.i.rt); if (!rs_64bit && !rt_64bit) { int rs = allocate_register((unsigned long *)dst->f.i.rs); int rt = allocate_register((unsigned long *)dst->f.i.rt); cmp_reg32_reg32(rs, rt); je_rj(12); mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 } else if (rs_64bit == -1) { int rt1 = allocate_64_register1((unsigned long *)dst->f.i.rt); int rt2 = allocate_64_register2((unsigned long *)dst->f.i.rt); cmp_reg32_m32(rt1, (unsigned long *)dst->f.i.rs); jne_rj(20); cmp_reg32_m32(rt2, ((unsigned long *)dst->f.i.rs)+1); // 6 jne_rj(12); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 } else if (rt_64bit == -1) { int rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); int rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); cmp_reg32_m32(rs1, (unsigned long *)dst->f.i.rt); jne_rj(20); cmp_reg32_m32(rs2, ((unsigned long *)dst->f.i.rt)+1); // 6 jne_rj(12); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 } else { int rs1, rs2, rt1, rt2; if (!rs_64bit) { rt1 = allocate_64_register1((unsigned long *)dst->f.i.rt); rt2 = allocate_64_register2((unsigned long *)dst->f.i.rt); rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); } else { rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); rt1 = allocate_64_register1((unsigned long *)dst->f.i.rt); rt2 = allocate_64_register2((unsigned long *)dst->f.i.rt); } cmp_reg32_reg32(rs1, rt1); jne_rj(16); cmp_reg32_reg32(rs2, rt2); // 2 jne_rj(12); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 } } void genbne() { #ifdef INTERPRET_BNE gencallinterp((unsigned long)BNE, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BNE, 1); return; } genbne_test(); gendelayslot(); gentest(); #endif } void genbne_out() { #ifdef INTERPRET_BNE_OUT gencallinterp((unsigned long)BNE_OUT, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BNE_OUT, 1); return; } genbne_test(); gendelayslot(); gentest_out(); #endif } void genbne_idle() { #ifdef INTERPRET_BNE_IDLE gencallinterp((unsigned long)BNE_IDLE, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BNE_IDLE, 1); return; } genbne_test(); gentest_idle(); genbne(); #endif } void genblez_test() { int rs_64bit = is64((unsigned long *)dst->f.i.rs); if (!rs_64bit) { int rs = allocate_register((unsigned long *)dst->f.i.rs); cmp_reg32_imm32(rs, 0); jg_rj(12); mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 } else if (rs_64bit == -1) { cmp_m32_imm32(((unsigned long *)dst->f.i.rs)+1, 0); jg_rj(14); jne_rj(24); // 2 cmp_m32_imm32((unsigned long *)dst->f.i.rs, 0); // 10 je_rj(12); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 } else { int rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); int rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); cmp_reg32_imm32(rs2, 0); jg_rj(10); jne_rj(20); // 2 cmp_reg32_imm32(rs1, 0); // 6 je_rj(12); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 } } void genblez() { #ifdef INTERPRET_BLEZ gencallinterp((unsigned long)BLEZ, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BLEZ, 1); return; } genblez_test(); gendelayslot(); gentest(); #endif } void genblez_out() { #ifdef INTERPRET_BLEZ_OUT gencallinterp((unsigned long)BLEZ_OUT, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BLEZ_OUT, 1); return; } genblez_test(); gendelayslot(); gentest_out(); #endif } void genblez_idle() { #ifdef INTERPRET_BLEZ_IDLE gencallinterp((unsigned long)BLEZ_IDLE, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BLEZ_IDLE, 1); return; } genblez_test(); gentest_idle(); genblez(); #endif } void genbgtz_test() { int rs_64bit = is64((unsigned long *)dst->f.i.rs); if (!rs_64bit) { int rs = allocate_register((unsigned long *)dst->f.i.rs); cmp_reg32_imm32(rs, 0); jle_rj(12); mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 } else if (rs_64bit == -1) { cmp_m32_imm32(((unsigned long *)dst->f.i.rs)+1, 0); jl_rj(14); jne_rj(24); // 2 cmp_m32_imm32((unsigned long *)dst->f.i.rs, 0); // 10 jne_rj(12); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 } else { int rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); int rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); cmp_reg32_imm32(rs2, 0); jl_rj(10); jne_rj(20); // 2 cmp_reg32_imm32(rs1, 0); // 6 jne_rj(12); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 0); // 10 jmp_imm_short(10); // 2 mov_m32_imm32((unsigned long *)(&branch_taken), 1); // 10 } } void genbgtz() { #ifdef INTERPRET_BGTZ gencallinterp((unsigned long)BGTZ, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BGTZ, 1); return; } genbgtz_test(); gendelayslot(); gentest(); #endif } void genbgtz_out() { #ifdef INTERPRET_BGTZ_OUT gencallinterp((unsigned long)BGTZ_OUT, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BGTZ_OUT, 1); return; } genbgtz_test(); gendelayslot(); gentest_out(); #endif } void genbgtz_idle() { #ifdef INTERPRET_BGTZ_IDLE gencallinterp((unsigned long)BGTZ_IDLE, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BGTZ_IDLE, 1); return; } genbgtz_test(); gentest_idle(); genbgtz(); #endif } void genaddi() { #ifdef INTERPRET_ADDI gencallinterp((unsigned long)ADDI, 0); #else int rs = allocate_register((unsigned long *)dst->f.i.rs); int rt = allocate_register_w((unsigned long *)dst->f.i.rt); mov_reg32_reg32(rt, rs); add_reg32_imm32(rt,(long)dst->f.i.immediate); #endif } void genaddiu() { #ifdef INTERPRET_ADDIU gencallinterp((unsigned long)ADDIU, 0); #else int rs = allocate_register((unsigned long *)dst->f.i.rs); int rt = allocate_register_w((unsigned long *)dst->f.i.rt); mov_reg32_reg32(rt, rs); add_reg32_imm32(rt,(long)dst->f.i.immediate); #endif } void genslti() { #ifdef INTERPRET_SLTI gencallinterp((unsigned long)SLTI, 0); #else int rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); int rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); int rt = allocate_register_w((unsigned long *)dst->f.i.rt); long long imm = (long long)dst->f.i.immediate; cmp_reg32_imm32(rs2, (unsigned long)(imm >> 32)); jl_rj(17); jne_rj(8); // 2 cmp_reg32_imm32(rs1, (unsigned long)imm); // 6 jl_rj(7); // 2 mov_reg32_imm32(rt, 0); // 5 jmp_imm_short(5); // 2 mov_reg32_imm32(rt, 1); // 5 #endif } void gensltiu() { #ifdef INTERPRET_SLTIU gencallinterp((unsigned long)SLTIU, 0); #else int rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); int rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); int rt = allocate_register_w((unsigned long *)dst->f.i.rt); long long imm = (long long)dst->f.i.immediate; cmp_reg32_imm32(rs2, (unsigned long)(imm >> 32)); jb_rj(17); jne_rj(8); // 2 cmp_reg32_imm32(rs1, (unsigned long)imm); // 6 jb_rj(7); // 2 mov_reg32_imm32(rt, 0); // 5 jmp_imm_short(5); // 2 mov_reg32_imm32(rt, 1); // 5 #endif } void genandi() { #ifdef INTERPRET_ANDI gencallinterp((unsigned long)ANDI, 0); #else int rs = allocate_register((unsigned long *)dst->f.i.rs); int rt = allocate_register_w((unsigned long *)dst->f.i.rt); mov_reg32_reg32(rt, rs); and_reg32_imm32(rt, (unsigned short)dst->f.i.immediate); #endif } void genori() { #ifdef INTERPRET_ORI gencallinterp((unsigned long)ORI, 0); #else int rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); int rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); int rt1 = allocate_64_register1_w((unsigned long *)dst->f.i.rt); int rt2 = allocate_64_register2_w((unsigned long *)dst->f.i.rt); mov_reg32_reg32(rt1, rs1); mov_reg32_reg32(rt2, rs2); or_reg32_imm32(rt1, (unsigned short)dst->f.i.immediate); #endif } void genxori() { #ifdef INTERPRET_XORI gencallinterp((unsigned long)XORI, 0); #else int rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); int rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); int rt1 = allocate_64_register1_w((unsigned long *)dst->f.i.rt); int rt2 = allocate_64_register2_w((unsigned long *)dst->f.i.rt); mov_reg32_reg32(rt1, rs1); mov_reg32_reg32(rt2, rs2); xor_reg32_imm32(rt1, (unsigned short)dst->f.i.immediate); #endif } void genlui() { #ifdef INTERPRET_LUI gencallinterp((unsigned long)LUI, 0); #else int rt = allocate_register_w((unsigned long *)dst->f.i.rt); mov_reg32_imm32(rt, (unsigned long)dst->f.i.immediate << 16); #endif } void gentestl() { unsigned long temp, temp2; cmp_m32_imm32((unsigned long *)(&branch_taken), 0); je_near_rj(0); temp = code_length; gendelayslot(); mov_m32_imm32((void*)(&last_addr), dst->addr + (dst-1)->f.i.immediate*4); gencheck_interupt((unsigned long)(dst + (dst-1)->f.i.immediate)); jmp(dst->addr + (dst-1)->f.i.immediate*4); temp2 = code_length; code_length = temp-4; put32(temp2 - temp); code_length = temp2; genupdate_count(dst->addr-4); mov_m32_imm32((void*)(&last_addr), dst->addr + 4); gencheck_interupt((unsigned long)(dst + 1)); jmp(dst->addr + 4); } void genbeql() { #ifdef INTERPRET_BEQL gencallinterp((unsigned long)BEQL, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BEQL, 1); return; } genbeq_test(); free_all_registers(); gentestl(); #endif } void gentestl_out() { unsigned long temp, temp2; cmp_m32_imm32((unsigned long *)(&branch_taken), 0); je_near_rj(0); temp = code_length; gendelayslot(); mov_m32_imm32((void*)(&last_addr), dst->addr + (dst-1)->f.i.immediate*4); gencheck_interupt_out(dst->addr + (dst-1)->f.i.immediate*4); mov_m32_imm32(&jump_to_address, dst->addr + (dst-1)->f.i.immediate*4); mov_m32_imm32((unsigned long*)(&PC), (unsigned long)(dst+1)); mov_reg32_imm32(EAX, (unsigned long)jump_to_func); call_reg32(EAX); temp2 = code_length; code_length = temp-4; put32(temp2 - temp); code_length = temp2; genupdate_count(dst->addr-4); mov_m32_imm32((void*)(&last_addr), dst->addr + 4); gencheck_interupt((unsigned long)(dst + 1)); jmp(dst->addr + 4); } void genbeql_out() { #ifdef INTERPRET_BEQL_OUT gencallinterp((unsigned long)BEQL_OUT, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BEQL_OUT, 1); return; } genbeq_test(); free_all_registers(); gentestl_out(); #endif } void genbeql_idle() { #ifdef INTERPRET_BEQL_IDLE gencallinterp((unsigned long)BEQL_IDLE, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BEQL_IDLE, 1); return; } genbeq_test(); gentest_idle(); genbeql(); #endif } void genbnel() { #ifdef INTERPRET_BNEL gencallinterp((unsigned long)BNEL, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BNEL, 1); return; } genbne_test(); free_all_registers(); gentestl(); #endif } void genbnel_out() { #ifdef INTERPRET_BNEL_OUT gencallinterp((unsigned long)BNEL_OUT, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BNEL_OUT, 1); return; } genbne_test(); free_all_registers(); gentestl_out(); #endif } void genbnel_idle() { #ifdef INTERPRET_BNEL_IDLE gencallinterp((unsigned long)BNEL_IDLE, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BNEL_IDLE, 1); return; } genbne_test(); gentest_idle(); genbnel(); #endif } void genblezl() { #ifdef INTERPRET_BLEZL gencallinterp((unsigned long)BLEZL, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BLEZL, 1); return; } genblez_test(); free_all_registers(); gentestl(); #endif } void genblezl_out() { #ifdef INTERPRET_BLEZL_OUT gencallinterp((unsigned long)BLEZL_OUT, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BLEZL_OUT, 1); return; } genblez_test(); free_all_registers(); gentestl_out(); #endif } void genblezl_idle() { #ifdef INTERPRET_BLEZL_IDLE gencallinterp((unsigned long)BLEZL_IDLE, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BLEZL_IDLE, 1); return; } genblez_test(); gentest_idle(); genblezl(); #endif } void genbgtzl() { #ifdef INTERPRET_BGTZL gencallinterp((unsigned long)BGTZL, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BGTZL, 1); return; } genbgtz_test(); free_all_registers(); gentestl(); #endif } void genbgtzl_out() { #ifdef INTERPRET_BGTZL_OUT gencallinterp((unsigned long)BGTZL_OUT, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BGTZL_OUT, 1); return; } genbgtz_test(); free_all_registers(); gentestl_out(); #endif } void genbgtzl_idle() { #ifdef INTERPRET_BGTZL_IDLE gencallinterp((unsigned long)BGTZL_IDLE, 1); #else if (((dst->addr & 0xFFF) == 0xFFC && (dst->addr < 0x80000000 || dst->addr >= 0xC0000000))||no_compiled_jump) { gencallinterp((unsigned long)BGTZL_IDLE, 1); return; } genbgtz_test(); gentest_idle(); genbgtzl(); #endif } void gendaddi() { #ifdef INTERPRET_DADDI gencallinterp((unsigned long)DADDI, 0); #else int rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); int rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); int rt1 = allocate_64_register1_w((unsigned long *)dst->f.i.rt); int rt2 = allocate_64_register2_w((unsigned long *)dst->f.i.rt); mov_reg32_reg32(rt1, rs1); mov_reg32_reg32(rt2, rs2); add_reg32_imm32(rt1, dst->f.i.immediate); adc_reg32_imm32(rt2, (int)dst->f.i.immediate>>31); #endif } void gendaddiu() { #ifdef INTERPRET_DADDIU gencallinterp((unsigned long)DADDIU, 0); #else int rs1 = allocate_64_register1((unsigned long *)dst->f.i.rs); int rs2 = allocate_64_register2((unsigned long *)dst->f.i.rs); int rt1 = allocate_64_register1_w((unsigned long *)dst->f.i.rt); int rt2 = allocate_64_register2_w((unsigned long *)dst->f.i.rt); mov_reg32_reg32(rt1, rs1); mov_reg32_reg32(rt2, rs2); add_reg32_imm32(rt1, dst->f.i.immediate); adc_reg32_imm32(rt2, (int)dst->f.i.immediate>>31); #endif } void genldl() { gencallinterp((unsigned long)LDL, 0); } void genldr() { gencallinterp((unsigned long)LDR, 0); } void genlb() { #ifdef INTERPRET_LB gencallinterp((unsigned long)LB, 0); #else free_all_registers(); simplify_access(); mov_eax_memoffs32((unsigned long *)dst->f.i.rs); add_eax_imm32((long)dst->f.i.immediate); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)readmemb); cmp_reg32_imm32(EAX, (unsigned long)read_rdramb); } je_rj(47); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m32_imm32((unsigned long *)(&rdword), (unsigned long)dst->f.i.rt); // 10 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)readmemb); // 7 call_reg32(EBX); // 2 movsx_reg32_m8(EAX, (unsigned char *)dst->f.i.rt); // 7 jmp_imm_short(16); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 xor_reg8_imm8(BL, 3); // 3 movsx_reg32_8preg32pimm32(EAX, EBX, (unsigned long)rdram); // 7 set_register_state(EAX, (unsigned long*)dst->f.i.rt, 1); #endif } void genlh() { #ifdef INTERPRET_LH gencallinterp((unsigned long)LH, 0); #else free_all_registers(); simplify_access(); mov_eax_memoffs32((unsigned long *)dst->f.i.rs); add_eax_imm32((long)dst->f.i.immediate); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)readmemh); cmp_reg32_imm32(EAX, (unsigned long)read_rdramh); } je_rj(47); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m32_imm32((unsigned long *)(&rdword), (unsigned long)dst->f.i.rt); // 10 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)readmemh); // 7 call_reg32(EBX); // 2 movsx_reg32_m16(EAX, (unsigned short *)dst->f.i.rt); // 7 jmp_imm_short(16); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 xor_reg8_imm8(BL, 2); // 3 movsx_reg32_16preg32pimm32(EAX, EBX, (unsigned long)rdram); // 7 set_register_state(EAX, (unsigned long*)dst->f.i.rt, 1); #endif } void genlwl() { gencallinterp((unsigned long)LWL, 0); } void genlw() { #ifdef INTERPRET_LW gencallinterp((unsigned long)LW, 0); #else free_all_registers(); simplify_access(); mov_eax_memoffs32((unsigned long *)dst->f.i.rs); add_eax_imm32((long)dst->f.i.immediate); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)readmem); cmp_reg32_imm32(EAX, (unsigned long)read_rdram); } je_rj(45); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m32_imm32((unsigned long *)(&rdword), (unsigned long)dst->f.i.rt); // 10 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)readmem); // 7 call_reg32(EBX); // 2 mov_eax_memoffs32((unsigned long *)(dst->f.i.rt)); // 5 jmp_imm_short(12); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 mov_reg32_preg32pimm32(EAX, EBX, (unsigned long)rdram); // 6 set_register_state(EAX, (unsigned long*)dst->f.i.rt, 1); #endif } void genlbu() { #ifdef INTERPRET_LBU gencallinterp((unsigned long)LBU, 0); #else free_all_registers(); simplify_access(); mov_eax_memoffs32((unsigned long *)dst->f.i.rs); add_eax_imm32((long)dst->f.i.immediate); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)readmemb); cmp_reg32_imm32(EAX, (unsigned long)read_rdramb); } je_rj(46); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m32_imm32((unsigned long *)(&rdword), (unsigned long)dst->f.i.rt); // 10 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)readmemb); // 7 call_reg32(EBX); // 2 mov_reg32_m32(EAX, (unsigned long *)dst->f.i.rt); // 6 jmp_imm_short(15); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 xor_reg8_imm8(BL, 3); // 3 mov_reg32_preg32pimm32(EAX, EBX, (unsigned long)rdram); // 6 and_eax_imm32(0xFF); set_register_state(EAX, (unsigned long*)dst->f.i.rt, 1); #endif } void genlhu() { #ifdef INTERPRET_LHU gencallinterp((unsigned long)LHU, 0); #else free_all_registers(); simplify_access(); mov_eax_memoffs32((unsigned long *)dst->f.i.rs); add_eax_imm32((long)dst->f.i.immediate); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)readmemh); cmp_reg32_imm32(EAX, (unsigned long)read_rdramh); } je_rj(46); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m32_imm32((unsigned long *)(&rdword), (unsigned long)dst->f.i.rt); // 10 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)readmemh); // 7 call_reg32(EBX); // 2 mov_reg32_m32(EAX, (unsigned long *)dst->f.i.rt); // 6 jmp_imm_short(15); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 xor_reg8_imm8(BL, 2); // 3 mov_reg32_preg32pimm32(EAX, EBX, (unsigned long)rdram); // 6 and_eax_imm32(0xFFFF); set_register_state(EAX, (unsigned long*)dst->f.i.rt, 1); #endif } void genlwr() { gencallinterp((unsigned long)LWR, 0); } void genlwu() { #ifdef INTERPRET_LWU gencallinterp((unsigned long)LWU, 0); #else free_all_registers(); simplify_access(); mov_eax_memoffs32((unsigned long *)dst->f.i.rs); add_eax_imm32((long)dst->f.i.immediate); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)readmem); cmp_reg32_imm32(EAX, (unsigned long)read_rdram); } je_rj(45); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m32_imm32((unsigned long *)(&rdword), (unsigned long)dst->f.i.rt); // 10 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)readmem); // 7 call_reg32(EBX); // 2 mov_eax_memoffs32((unsigned long *)(dst->f.i.rt)); // 5 jmp_imm_short(12); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 mov_reg32_preg32pimm32(EAX, EBX, (unsigned long)rdram); // 6 xor_reg32_reg32(EBX, EBX); set_64_register_state(EAX, EBX, (unsigned long*)dst->f.i.rt, 1); #endif } void gensb() { #ifdef INTERPRET_SB gencallinterp((unsigned long)SB, 0); #else free_all_registers(); simplify_access(); mov_reg8_m8(CL, (unsigned char *)dst->f.i.rt); mov_eax_memoffs32((unsigned long *)dst->f.i.rs); add_eax_imm32((long)dst->f.i.immediate); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)writememb); cmp_reg32_imm32(EAX, (unsigned long)write_rdramb); } je_rj(41); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m8_reg8((unsigned char *)(&g_byte), CL); // 6 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)writememb); // 7 call_reg32(EBX); // 2 mov_eax_memoffs32((unsigned long *)(&address)); // 5 jmp_imm_short(17); // 2 mov_reg32_reg32(EAX, EBX); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 xor_reg8_imm8(BL, 3); // 3 mov_preg32pimm32_reg8(EBX, (unsigned long)rdram, CL); // 6 mov_reg32_reg32(EBX, EAX); shr_reg32_imm8(EBX, 12); cmp_preg32pimm32_imm8(EBX, (unsigned long)invalid_code, 0); jne_rj(54); mov_reg32_reg32(ECX, EBX); // 2 shl_reg32_imm8(EBX, 2); // 3 mov_reg32_preg32pimm32(EBX, EBX, (unsigned long)blocks); // 6 mov_reg32_preg32pimm32(EBX, EBX, (int)&actual->block - (int)actual); // 6 and_eax_imm32(0xFFF); // 5 shr_reg32_imm8(EAX, 2); // 3 mov_reg32_imm32(EDX, sizeof(precomp_instr)); // 5 mul_reg32(EDX); // 2 mov_reg32_preg32preg32pimm32(EAX, EAX, EBX, (int)&dst->ops - (int)dst); // 7 cmp_reg32_imm32(EAX, (unsigned long)NOTCOMPILED); // 6 je_rj(7); // 2 mov_preg32pimm32_imm8(ECX, (unsigned long)invalid_code, 1); // 7 #endif } void gensh() { #ifdef INTERPRET_SH gencallinterp((unsigned long)SH, 0); #else free_all_registers(); simplify_access(); mov_reg16_m16(CX, (unsigned short *)dst->f.i.rt); mov_eax_memoffs32((unsigned long *)dst->f.i.rs); add_eax_imm32((long)dst->f.i.immediate); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)writememh); cmp_reg32_imm32(EAX, (unsigned long)write_rdramh); } je_rj(42); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m16_reg16((unsigned short *)(&hword), CX); // 7 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)writememh); // 7 call_reg32(EBX); // 2 mov_eax_memoffs32((unsigned long *)(&address)); // 5 jmp_imm_short(18); // 2 mov_reg32_reg32(EAX, EBX); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 xor_reg8_imm8(BL, 2); // 3 mov_preg32pimm32_reg16(EBX, (unsigned long)rdram, CX); // 7 mov_reg32_reg32(EBX, EAX); shr_reg32_imm8(EBX, 12); cmp_preg32pimm32_imm8(EBX, (unsigned long)invalid_code, 0); jne_rj(54); mov_reg32_reg32(ECX, EBX); // 2 shl_reg32_imm8(EBX, 2); // 3 mov_reg32_preg32pimm32(EBX, EBX, (unsigned long)blocks); // 6 mov_reg32_preg32pimm32(EBX, EBX, (int)&actual->block - (int)actual); // 6 and_eax_imm32(0xFFF); // 5 shr_reg32_imm8(EAX, 2); // 3 mov_reg32_imm32(EDX, sizeof(precomp_instr)); // 5 mul_reg32(EDX); // 2 mov_reg32_preg32preg32pimm32(EAX, EAX, EBX, (int)&dst->ops - (int)dst); // 7 cmp_reg32_imm32(EAX, (unsigned long)NOTCOMPILED); // 6 je_rj(7); // 2 mov_preg32pimm32_imm8(ECX, (unsigned long)invalid_code, 1); // 7 #endif } void genswl() { gencallinterp((unsigned long)SWL, 0); } void gensw() { #ifdef INTERPRET_SW gencallinterp((unsigned long)SW, 0); #else free_all_registers(); simplify_access(); mov_reg32_m32(ECX, (unsigned long *)dst->f.i.rt); mov_eax_memoffs32((unsigned long *)dst->f.i.rs); add_eax_imm32((long)dst->f.i.immediate); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)writemem); cmp_reg32_imm32(EAX, (unsigned long)write_rdram); } je_rj(41); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m32_reg32((unsigned long *)(&word), ECX); // 6 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)writemem); // 7 call_reg32(EBX); // 2 mov_eax_memoffs32((unsigned long *)(&address)); // 5 jmp_imm_short(14); // 2 mov_reg32_reg32(EAX, EBX); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 mov_preg32pimm32_reg32(EBX, (unsigned long)rdram, ECX); // 6 mov_reg32_reg32(EBX, EAX); shr_reg32_imm8(EBX, 12); cmp_preg32pimm32_imm8(EBX, (unsigned long)invalid_code, 0); jne_rj(54); mov_reg32_reg32(ECX, EBX); // 2 shl_reg32_imm8(EBX, 2); // 3 mov_reg32_preg32pimm32(EBX, EBX, (unsigned long)blocks); // 6 mov_reg32_preg32pimm32(EBX, EBX, (int)&actual->block - (int)actual); // 6 and_eax_imm32(0xFFF); // 5 shr_reg32_imm8(EAX, 2); // 3 mov_reg32_imm32(EDX, sizeof(precomp_instr)); // 5 mul_reg32(EDX); // 2 mov_reg32_preg32preg32pimm32(EAX, EAX, EBX, (int)&dst->ops - (int)dst); // 7 cmp_reg32_imm32(EAX, (unsigned long)NOTCOMPILED); // 6 je_rj(7); // 2 mov_preg32pimm32_imm8(ECX, (unsigned long)invalid_code, 1); // 7 #endif } void gensdl() { gencallinterp((unsigned long)SDL, 0); } void gensdr() { gencallinterp((unsigned long)SDR, 0); } void genswr() { gencallinterp((unsigned long)SWR, 0); } #include <malloc.h> inline void put8gr(unsigned char octet) { (*inst_pointer)[code_length] = octet; code_length++; if (code_length == max_code_length) { max_code_length += 1000; *inst_pointer = (unsigned char*) realloc(*inst_pointer, max_code_length); } } void gencheck_cop1_unusable() { unsigned long temp, temp2; free_all_registers(); simplify_access(); test_m32_imm32((unsigned long*)&Status, 0x20000000); jne_rj(0); temp = code_length; gencallinterp((unsigned long)check_cop1_unusable, 0); temp2 = code_length; code_length = temp - 1; put8gr(temp2 - temp); code_length = temp2; } void genlwc1() { #ifdef INTERPRET_LWC1 gencallinterp((unsigned long)LWC1, 0); #else gencheck_cop1_unusable(); mov_eax_memoffs32((unsigned long *)(&reg[dst->f.lf.base])); add_eax_imm32((long)dst->f.lf.offset); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)readmem); cmp_reg32_imm32(EAX, (unsigned long)read_rdram); } je_rj(42); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_reg32_m32(EDX, (unsigned long*)(&reg_cop1_simple[dst->f.lf.ft])); // 6 mov_m32_reg32((unsigned long *)(&rdword), EDX); // 6 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)readmem); // 7 call_reg32(EBX); // 2 jmp_imm_short(20); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 mov_reg32_preg32pimm32(EAX, EBX, (unsigned long)rdram); // 6 mov_reg32_m32(EBX, (unsigned long*)(&reg_cop1_simple[dst->f.lf.ft])); // 6 mov_preg32_reg32(EBX, EAX); // 2 #endif } void genldc1() { #ifdef INTERPRET_LDC1 gencallinterp((unsigned long)LDC1, 0); #else gencheck_cop1_unusable(); mov_eax_memoffs32((unsigned long *)(&reg[dst->f.lf.base])); add_eax_imm32((long)dst->f.lf.offset); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)readmemd); cmp_reg32_imm32(EAX, (unsigned long)read_rdramd); } je_rj(42); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_reg32_m32(EDX, (unsigned long*)(&reg_cop1_double[dst->f.lf.ft])); // 6 mov_m32_reg32((unsigned long *)(&rdword), EDX); // 6 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)readmemd); // 7 call_reg32(EBX); // 2 jmp_imm_short(32); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 mov_reg32_preg32pimm32(EAX, EBX, ((unsigned long)rdram)+4); // 6 mov_reg32_preg32pimm32(ECX, EBX, ((unsigned long)rdram)); // 6 mov_reg32_m32(EBX, (unsigned long*)(&reg_cop1_double[dst->f.lf.ft])); // 6 mov_preg32_reg32(EBX, EAX); // 2 mov_preg32pimm32_reg32(EBX, 4, ECX); // 6 #endif } void gencache() { } void genld() { #ifdef INTERPRET_LD gencallinterp((unsigned long)LD, 0); #else free_all_registers(); simplify_access(); mov_eax_memoffs32((unsigned long *)dst->f.i.rs); add_eax_imm32((long)dst->f.i.immediate); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)readmemd); cmp_reg32_imm32(EAX, (unsigned long)read_rdramd); } je_rj(51); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m32_imm32((unsigned long *)(&rdword), (unsigned long)dst->f.i.rt); // 10 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)readmemd); // 7 call_reg32(EBX); // 2 mov_eax_memoffs32((unsigned long *)(dst->f.i.rt)); // 5 mov_reg32_m32(ECX, (unsigned long *)(dst->f.i.rt)+1); // 6 jmp_imm_short(18); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 mov_reg32_preg32pimm32(EAX, EBX, ((unsigned long)rdram)+4); // 6 mov_reg32_preg32pimm32(ECX, EBX, ((unsigned long)rdram)); // 6 set_64_register_state(EAX, ECX, (unsigned long*)dst->f.i.rt, 1); #endif } void genswc1() { #ifdef INTERPRET_SWC1 gencallinterp((unsigned long)SWC1, 0); #else gencheck_cop1_unusable(); mov_reg32_m32(EDX, (unsigned long*)(&reg_cop1_simple[dst->f.lf.ft])); mov_reg32_preg32(ECX, EDX); mov_eax_memoffs32((unsigned long *)(&reg[dst->f.lf.base])); add_eax_imm32((long)dst->f.lf.offset); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)writemem); cmp_reg32_imm32(EAX, (unsigned long)write_rdram); } je_rj(41); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m32_reg32((unsigned long *)(&word), ECX); // 6 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)writemem); // 7 call_reg32(EBX); // 2 mov_eax_memoffs32((unsigned long *)(&address)); // 5 jmp_imm_short(14); // 2 mov_reg32_reg32(EAX, EBX); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 mov_preg32pimm32_reg32(EBX, (unsigned long)rdram, ECX); // 6 mov_reg32_reg32(EBX, EAX); shr_reg32_imm8(EBX, 12); cmp_preg32pimm32_imm8(EBX, (unsigned long)invalid_code, 0); jne_rj(54); mov_reg32_reg32(ECX, EBX); // 2 shl_reg32_imm8(EBX, 2); // 3 mov_reg32_preg32pimm32(EBX, EBX, (unsigned long)blocks); // 6 mov_reg32_preg32pimm32(EBX, EBX, (int)&actual->block - (int)actual); // 6 and_eax_imm32(0xFFF); // 5 shr_reg32_imm8(EAX, 2); // 3 mov_reg32_imm32(EDX, sizeof(precomp_instr)); // 5 mul_reg32(EDX); // 2 mov_reg32_preg32preg32pimm32(EAX, EAX, EBX, (int)&dst->ops - (int)dst); // 7 cmp_reg32_imm32(EAX, (unsigned long)NOTCOMPILED); // 6 je_rj(7); // 2 mov_preg32pimm32_imm8(ECX, (unsigned long)invalid_code, 1); // 7 #endif } void gensdc1() { #ifdef INTERPRET_SDC1 gencallinterp((unsigned long)SDC1, 0); #else gencheck_cop1_unusable(); mov_reg32_m32(ESI, (unsigned long*)(&reg_cop1_double[dst->f.lf.ft])); mov_reg32_preg32(ECX, ESI); mov_reg32_preg32pimm32(EDX, ESI, 4); mov_eax_memoffs32((unsigned long *)(&reg[dst->f.lf.base])); add_eax_imm32((long)dst->f.lf.offset); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)writememd); cmp_reg32_imm32(EAX, (unsigned long)write_rdramd); } je_rj(47); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m32_reg32((unsigned long *)(&dword), ECX); // 6 mov_m32_reg32((unsigned long *)(&dword)+1, EDX); // 6 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)writememd); // 7 call_reg32(EBX); // 2 mov_eax_memoffs32((unsigned long *)(&address)); // 5 jmp_imm_short(20); // 2 mov_reg32_reg32(EAX, EBX); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 mov_preg32pimm32_reg32(EBX, ((unsigned long)rdram)+4, ECX); // 6 mov_preg32pimm32_reg32(EBX, ((unsigned long)rdram)+0, EDX); // 6 mov_reg32_reg32(EBX, EAX); shr_reg32_imm8(EBX, 12); cmp_preg32pimm32_imm8(EBX, (unsigned long)invalid_code, 0); jne_rj(54); mov_reg32_reg32(ECX, EBX); // 2 shl_reg32_imm8(EBX, 2); // 3 mov_reg32_preg32pimm32(EBX, EBX, (unsigned long)blocks); // 6 mov_reg32_preg32pimm32(EBX, EBX, (int)&actual->block - (int)actual); // 6 and_eax_imm32(0xFFF); // 5 shr_reg32_imm8(EAX, 2); // 3 mov_reg32_imm32(EDX, sizeof(precomp_instr)); // 5 mul_reg32(EDX); // 2 mov_reg32_preg32preg32pimm32(EAX, EAX, EBX, (int)&dst->ops - (int)dst); // 7 cmp_reg32_imm32(EAX, (unsigned long)NOTCOMPILED); // 6 je_rj(7); // 2 mov_preg32pimm32_imm8(ECX, (unsigned long)invalid_code, 1); // 7 #endif } void gensd() { #ifdef INTERPRET_SD gencallinterp((unsigned long)SD, 0); #else free_all_registers(); simplify_access(); mov_reg32_m32(ECX, (unsigned long *)dst->f.i.rt); mov_reg32_m32(EDX, ((unsigned long *)dst->f.i.rt)+1); mov_eax_memoffs32((unsigned long *)dst->f.i.rs); add_eax_imm32((long)dst->f.i.immediate); mov_reg32_reg32(EBX, EAX); if(fast_memory) { and_eax_imm32(0xDF800000); cmp_eax_imm32(0x80000000); } else { shr_reg32_imm8(EAX, 16); mov_reg32_preg32x4pimm32(EAX, EAX, (unsigned long)writememd); cmp_reg32_imm32(EAX, (unsigned long)write_rdramd); } je_rj(47); mov_m32_imm32((void *)(&PC), (unsigned long)(dst+1)); // 10 mov_m32_reg32((unsigned long *)(&address), EBX); // 6 mov_m32_reg32((unsigned long *)(&dword), ECX); // 6 mov_m32_reg32((unsigned long *)(&dword)+1, EDX); // 6 shr_reg32_imm8(EBX, 16); // 3 mov_reg32_preg32x4pimm32(EBX, EBX, (unsigned long)writememd); // 7 call_reg32(EBX); // 2 mov_eax_memoffs32((unsigned long *)(&address)); // 5 jmp_imm_short(20); // 2 mov_reg32_reg32(EAX, EBX); // 2 and_reg32_imm32(EBX, 0x7FFFFF); // 6 mov_preg32pimm32_reg32(EBX, ((unsigned long)rdram)+4, ECX); // 6 mov_preg32pimm32_reg32(EBX, ((unsigned long)rdram)+0, EDX); // 6 mov_reg32_reg32(EBX, EAX); shr_reg32_imm8(EBX, 12); cmp_preg32pimm32_imm8(EBX, (unsigned long)invalid_code, 0); jne_rj(54); mov_reg32_reg32(ECX, EBX); // 2 shl_reg32_imm8(EBX, 2); // 3 mov_reg32_preg32pimm32(EBX, EBX, (unsigned long)blocks); // 6 mov_reg32_preg32pimm32(EBX, EBX, (int)&actual->block - (int)actual); // 6 and_eax_imm32(0xFFF); // 5 shr_reg32_imm8(EAX, 2); // 3 mov_reg32_imm32(EDX, sizeof(precomp_instr)); // 5 mul_reg32(EDX); // 2 mov_reg32_preg32preg32pimm32(EAX, EAX, EBX, (int)&dst->ops - (int)dst); // 7 cmp_reg32_imm32(EAX, (unsigned long)NOTCOMPILED); // 6 je_rj(7); // 2 mov_preg32pimm32_imm8(ECX, (unsigned long)invalid_code, 1); // 7 #endif } void genll() { gencallinterp((unsigned long)LL, 0); } void gensc() { gencallinterp((unsigned long)SC, 0); }
55,395
C
.c
1,844
26.478308
79
0.648826
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,407
resource.h
anta0_mupen64-rr-lua-/winproject/resource.h
#define IDC_STATIC -1 #define IDR_MYMENU 101 #define IDR_ACCEL 103 #define ID_LOAD_CONFIG 105 #define IDD_MAIN 128 #define IDLOAD 129 #define IDC_INTERP 130 #define IDC_RECOMP 131 #define IDC_PURE_INTERP 132 #define IDB_LOGO 133 #define IDC_LOGO 134 #define IDC_COMBO_GFX 135 #define IDGFXCONFIG 136 #define IDGFXTEST 137 #define IDGFXABOUT 138 #define IDC_COMBO_INPUT 139 #define IDINPUTCONFIG 140 #define IDINPUTTEST 141 #define IDINPUTABOUT 142 #define IDC_CPUCORE 143 #define IDC_GFXPLUGIN 144 #define IDC_INPUTPLUGIN 145 #define IDC_SOUNDPLUGIN 146 #define IDI_AUSTRALIA 147 #define IDI_USA 148 #define IDI_JAPAN 149 #define IDI_GERMANY 150 #define IDI_EUROPE 151 #define IDI_N64CART 152 #define IDI_ITALIA 153 #define IDI_SPAIN 154 #define IDI_FRANCE 155 #define IDI_UNKNOWN 156 #define IDI_DEMO 157 #define IDI_BETA 158 #define ID_HELP_ABOUT 160 #define ID_HELP_CONTENS 161 #define ID_HELP_WHATSNEW 162 #define IDC_COMBO_SOUND 163 #define IDSOUNDCONFIG 164 #define IDSOUNDTEST 165 #define IDSOUNDABOUT 166 #define IDB_UP_ARROW 167 #define IDB_DOWN_ARROW 168 #define IDI_SIF 169 #define IDI_M64ICONSMALL 180 #define IDI_M64ICONBIG 181 //Lua #define IDD_LUAWINDOW 182 #define IDD_LUAINPUTPROMPT 183 #define IDC_WEBSITE 190 #define IDC_COMBO_RSP 200 #define IDRSPCONFIG 201 #define IDC_RSPPLUGIN 202 #define IDRSPTEST 203 #define IDRSPABOUT 204 #define IDD_ABOUT 1020 #define FULL_SCREEN 1061 #define EMU_PAUSE 1062 #define EMU_FRAMEADVANCE 1063 #define EMU_PLAY 1064 #define EMU_STOP 1065 #define REFRESH_ROM_BROWSER 1066 #define EMU_VCRTOGGLEREADONLY 1067 #define IDC_TOOLBAR 1000 #define IDB_TOOLBAR 1001 #define IDC_MAIN_STATUS 1002 #define IDC_PLUGIN_DEFAULT 1003 #define IDD_DIRECTORIES 1004 #define IDC_ROMBROWSER_DIR_LIST 1006 #define IDC_ADD_BROWSER_DIR 1007 #define IDC_REMOVE_BROWSER_DIR 1008 #define IDC_REMOVE_BROWSER_ALL 1009 #define IDC_ROMS_DIRECTORIES 1010 #define IDC_RECURSION 1011 #define IDC_GUI_TOOLBAR 1012 #define IDC_GUI_STATUSBAR 1013 #define ID_POPUP_ROM_SETTING 2000 #define IDD_ROM_SETTING_DIALOG 2001 #define IDC_OK 2003 #define IDC_CANCEL 2004 #define IDC_ROM_CRC1 2006 #define IDC_ROM_CRC2 2007 #define IDC_ROM_HEADER_INFO_TEXT 2008 #define IDC_ROM_FULLPATH_TEXT 2009 #define IDC_ROM_FULLPATH 2010 #define IDC_ROM_GOODNAME_TEXT 2011 #define IDC_ROM_GOODNAME 2012 #define IDC_ROM_INTERNAL_NAME_TEXT 2013 #define IDC_ROM_INTERNAL_NAME 2014 #define IDC_ROM_CRC1_TEXT 2015 #define IDC_ROM_CRC2_TEXT 2016 #define IDC_ROM_COUNTRY_TEXT 2017 #define IDC_ROM_COUNTRY 2018 #define IDC_INI_COMMENTS_TEXT 2019 #define IDC_INI_COMMENTS 2020 #define IDC_ROM_MD5_TEXT 2021 #define IDC_ROM_MD5 2022 #define IDC_MD5_CALCULATE 2023 #define IDC_MD5_PROGRESS 2024 #define IDC_ROM_SIZE_TEXT 2025 #define IDC_ROM_SIZE 2026 #define IDC_ROM_INICODE_TEXT 2027 #define IDC_ROM_INICODE 2028 #define IDC_MD5_PROGRESS_BAR 2029 #define ID_START_ROM 2050 #define ID_START_ROM_ENTER 2051 #define ID_AUDIT_ROMS 2100 #define IDD_AUDIT_ROMS_DIALOG 2101 #define IDC_STOP 2102 #define IDC_CLOSE 2103 #define IDC_START 2104 #define IDC_TOTAL_ROMS_TEXT 2105 #define IDC_TOTAL_ROMS 2106 #define IDC_CURRENT_ROM_TEXT 2107 #define IDC_CURRENT_ROM 2108 #define ID_GENERATE_ROM_INFO 2200 #define IDD_MESSAGES 2250 #define IDC_SHOWFPS 2251 #define IDC_SHOWVIS 2252 #define IDC_ALERTBADROM 2253 #define IDC_ALERTHACKEDROM 2254 #define IDC_MESSAGES 2255 #define IDC_ALERTSAVESERRORS 2256 #define IDC_LIMITFPS 2257 #define IDC_FPSTITLE 2258 #define ID_FPSTRACKBAR 2259 #define IDC_SPEEDMODIFIER 2260 #define IDC_SPEEDMODIFIER_VALUE 2261 #define IDC_INCREASE_MODIFIER 2262 #define IDC_DECREASE_MODIFIER 2263 #define IDC_RESET_MODIFIER 2264 #define STATE_SAVE 3000 #define STATE_SAVEAS 3001 #define STATE_RESTORE 3002 #define STATE_LOAD 3003 #define ID_CURRENTSAVE_DEFAULT 3004 #define ID_CURRENTSAVE_1 3005 #define ID_CURRENTSAVE_2 3006 #define ID_CURRENTSAVE_3 3007 #define ID_CURRENTSAVE_4 3008 #define ID_CURRENTSAVE_5 3009 #define ID_CURRENTSAVE_6 3010 #define ID_CURRENTSAVE_7 3011 #define ID_CURRENTSAVE_8 3012 #define ID_CURRENTSAVE_9 3013 #define ID_SAVE_1 3014 #define ID_SAVE_2 3015 #define ID_SAVE_3 3016 #define ID_SAVE_4 3017 #define ID_SAVE_5 3018 #define ID_SAVE_6 3019 #define ID_SAVE_7 3020 #define ID_SAVE_8 3021 #define ID_SAVE_9 3022 #define ID_LOAD_1 3023 #define ID_LOAD_2 3024 #define ID_LOAD_3 3025 #define ID_LOAD_4 3026 #define ID_LOAD_5 3027 #define ID_LOAD_6 3028 #define ID_LOAD_7 3029 #define ID_LOAD_8 3030 #define ID_LOAD_9 3031 #define IDC_INIFILE 3100 #define IDC_INI_COMPRESSED 3101 #define IDC_DEFAULT_PLUGINS_CHECK 4000 #define IDC_DEFAULT_SCREENSHOTS_CHECK 4001 #define IDC_DEFAULT_SAVES_CHECK 4002 #define IDC_DEFAULT_PLUGINS_DIR 4003 #define IDC_DEFAULT_SAVES_DIR 4004 #define IDC_DEFAULT_SCREENSHOTS_DIR 4005 #define IDC_PLUGINS_GROUP 4012 #define IDC_SAVES_GROUP 4013 #define IDC_SCREENSHOTS_GROUP 4014 #define IDC_PLUGINS_DIR 4015 #define IDC_CHOOSE_PLUGINS_DIR 4016 #define IDC_SCREENSHOTS_DIR 4017 #define IDC_CHOOSE_SCREENSHOTS_DIR 4018 #define IDI_GFX 4101 #define IDI_INPUT 4103 #define IDI_SOUND 4104 #define IDB_RSP 4112 #define IDB_SOUND 4113 #define IDB_CONTROL 4114 #define IDB_DISPLAY 4115 #define ROM_POPUP_MENU 4116 #define IDC_CURRENT_ROM_PROGRESS 5001 #define IDC_TOTAL_ROMS_PROGRESS 5002 #define IDC_SAVES_DIR 5004 #define IDC_IDC_ROM_MD5 5011 #define IDC_CHOOSE_SAVES_DIR 5014 #define GENERATE_BITMAP 5015 #define IDD_ADVANCED_OPTIONS 5501 #define IDC_STARTFULLSCREEN 5502 #define IDC_PAUSENOTACTIVE 5503 #define IDC_ROMBROWSERCOLUMNS 5504 #define IDC_COLUMN_GOODNAME 5505 #define IDC_COLUMN_INTERNALNAME 5506 #define IDC_COLUMN_COUNTRY 5507 #define IDC_COLUMN_SIZE 5508 #define IDC_COLUMN_FILENAME 5509 #define IDC_COLUMN_MD5 5510 #define IDC_COLUMN_COMMENTS 5511 #define IDC_PLUGIN_OVERWRITE 5512 #define IDC_COMMON 5513 #define IDC_COMPATIBILITY 5514 #define IDC_NO_AUDIO_DELAY 5515 #define IDC_NO_COMPILED_JUMP 5516 #define IDC_AUTOINCSAVESLOT 5517 #define IDD_HOTKEY_CONFIG 5518 #define ID_RECENTROMS_RESET 6000 #define ID_RECENTROMS_FREEZE 6001 #define ID_RECENTROMS_FIRST 6002 //reserved till 6020 #define ID_MENU_LUASCRIPT_NEW 6020 #define ID_MENU_LUASCRIPT_CLOSEALL 6021 #define ID_TRACELOG 6022 #define IDC_HOTKEYS_FLOWGROUP 6101 #define IDC_HOT_SCREENSHOT 6103 #define IDC_HOT_PAUSE 6104 #define IDC_HOT_FASTFORWARD 6105 #define IDC_HOT_SPEEDDOWN 6106 #define IDC_HOT_FRAMEADVANCE 6107 #define IDC_HOT_SPEEDUP 6108 #define IDC_HOT_READONLY 6109 #define IDC_HOT_PLAY 6110 #define IDC_HOT_PLAYSTOP 6111 #define IDC_HOT_RECORD 6112 #define IDC_HOT_RECORDSTOP 6113 #define IDC_HOTKEYS_SAVEGROUP2 6124 #define IDC_CSAVE 6138 #define IDC_CLOAD 6139 #define IDC_1SEL 6140 #define IDC_1SAVE 6141 #define IDC_1LOAD 6142 #define IDC_2SEL 6143 #define IDC_2SAVE 6144 #define IDC_2LOAD 6145 #define IDC_3SEL 6155 #define IDC_3SAVE 6156 #define IDC_3LOAD 6157 #define IDC_4SEL 6158 #define IDC_4SAVE 6159 #define IDC_4LOAD 6160 #define IDC_5SEL 6161 #define IDC_5SAVE 6162 #define IDC_5LOAD 6163 #define IDC_6SEL 6164 #define IDC_6SAVE 6165 #define IDC_6LOAD 6166 #define IDC_7SEL 6167 #define IDC_7SAVE 6168 #define IDC_7LOAD 6169 #define IDC_8SEL 6170 #define IDC_8SAVE 6171 #define IDC_8LOAD 6172 #define IDC_9SEL 6173 #define IDC_9SAVE 6174 #define IDC_9LOAD 6175 #define IDD_LANG_INFO 7000 #define IDC_PAUSE_EMULATION_FOCUS 7002 #define IDC_FULLSCREEN_ON_LOADING 7003 #define IDC_START_EMU_ON_LOADING 7004 #define IDC_LANG_AUTHOR 7019 #define IDC_LANG_VERSION 7020 #define IDC_LANG_DATE 7021 #define IDC_LANG_AUTHOR_TEXT 7022 #define IDC_LANG_VERSION_TEXT 7023 #define IDC_LANG_DATE_TEXT 7024 #define IDC_CRC1CRC2 7029 #define IDC_ROM_PLUGINS 8000 #define IDC_SAVE_PROFILE 8001 #define ID_LOG_WINDOW 9000 #define ID_KAILLERA 9100 #define ID_BENCHMARK 9101 #define IDD_MOVIE_PLAYBACK_DIALOG 9000 #define IDD_MOVIE_RECORD_DIALOG 9001 #define ID_START_RECORD 9200 #define ID_STOP_RECORD 9202 #define ID_START_PLAYBACK 9203 #define ID_STOP_PLAYBACK 9204 #define ID_START_CAPTURE 9205 #define ID_END_CAPTURE 9206 #define IDC_CONTROLLER1 9247 #define IDC_CONTROLLER2 9248 #define IDC_CONTROLLER3 9249 #define IDC_GFXPLUGIN2 9250 #define IDC_SOUNDPLUGIN2 9251 #define IDC_INPUTPLUGIN2 9252 #define IDC_CONTROLLER5 9253 #define IDC_CONTROLLER6 9254 #define IDC_CONTROLLER7 9255 #define IDC_CONTROLLER4 9223 #define IDC_RSPPLUGIN2 9224 #define IDC_CONTROLLER8 9225 #define IDC_MOVIE_BROWSE 9300 #define IDC_MOVIE_REFRESH 9301 #define IDC_MOVIE_READONLY 9302 #define IDC_FROMSNAPSHOT_LABEL 9303 #define IDC_ROM_INFO_TEXT 9409 #define IDC_ROM_HEADER_INFO_TEXT2 9410 #define IDC_ROM_INFO_TEXT2 9411 #define IDC_MOVIE_AUTHOR_TEXT 9415 #define IDC_MOVIE_DESCRIPTION_TEXT 9416 #define IDC_ROM_INTERNAL_NAME_TEXT2 9419 #define IDC_ROM_COUNTRY_TEXT2 9420 #define IDC_MOVIE_VIDEO_TEXT 9421 #define IDC_MOVIE_SOUND_TEXT 9422 #define IDC_MOVIE_INPUT_TEXT 9423 #define IDC_MOVIE_RSP_TEXT 9424 #define IDC_ROM_CRC_TEXT 9425 #define IDC_ROM_CRC 9426 #define IDC_MOVIE_CONTROLLER1_TEXT 9427 #define IDC_MOVIE_CONTROLLER2_TEXT 9428 #define IDC_MOVIE_CONTROLLER3_TEXT 9429 #define IDC_INI_MOVIEFILE_TEXT 9430 #define IDC_INI_AUTHOR 9431 #define IDC_INI_DESCRIPTION 9432 #define IDC_INI_MOVIEFILE 9433 #define IDC_MOVIE_CONTROLLER4_TEXT 9434 #define IDC_ROM_INTERNAL_NAME2 9435 #define IDC_ROM_COUNTRY2 9436 #define IDC_ROM_CRC_TEXT2 9437 #define IDC_ROM_CRC3 9438 #define IDC_MOVIE_VIDEO_TEXT2 9439 #define IDC_MOVIE_SOUND_TEXT2 9440 #define IDC_MOVIE_INPUT_TEXT2 9441 #define IDC_MOVIE_RSP_TEXT2 9442 #define IDC_MOVIE_CONTROLLER1_TEXT2 9443 #define IDC_MOVIE_CONTROLLER2_TEXT2 9444 #define IDC_MOVIE_CONTROLLER3_TEXT2 9445 #define IDC_MOVIE_CONTROLLER4_TEXT2 9446 #define IDC_MOVIE_LENGTH_TEXT 9447 #define IDC_MOVIE_FRAMES_TEXT 9448 #define IDC_MOVIE_RERECORDS_TEXT 9449 #define IDC_MOVIE_LENGTH 9450 #define IDC_MOVIE_FRAMES 9451 #define IDC_MOVIE_RERECORDS 9452 #define IDC_MOVIE_SNAPSHOT_TEXT 9453 #define IDC_FROMSNAPSHOT_TEXT 9453 #define IDC_MOVIE_CONTROLLERS 9501 #define IDC_ROM_PLUGINS2 9502 #define IDC_MOVIE_CONTROLLERS2 9503 #define IDC_STARTSFROM_LABEL 9504 #define IDC_FROMSNAPSHOT_RADIO 9505 #define IDC_FROMSTART_RADIO 9506 #define IDC_PAUSEAT_LABEL 9507 #define IDC_PAUSEAT_FIELD 9508 //Lua #define IDC_TEXTBOX_LUASCRIPTPATH 9509 #define IDC_TEXTBOX_LUACONSOLE 9510 #define IDC_BUTTON_LUASTATE 9511 #define IDC_BUTTON_LUAEDIT 9512 #define IDC_BUTTON_LUABROWSE 9513 #define IDC_BUTTON_LUACLEAR 9514 #define IDC_BUTTON_LUASTOP 9515 #define IDC_TEXTBOX_LUAPROMPT 9520 #define ID_LUA_RELOAD 9600 #define ID_EMULATOR_EXIT 40001 #define ID_LANG_INFO_MENU 40002 #define AC_PAUSE 40004 #define EMU_RESET 40007 #define IDC_ROMLIST 12347 #define ID_LANG_ENGLISH 10000 #define MUPEN_VERSION "Mupen 64 0.5"
15,114
C
.c
366
38.953552
52
0.580559
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,476
disasm.c
anta0_mupen64-rr-lua-/main/disasm.c
#include "disasm.h" #include <stdarg.h> typedef enum INSTSETOP_t { INSTSETOP_UNDEF, INSTSETOP_MAIN, INSTSETOP_SPECIAL, INSTSETOP_REGIMM, INSTSETOP_COP0, INSTSETOP_COP1, //COP2はundefined扱いで } INSTSETOP; static INSTSETOP OpInstructionSet[1<<6] = { //bit31-26 INSTSETOP_SPECIAL, INSTSETOP_REGIMM, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_COP0, INSTSETOP_COP1, INSTSETOP_UNDEF, INSTSETOP_UNDEF, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_UNDEF, INSTSETOP_UNDEF, INSTSETOP_UNDEF, INSTSETOP_UNDEF, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_UNDEF, INSTSETOP_UNDEF, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_UNDEF, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_UNDEF, INSTSETOP_UNDEF, INSTSETOP_MAIN, INSTSETOP_MAIN, INSTSETOP_UNDEF, INSTSETOP_MAIN, }; static INST MainInstruction[1<<6] = { INST_UNDEF, INST_UNDEF, INST_J, INST_JAL, INST_BEQ, INST_BNE, INST_BLEZ, INST_BGTZ, INST_ADDI, INST_ADDIU, INST_SLTI, INST_SLTIU, INST_ANDI, INST_ORI, INST_XORI, INST_LUI, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_BEQL, INST_BNEL, INST_BLEZL, INST_BGTZL, INST_DADDI, INST_DADDIU, INST_LDL, INST_LDR, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_LB, INST_LH, INST_LWL, INST_LW, INST_LBU, INST_LHU, INST_LWR, INST_LWU, INST_SB, INST_SH, INST_SWL, INST_SW, INST_SDL, INST_SDR, INST_SWR, INST_CACHE, INST_LL, INST_LWC1, INST_UNDEF, INST_UNDEF, INST_LLD, INST_LDC1, INST_UNDEF, INST_LD, INST_SC, INST_SWC1, INST_UNDEF, INST_UNDEF, INST_SCD, INST_SDC1, INST_UNDEF, INST_SD, }; static INST SpecialInstruction[1<<6] = { INST_SLL, INST_UNDEF, INST_SRL, INST_SRA, INST_SLLV, INST_UNDEF, INST_SRLV, INST_SRAV, INST_JR, INST_JALR, INST_UNDEF, INST_UNDEF, INST_SYSCALL, INST_BREAK, INST_UNDEF, INST_SYNC, INST_MFHI, INST_MTHI, INST_MFLO, INST_MTLO, INST_DSLLV, INST_UNDEF, INST_DSRLV, INST_DSRAV, INST_MULT, INST_MULTU, INST_DIV, INST_DIVU, INST_DMULT, INST_DMULTU, INST_DDIV, INST_DDIVU, INST_ADD, INST_ADDU, INST_SUB, INST_SUBU, INST_AND, INST_OR, INST_XOR, INST_NOR, INST_UNDEF, INST_UNDEF, INST_SLT, INST_SLTU, INST_DADD, INST_DADDU, INST_DSUB, INST_DSUBU, INST_TGE, INST_TGEU, INST_TLT, INST_TLTU, INST_TEQ, INST_UNDEF, INST_TNE, INST_UNDEF, INST_DSLL, INST_UNDEF, INST_DSRL, INST_DSRA, INST_DSLL32, INST_UNDEF, INST_DSRL32, INST_DSRA32, }; static INST RegimmInstruction[1<<5] = { INST_BLTZ, INST_BGEZ, INST_BLTZL, INST_BGEZL, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_TGEI, INST_TGEIU, INST_TLTI, INST_TLTIU, INST_TEQI, INST_UNDEF, INST_TNEI, INST_UNDEF, INST_BLTZAL, INST_BGEZAL, INST_BLTZALL, INST_BGEZALL, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, }; typedef enum INSTSETCOP0_t{ INSTSETCOP0_UNDEF, INSTSETCOP0_MAIN, INSTSETCOP0_BC0, INSTSETCOP0_TLB, } INSTSETCOP0; static INSTSETCOP0 Cop0InstructionSet[1<<5] = { INSTSETCOP0_MAIN, INSTSETCOP0_MAIN, INSTSETCOP0_MAIN, INSTSETCOP0_UNDEF, INSTSETCOP0_MAIN, INSTSETCOP0_MAIN, INSTSETCOP0_MAIN, INSTSETCOP0_UNDEF, INSTSETCOP0_BC0, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_TLB, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, INSTSETCOP0_UNDEF, }; static INST Cop0Instruction[1<<5] = { //CFC0,CTC0が不明だからUNDEFにしとく(上のはMAINのまま) INST_MFC0, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_MTC0, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, }; static INST Bc0Instruction[1<<2] = { //全部不明だからUNDEFにしとく INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF }; static INST TlbInstruction[1<<6] = { INST_UNDEF, INST_TLBR, INST_TLBWI, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_TLBWR, INST_UNDEF, INST_TLBP, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_ERET, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, }; typedef enum INSTSETCOP1_t{ INSTSETCOP1_UNDEF, INSTSETCOP1_MAIN, INSTSETCOP1_BC1, INSTSETCOP1_S, INSTSETCOP1_D, INSTSETCOP1_W, INSTSETCOP1_L, } INSTSETCOP1; static INSTSETCOP1 Cop1InstructionSet[1<<5] = { INSTSETCOP1_MAIN, INSTSETCOP1_MAIN, INSTSETCOP1_MAIN, INSTSETCOP1_UNDEF, INSTSETCOP1_MAIN, INSTSETCOP1_MAIN, INSTSETCOP1_MAIN, INSTSETCOP1_UNDEF, INSTSETCOP1_BC1, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_S, INSTSETCOP1_D, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_W, INSTSETCOP1_L, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, INSTSETCOP1_UNDEF, }; static INST Cop1Instruction[1<<5] = { INST_MFC1, INST_DMFC1, INST_CFC1, INST_UNDEF, INST_MTC1, INST_DMTC1, INST_CTC1, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, }; static INST Bc1Instruction[1<<2] = { INST_BC1F, INST_BC1T, INST_BC1FL, INST_BC1TL, }; static INST SInstruction[1<<6] = { INST_ADD_S, INST_SUB_S, INST_MUL_S, INST_DIV_S, INST_SQRT_S, INST_ABS_S, INST_MOV_S, INST_NEG_S, INST_ROUND_L_S, INST_TRUNC_L_S, INST_CEIL_L_S, INST_FLOOR_L_S, INST_ROUND_W_S, INST_TRUNC_W_S, INST_CEIL_W_S, INST_FLOOR_W_S, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_CVT_D_S, INST_UNDEF, INST_UNDEF, INST_CVT_W_S, INST_CVT_L_S, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_C_F_S, INST_C_UN_S, INST_C_EQ_S, INST_C_UEQ_S, INST_C_OLT_S, INST_C_ULT_S, INST_C_OLE_S, INST_C_ULE_S, INST_C_SF_S, INST_C_NGLE_S, INST_C_SEQ_S, INST_C_NGL_S, INST_C_LT_S, INST_C_NGE_S, INST_C_LE_S, INST_C_NGT_S, }; static INST DInstruction[1<<6] = { INST_ADD_D, INST_SUB_D, INST_MUL_D, INST_DIV_D, INST_SQRT_D, INST_ABS_D, INST_MOV_D, INST_NEG_D, INST_ROUND_L_D, INST_TRUNC_L_D, INST_CEIL_L_D, INST_FLOOR_L_D, INST_ROUND_W_D, INST_TRUNC_W_D, INST_CEIL_W_D, INST_FLOOR_W_D, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_CVT_S_D, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_CVT_W_D, INST_CVT_L_D, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_C_F_D, INST_C_UN_D, INST_C_EQ_D, INST_C_UEQ_D, INST_C_OLT_D, INST_C_ULT_D, INST_C_OLE_D, INST_C_ULE_D, INST_C_SF_D, INST_C_NGLE_D, INST_C_SEQ_D, INST_C_NGL_D, INST_C_LT_D, INST_C_NGE_D, INST_C_LE_D, INST_C_NGT_D, }; static INST WInstruction[1<<6] = { INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_CVT_S_W, INST_CVT_D_W, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, }; static INST LInstruction[1<<6] = { INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_CVT_S_L, INST_CVT_D_L, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, INST_UNDEF, }; INST GetInstruction(r4300word w) { switch(OpInstructionSet[w >> 26]) { case INSTSETOP_UNDEF: return INST_UNDEF; case INSTSETOP_MAIN: return MainInstruction[w >> 26]; case INSTSETOP_SPECIAL: return SpecialInstruction[w & 0x3F]; case INSTSETOP_REGIMM: return RegimmInstruction[w>>16 & 0x1F]; case INSTSETOP_COP0: switch(Cop0InstructionSet[w>>21 & 0x1F]) { case INSTSETCOP0_UNDEF: return INST_UNDEF; case INSTSETCOP0_MAIN: return Cop0Instruction[w>>21 & 0x1F]; case INSTSETCOP0_BC0: return Bc0Instruction[w >> 16 & 0x3]; case INSTSETCOP0_TLB: return TlbInstruction[w & 0x3F]; } case INSTSETOP_COP1: switch(Cop1InstructionSet[w>>21 & 0x1F]) { case INSTSETCOP1_UNDEF: return INST_UNDEF; case INSTSETCOP1_MAIN: return Cop1Instruction[w>>21 & 0x1F]; case INSTSETCOP1_BC1: return Bc1Instruction[w>>16 & 0x3]; case INSTSETCOP1_S: return SInstruction[w & 0x3F]; case INSTSETCOP1_D: return DInstruction[w & 0x3F]; case INSTSETCOP1_W: return WInstruction[w & 0x3F]; case INSTSETCOP1_L: return LInstruction[w & 0x3F]; } } return INST_UNDEF; } const INSTFMT InstFormat[INST_COUNT] = { INSTF_NONE, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRR, INSTF_ADDRW, INSTF_ADDRW, INSTF_ADDRW, INSTF_ADDRW, INSTF_ADDRW, INSTF_ADDRW, INSTF_ADDRW, INSTF_ADDRW, INSTF_ADDRW, INSTF_ADDRW, INSTF_NONE, INSTF_R3, INSTF_ISIGN, INSTF_ISIGN, INSTF_R3, INSTF_R3, INSTF_IUNSIGN, INSTF_R3, INSTF_ISIGN, INSTF_ISIGN, INSTF_R3, INSTF_R2, INSTF_R2, INSTF_R2, INSTF_R2, INSTF_R2, INSTF_R2, INSTF_SA, INSTF_SA, INSTF_R3, INSTF_SA, INSTF_SA, INSTF_R3, INSTF_SA, INSTF_SA, INSTF_R3, INSTF_R3, INSTF_R3, INSTF_LUI, INSTF_R1, INSTF_R1, INSTF_R1, INSTF_R1, INSTF_R2, INSTF_R2, INSTF_R3, INSTF_R3, INSTF_IUNSIGN, INSTF_SA, INSTF_R3, INSTF_R3, INSTF_ISIGN, INSTF_IUNSIGN, INSTF_R3, INSTF_SA, INSTF_R3, INSTF_SA, INSTF_R3, INSTF_R3, INSTF_R3, INSTF_R3, INSTF_IUNSIGN, INSTF_2BRANCH, INSTF_2BRANCH, INSTF_1BRANCH, INSTF_1BRANCH, INSTF_1BRANCH, INSTF_1BRANCH, INSTF_1BRANCH, INSTF_1BRANCH, INSTF_1BRANCH, INSTF_1BRANCH, INSTF_1BRANCH, INSTF_1BRANCH, INSTF_1BRANCH, INSTF_1BRANCH, INSTF_2BRANCH, INSTF_2BRANCH, INSTF_J, INSTF_J, INSTF_R2, INSTF_JR, INSTF_NONE, INSTF_NONE, INSTF_LFR, INSTF_LFR, INSTF_LFW, INSTF_LFW, //とりあえず、トラップ系はよくわからんので INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_MFC0, INSTF_MTC0, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_NONE, INSTF_MFC1, INSTF_MFC1, INSTF_MTC1, INSTF_MTC1, INSTF_MTC1, INSTF_MTC1, INSTF_0BRANCH, INSTF_0BRANCH, //BC1Fとかよくわかってない INSTF_0BRANCH, INSTF_0BRANCH, INSTF_R3F, INSTF_R3F, INSTF_R3F, INSTF_R3F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_R3F, INSTF_R3F, INSTF_R3F, INSTF_R3F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_C, INSTF_R2F, INSTF_R2F, INSTF_R2F, INSTF_R2F, }; const char * const OpecodeName[INST_COUNT] = { "undef", "lb", "lbu", "ld", "ldl", "ldr", "lh", "lhu", "ll", "lld", "lw", "lwl", "lwr", "lwu", "sb", "sc", "scd", "sd", "sdl", "sdr", "sh", "sw", "swl", "swr", "sync", "add", "addi", "addiu", "addu", "and", "andi", "dadd", "daddi", "daddiu", "daddu", "ddiv", "ddivu", "div", "divu", "dmult", "dmultu", "dsll", "dsll32", "dsllv", "dsra", "dsra32", "dsrav", "dsrl", "dsrl32", "dsrlv", "dsub", "dsubu", "lui", "mfhi", "mflo", "mthi", "mtlo", "mult", "multu", "nor", "or", "ori", "sll", "sllv", "slt", "slti", "sltiu", "sltu", "sra", "srav", "srl", "srlv", "sub", "subu", "xor", "xori", "beq", "beql", "bgez", "bgezal", "bgezall", "bgezl", "bgtz", "bgtzl", "blez", "blezl", "bltz", "bltzal", "bltzall", "bltzl", "bne", "bnel", "j", "jal", "jalr", "jr", "break", "syscall", "lwc1", "ldc1", "swc1", "sdc1", "teq", "teqi", "tge", "tgei", "tgeiu", "tgeu", "tlt", "tlti", "tltiu", "tltu", "tne", "tnei", "cache", "eret", "mfc0", "mtc0", "tlbp", "tlbr", "tlbwi", "tlbwr", "mfc1", "dmfc1", "cfc1", "mtc1", "dmtc1", "ctc1", "bc1f", "bc1t", "bc1fl", "bc1tl", "add.s", "sub.s", "mul.s", "div.s", "sqrt.s", "abs.s", "mov.s", "neg.s", "round.l.s", "trunc.l.s", "ceil.l.s", "floor.l.s", "round.w.s", "trunc.w.s", "ceil.w.s", "floor.w.s", "cvt.d.s", "cvt.w.s", "cvt.l.s", "c.f.s", "c.un.s", "c.eq.s", "c.ueq.s", "c.olt.s", "c.ult.s", "c.ole.s", "c.ule.s", "c.sf.s", "c.ngle.s", "c.seq.s", "c.ngl.s", "c.lt.s", "c.nge.s", "c.le.s", "c.ngt.s", "add.d", "sub.d", "mul.d", "div.d", "sqrt.d", "abs.d", "mov.d", "neg.d", "round.l.d", "trunc.l.d", "ceil.l.d", "floor.l.d", "round.w.d", "trunc.w.d", "ceil.w.d", "floor.w.d", "cvt.s.d", "cvt.w.d", "cvt.l.d", "c.f.d", "c.un.d", "c.eq.d", "c.ueq.d", "c.olt.d", "c.ult.d", "c.ole.d", "c.ule.d", "c.sf.d", "c.ngle.d", "c.seq.d", "c.ngl.d", "c.lt.d", "c.nge.d", "c.le.d", "c.ngt.d", "cvt.s.w", "cvt.d.w", "cvt.s.l", "cvt.d.l", }; #define BITS(n,length) (w>>(n) & ((1<<(length))-1)) static void noneType(r4300word w, INSTOPERAND *f) { } static void iType(r4300word w, INSTOPERAND *f) { f->i.rs = BITS(21, 5); f->i.rt = BITS(16, 5); f->i.immediate = BITS(0,16); } static void jType(r4300word w, INSTOPERAND *f) { f->j.inst_index = BITS(0,26); } static void rType(r4300word w, INSTOPERAND *f) { f->r.rs = BITS(21,5); f->r.rt = BITS(16,5); f->r.rd = BITS(11,5); f->r.sa = BITS(6,5); } static void lfType(r4300word w, INSTOPERAND *f) { f->lf.base = BITS(21,5); f->lf.ft = BITS(16,5); f->lf.offset = BITS(0,16); } static void cfType(r4300word w, INSTOPERAND *f) { f->cf.ft = BITS(16,5); f->cf.fs = BITS(11,5); f->cf.fd = BITS(6,5); } const INSTFTYPE InstFormatType[INSTF_COUNT] = { INSTFTYPE_NONE, INSTFTYPE_I, INSTFTYPE_I, INSTFTYPE_I, INSTFTYPE_I, INSTFTYPE_I, INSTFTYPE_I, INSTFTYPE_I, INSTFTYPE_I, INSTFTYPE_I, INSTFTYPE_J, INSTFTYPE_R, INSTFTYPE_R, INSTFTYPE_R, INSTFTYPE_R, INSTFTYPE_R, INSTFTYPE_R, INSTFTYPE_R, INSTFTYPE_R, INSTFTYPE_LF, INSTFTYPE_LF, INSTFTYPE_CF, INSTFTYPE_CF, INSTFTYPE_CF }; void(*InstFormatTypeFunc[INSTFTYPE_COUNT])(r4300word, INSTOPERAND*) = { noneType, iType, jType, rType, lfType, cfType }; void DecodeInstruction(r4300word w, INSTDECODE *d) { INST inst = GetInstruction(w); INSTFMT format; INSTFTYPE type; if(inst==INST_UNDEF) { inst = GetInstruction(w); } format = InstFormat[inst]; type = InstFormatType[format]; InstFormatTypeFunc[type](w, &d->operand); d->inst = inst; d->format = format; d->type = type; } //max-length:9 const char *GetOpecodeString(INSTDECODE *d) { return OpecodeName[d->inst]; } const char * const CPURegisterName[32] = { "r0","at","v0","v1","a0","a1","a2","a3", "t0","t1","t2","t3","t4","t5","t6","t7", "s0","s1","s2","s3","s4","s5","s6","s7", "t8","t9","k0","k1","gp","sp","s8","ra", }; const char * const COP0RegisterName[32] = { "index","random","entrylo0","entrylo1", "context","pagemask","wired","reserved07", "badvaddr","count","entryhi","compare", "status","cause","epc","previd", "config","lladdr","watchlo","watchhi", "xcontext","reserved21","reserved22","reserved23", "reserved24","reserved25","perr","cacheerr", "taglo","taghi","errorepc","reserved1f" }; static char *sfmt(char *b, const char *f, ...) { #define HEX4() q[0] = x[n>>12&0xF];\ q[1] = x[n>>8&0xF];\ q[2] = x[n>>4&0xF];\ q[3] = x[n&0xF];\ q+=4; va_list v; const char *p; char *q = b; const char * const x = "0123456789abcdef"; va_start(v, f); for(p = f; *p; p ++) { char c = *p; switch(c) { case 'r':{ const char *l; for(l = CPURegisterName[va_arg(v, int)]; *l; l++){ *(q++) = *l; } break; } case 'c':{ const char *l; for(l = COP0RegisterName[va_arg(v, int)]; *l; l++){ *(q++) = *l; } break; } case 'f':{ int f = va_arg(v, int); q[0]='f'; //decimal q[1]=x[f/10]; q[2]=x[f%10]; q+=3; break; } case 'u':{ r4300half n = va_arg(v,r4300half); HEX4(); break; } case 's':{ r4300half n = va_arg(v,r4300half); if(n < 0x8000) { *q = '+'; }else { *q = '+'; // n = -n; } q++; HEX4(); break; } case 'p':{ r4300word m = va_arg(v,r4300word); r4300half n = m>>16; HEX4(); n = m&0xFFFF; HEX4(); break; } case 'a':{ r4300byte n = va_arg(v,r4300byte); q[0]=x[n>>4]; q[1]=x[n&0xF]; q+=2; break; } default: *(q++) = c; break; } } va_end(v); *q = '\0'; return q; #undef HEX4 } //max-length: 16+1 char *GetOperandString(char *buf, INSTDECODE *d, r4300word pc) { #define BRANCH (pc+4+((r4300wordsigned)(r4300halfsigned)o->i.immediate << 2)) INSTOPERAND *o = &d->operand; //max-length: r:2, c:10, f:3, s:5, u:4, p:8, a:2, *:1 switch(d->format) { default: case INSTF_NONE: return sfmt(buf, ""); //max-length: 0 case INSTF_LUI: return sfmt(buf, "r, s", o->i.rt, o->i.immediate); //9 case INSTF_ISIGN: return sfmt(buf, "r, r, s", o->i.rt, o->i.rs, o->i.immediate); //13 case INSTF_IUNSIGN: return sfmt(buf, "r, r, u", o->i.rt, o->i.rs, o->i.immediate); //12 case INSTF_0BRANCH: return sfmt(buf, "p", BRANCH); //8 case INSTF_1BRANCH: return sfmt(buf, "r, p", o->i.rs, BRANCH); //12 case INSTF_2BRANCH: return sfmt(buf, "r, r, p", o->i.rs, o->i.rt, BRANCH); //16 case INSTF_ADDRR: case INSTF_ADDRW: return sfmt(buf, "r, s(r)", o->i.rt, o->i.immediate, o->i.rs); //13 case INSTF_JR: return sfmt(buf, "r", o->i.rs); case INSTF_J: return sfmt(buf, "p", (pc & 0xF0000000)|(o->j.inst_index<<2)); //8 case INSTF_MTC0: case INSTF_MFC0: return sfmt(buf, "r, c", o->r.rt, o->r.rd); //14 case INSTF_MTC1: case INSTF_MFC1: return sfmt(buf, "r, f", o->r.rt, o->r.rd); //7 case INSTF_R1: return sfmt(buf, "r", o->r.rd); //2 case INSTF_R2: return sfmt(buf, "r, r", o->r.rs, o->r.rt); //6 case INSTF_R3: return sfmt(buf, "r, r, r", o->r.rd, o->r.rs, o->r.rt); //10 case INSTF_SA: return sfmt(buf, "r, r, a", o->r.rd, o->r.rt, o->r.sa); //10 case INSTF_LFR: case INSTF_LFW: return sfmt(buf, "f, s(r)", o->i.rt, o->i.immediate, o->i.rs); //14 case INSTF_R2F: return sfmt(buf, "f, f", o->cf.fd, o->cf.fs); //8 case INSTF_C: return sfmt(buf, "f, f", o->cf.fs, o->cf.ft); //8 case INSTF_R3F: return sfmt(buf, "f, f, f", o->cf.fd, o->cf.fs, o->cf.ft); //13 } #undef BRANCH } //max-size:27 = 9(opecode)+1(space)+16(operand)+1(NUL) char *DisassembleInstruction(char *buf, r4300word w, r4300word pc) { INSTDECODE decode; const char *p; DecodeInstruction(w, &decode); for(p = GetOpecodeString(&decode); *p; p ++) { *(buf++) = *p; } *(buf++) = ' '; return GetOperandString(buf, &decode, pc); }
22,014
C
.c
535
37.68785
127
0.671245
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,356,518
GUI_LogWindow.c
anta0_mupen64-rr-lua-/main/win/GUI_LogWindow.c
/*************************************************************************** GUI_LogWindow.c - description ------------------- copyright : (C) 2003 by ShadowPrince email : [email protected] ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <windows.h> #include <stdio.h> #include "GUI_LogWindow.h" #include "DebugView.h" #include "main_win.h" int extLogger ; ///////////////// External Logger DLL ////////////////////////////////////////// int CreateExtLogger() { HMODULE DVHandle; char TempStr[MAX_PATH]; sprintf(TempStr,"%s%s",AppPath,"debugview.dll") ; DVHandle = LoadLibrary(TempStr); if (DVHandle) { FileLog = (void (__cdecl *)(char *, ...)) GetProcAddress(DVHandle, "FileLog"); OpenDV = (HWND (__cdecl *)(HINSTANCE, int)) GetProcAddress(DVHandle, "OpenDV"); DVMsg = (void (__cdecl *)(int, char *, ...)) GetProcAddress(DVHandle, "DVMsg"); CloseDV = (void (__cdecl *)(void)) GetProcAddress(DVHandle, "CloseDV"); ShowDV = (void (__cdecl *)(int)) GetProcAddress(DVHandle, "ShowDV"); SetUserIcon = (void (__cdecl *)(int, HICON)) GetProcAddress(DVHandle, "SetUserIcon"); SetUserIconName = (void (__cdecl *)(int, char*)) GetProcAddress(DVHandle, "SetUserIconName"); DVClear = (void (__cdecl*)( void )) GetProcAddress(DVHandle, "DVClear");; OpenDV( DVHandle, DV_SHOW ); // ShowDV( DV_HIDE ) ; return 1; } else { return 0; } } /* Show / Hide Management */ void ShowLogWindow() { if (extLogger) { if (ShowDV) ShowDV( DV_SHOW ) ; } } void HideLogWindow() { if (extLogger) { if (ShowDV) ShowDV( DV_HIDE ) ; } } void ShowHideLogWindow() { if (extLogger) { if (ShowDV) ShowDV( DV_AUTO ) ; } } /* Add Text to Log */ void ShowInfo(char *Str, ...) { int i; char Msg[800]; va_list ap; va_start( ap, Str ); _vsnprintf( Msg, sizeof(Msg), Str, ap ); va_end( ap ); for ( i = 0 ; i < strlen( Msg ) ; i++ ) { if ( Msg[ i ] == '\n' ) Msg[ i ] = ' '; //carrier retirn if ( Msg[ i ] == '\r' ) Msg[ i ] = ' '; if ( Msg[ i ] == '\t' ) Msg[ i ] = ' '; //tab } #if 0 OutputDebugString(Msg); OutputDebugString("\n"); #else if (DVMsg) DVMsg( DV_INFO, Msg) ; #endif } void ShowWarning(char *Str, ...) { int i; char Msg[800]; va_list ap; va_start( ap, Str ); _vsnprintf( Msg, sizeof(Msg), Str, ap ); va_end( ap ); for ( i = 0 ; i < strlen( Msg ) ; i++ ) { if ( Msg[ i ] == '\n' ) Msg[ i ] = ' '; //carrier retirn if ( Msg[ i ] == '\r' ) Msg[ i ] = ' '; if ( Msg[ i ] == '\t' ) Msg[ i ] = ' '; //tab } if (DVMsg) DVMsg( DV_WARNING, Msg) ; } void ShowError( char *Str, ...) { int i; char Msg[800]; va_list ap; va_start( ap, Str ); _vsnprintf( Msg, sizeof(Msg), Str, ap ); va_end( ap ); for ( i = 0 ; i < strlen( Msg ) ; i++ ) { if ( Msg[ i ] == '\n' ) Msg[ i ] = ' '; //carrier retirn if ( Msg[ i ] == '\r' ) Msg[ i ] = ' '; if ( Msg[ i ] == '\t' ) Msg[ i ] = ' '; //tab } if (DVMsg) DVMsg( DV_ERROR, Msg) ; } /* Clear Text in Log */ void ClearLogWindow() { if (extLogger) { if (DVClear) DVClear(); } } int GUI_CreateLogWindow( HWND hwnd ) { extLogger = CreateExtLogger() ; return 0; } void CloseLogWindow() { if (extLogger) { if (CloseDV) CloseDV() ; } }
4,442
C
.c
128
28.0625
102
0.462008
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,520
Config.c
anta0_mupen64-rr-lua-/main/win/Config.c
/*************************************************************************** config.c - description ------------------- copyright : (C) 2003 by ShadowPrince email : [email protected] ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /* #if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0500) #undef _WIN32_WINNT #define _WIN32_WINNT 0x0500 #endif */ #include <windows.h> #include <winuser.h> #include <stdio.h> #include "config.h" #include "main_win.h" #include "rombrowser.h" #include "commandline.h" #include "../../winproject/resource.h" #define CfgFileName "mupen64.cfg" extern int no_audio_delay; extern int no_compiled_jump; ////////////////////// Service functions and structures //////////////////////// CONFIG Config; // is this the best way to handle this? int *autoinc_save_slot = &Config.AutoIncSaveSlot; char *CfgFilePath() { static char *cfgpath = NULL; if (cfgpath == NULL) { cfgpath = (char*)malloc(strlen(AppPath)+1+strlen(CfgFileName)); strcpy(cfgpath, AppPath); strcat(cfgpath, CfgFileName); } return cfgpath; } void WriteCfgString (char *Section,char *Key,char *Value) { WritePrivateProfileString( Section, Key, Value, CfgFilePath()); } void WriteCfgInt (char *Section,char *Key,int Value) { static char TempStr[20]; sprintf( TempStr, "%d", Value); WriteCfgString( Section, Key, TempStr ); } void ReadCfgString (char *Section,char *Key,char *DefaultValue,char *retValue) { GetPrivateProfileString( Section, Key, DefaultValue, retValue, MAX_PATH, CfgFilePath()); } int ReadCfgInt (char *Section,char *Key,int DefaultValue) { return GetPrivateProfileInt( Section, Key, DefaultValue, CfgFilePath()); } //////////////////////////// Load and Save Config ////////////////////////////// void LoadRecentRoms() { int i; char tempStr[50]; Config.RecentRomsFreeze = ReadCfgInt( "Recent Roms", "Freeze", 0 ) ; for ( i=0; i < MAX_RECENT_ROMS; i++) { sprintf( tempStr, "RecentRom%d", i) ; ReadCfgString( "Recent Roms", tempStr, "", Config.RecentRoms[i]) ; // FILE* f = fopen(tempStr, "wb"); // fputs(Config.RecentRoms[i], f); // fclose(f); } } void ReadHotkeyConfig(int n, char *name, int cmd, int def) { HOTKEY *h; char t[128]; h = &Config.hotkey[n]; sprintf(t, "%s Key", name); h->key = ReadCfgInt("Hotkeys",t,def&0xFF); sprintf(t, "%s Shift", name); h->shift = ReadCfgInt("Hotkeys",t,def&0x100?1:0); sprintf(t, "%s Ctrl", name); h->ctrl = ReadCfgInt("Hotkeys",t,def&0x200?1:0); sprintf(t, "%s Alt", name); h->alt = ReadCfgInt("Hotkeys",t,def&0x400?1:0); h->command = cmd; } void WriteHotkeyConfig(int n, char *name) { HOTKEY *h; char t[128]; h = &Config.hotkey[n]; sprintf(t, "%s Key", name); WriteCfgInt("Hotkeys", t, h->key); sprintf(t, "%s Shift", name); WriteCfgInt("Hotkeys", t, h->shift); sprintf(t, "%s Ctrl", name); WriteCfgInt("Hotkeys", t, h->ctrl); sprintf(t, "%s Alt", name); WriteCfgInt("Hotkeys", t, h->alt); } void LoadConfig() { LoadRecentRoms(); // Language ReadCfgString( "Language", "Default", "English" , Config.DefaultLanguage); //Window position and size Config.WindowWidth = ReadCfgInt("Window","Width",640); Config.WindowHeight = ReadCfgInt("Window","Height",480); Config.WindowPosX = ReadCfgInt("Window","X",(GetSystemMetrics( SM_CXSCREEN ) - Config.WindowWidth) / 2); Config.WindowPosY = ReadCfgInt("Window","Y",(GetSystemMetrics( SM_CYSCREEN ) - Config.WindowHeight) / 2); //General Vars Config.showFPS = ReadCfgInt("General","Show FPS",1); Config.showVIS = ReadCfgInt("General","Show VIS",1); Config.alertBAD = ReadCfgInt("General","Alert Bad roms",1); Config.alertHACK = ReadCfgInt("General","Alert Hacked roms",1); Config.savesERRORS = ReadCfgInt("General","Alert Saves errors",1); Config.limitFps = ReadCfgInt("General","Alert Saves errors",1); Config.compressedIni = ReadCfgInt("General","Compressed Ini",1); Config.UseFPSmodifier = ReadCfgInt("General","Use Fps Modifier",1); Config.FPSmodifier = ReadCfgInt("General","Fps Modifier",100); Config.guiDynacore = ReadCfgInt("CPU","Core",1); //Advanced vars Config.StartFullScreen = ReadCfgInt("Advanced","Start Full Screen",0); Config.PauseWhenNotActive = ReadCfgInt("Advanced","Pause when not active",1); Config.OverwritePluginSettings = ReadCfgInt("Advanced","Overwrite Plugins Settings ",0); Config.GuiToolbar = ReadCfgInt( "Advanced", "Use Toolbar", 0); Config.GuiStatusbar = ReadCfgInt( "Advanced", "Use Statusbar", 1); Config.AutoIncSaveSlot = ReadCfgInt( "Advanced", "Auto Increment Save Slot", 0); //Compatibility Settings no_audio_delay = ReadCfgInt("Compatibility","No Audio Delay", 0); no_compiled_jump = ReadCfgInt("Compatibility","No Compiled Jump", 0); //RomBrowser Columns Config.Column_GoodName = ReadCfgInt("Rom Browser Columns","Good Name", 1); Config.Column_InternalName = ReadCfgInt("Rom Browser Columns","Internal Name", 0); Config.Column_Country = ReadCfgInt("Rom Browser Columns","Country", 1); Config.Column_Size = ReadCfgInt("Rom Browser Columns","Size", 1); Config.Column_Comments = ReadCfgInt("Rom Browser Columns","Comments", 1); Config.Column_FileName = ReadCfgInt("Rom Browser Columns","File Name", 0); Config.Column_MD5 = ReadCfgInt("Rom Browser Columns","MD5", 0); // Directories Config.DefaultPluginsDir = ReadCfgInt("Directories","Default Plugins Directory",1); Config.DefaultSavesDir = ReadCfgInt("Directories","Default Saves Directory",1); Config.DefaultScreenshotsDir = ReadCfgInt("Directories","Default Screenshots Directory",1); sprintf(Config.PluginsDir,"%sPlugin\\",AppPath); ReadCfgString("Directories","Plugins Directory",Config.PluginsDir, Config.PluginsDir); sprintf(Config.SavesDir,"%sSave\\",AppPath); ReadCfgString("Directories","Saves Directory",Config.SavesDir, Config.SavesDir); sprintf(Config.ScreenshotsDir,"%sScreenShots\\",AppPath); ReadCfgString("Directories","Screenshots Directory",Config.ScreenshotsDir, Config.ScreenshotsDir); // Rom Browser Config.RomBrowserSortColumn = ReadCfgInt( "Rom Browser", "Sort Column" , 0); Config.RomBrowserRecursion = ReadCfgInt("Rom Browser","Recursion",0); ReadCfgString("Rom Browser","Sort Method","ASC",Config.RomBrowserSortMethod); // Load A Whole Whackton Of Hotkeys: ReadHotkeyConfig(0, "Fast Forward", 0, VK_TAB); // handled specially ReadHotkeyConfig(1, "Speed Up", IDC_INCREASE_MODIFIER, /*VK_OEM_PLUS*/0xBB); ReadHotkeyConfig(2, "Slow Down", IDC_DECREASE_MODIFIER, /*VK_OEM_MINUS*/0xBD); ReadHotkeyConfig(3, "Frame Advance", EMU_FRAMEADVANCE, VK_OEM_5); ReadHotkeyConfig(4, "Pause Resume", EMU_PAUSE, VK_PAUSE); ReadHotkeyConfig(5, "ReadOnly", EMU_VCRTOGGLEREADONLY, '8'|0x100); ReadHotkeyConfig(6, "Play", ID_START_PLAYBACK, 'P'|0x300); ReadHotkeyConfig(7, "PlayStop", ID_STOP_PLAYBACK, 'S'|0x300); ReadHotkeyConfig(8, "Record", ID_START_RECORD, 'R'|0x300); ReadHotkeyConfig(9, "RecordStop", ID_STOP_RECORD, 'S'|0x300); ReadHotkeyConfig(10,"Screenshot", GENERATE_BITMAP, VK_F12); ReadHotkeyConfig(11,"Save Current", STATE_SAVE, VK_F5|0x200); ReadHotkeyConfig(12,"Load Current", STATE_RESTORE, VK_F7|0x200); // Save/Load Hotkeys { int i; char str [128]; for(i = 1 ; i <= 9 ; i++) { sprintf(str, "Save %d", i); ReadHotkeyConfig(12+i, str, (ID_SAVE_1-1) + i, ((VK_F1-1)+i)|0x100); } for(i = 1 ; i <= 9 ; i++) { sprintf(str, "Load %d", i); ReadHotkeyConfig(21+i, str, (ID_LOAD_1-1) + i, (VK_F1-1)+i); } for(i = 1 ; i <= 9 ; i++) { sprintf(str, "Select %d", i); ReadHotkeyConfig(30+i, str, (ID_CURRENTSAVE_1-1) + i, '0'+i); } } //Lua //ダイアログに追加するの面倒くさい ReadCfgString("Lua", "Script Path", "", Config.LuaScriptPath); ReadHotkeyConfig(40, "Lua Script Reload", ID_LUA_RELOAD, VK_F3|0x200); ReadHotkeyConfig(41, "Lua Script CloseAll", ID_MENU_LUASCRIPT_CLOSEALL, VK_F4|0x200); } ///////////////////////////////////////////////////////////////////////////////// void saveWindowSettings() { RECT rcMain; GetWindowRect(mainHWND, &rcMain); Config.WindowPosX=rcMain.left; Config.WindowPosY=rcMain.top; Config.WindowWidth = rcMain.right - rcMain.left; Config.WindowHeight = rcMain.bottom - rcMain.top; WriteCfgInt("Window","Width",Config.WindowWidth); WriteCfgInt("Window","Height",Config.WindowHeight); WriteCfgInt("Window","X",Config.WindowPosX); WriteCfgInt("Window","Y",Config.WindowPosY); } void saveBrowserSettings() { int Column,ColWidth,index; index=0; for (Column = 0; Column < ROM_COLUMN_FIELDS; Column ++) { if ( isFieldInBrowser( Column) ) { ColWidth = ListView_GetColumnWidth(hRomList,index); WriteCfgInt("Rom Browser",getFieldName(Column),ColWidth); index++; } } WriteCfgInt( "Rom Browser", "Sort Column", Config.RomBrowserSortColumn); WriteCfgInt( "Rom Browser", "Recursion", Config.RomBrowserRecursion); WriteCfgString("Rom Browser","Sort Method", Config.RomBrowserSortMethod); } void SaveRecentRoms() { int i; char tempStr[50]; WriteCfgInt( "Recent Roms", "Freeze", Config.RecentRomsFreeze) ; for ( i=0; i < MAX_RECENT_ROMS; i++) { sprintf( tempStr, "RecentRom%d", i) ; WriteCfgString( "Recent Roms", tempStr, Config.RecentRoms[i]) ; } } void SaveConfig() { saveWindowSettings(); if (!cmdlineNoGui) { saveBrowserSettings(); SaveRecentRoms(); } //Language WriteCfgString( "Language", "Default", Config.DefaultLanguage); //General Vars WriteCfgInt( "General", "Show FPS", Config.showFPS); WriteCfgInt( "General", "Show VIS", Config.showVIS); WriteCfgInt( "General", "Alert Bad roms", Config.alertBAD); WriteCfgInt( "General", "Alert Hacked roms", Config.alertHACK); WriteCfgInt( "General", "Alert Saves errors", Config.savesERRORS); WriteCfgInt( "General", "Alert Saves errors", Config.limitFps); WriteCfgInt( "General", "Compressed Ini", Config.compressedIni); WriteCfgInt( "General", "Fps Modifier", Config.FPSmodifier); WriteCfgInt( "General", "Use Fps Modifier", Config.UseFPSmodifier); //Advanced Vars WriteCfgInt( "Advanced", "Start Full Screen", Config.StartFullScreen); WriteCfgInt( "Advanced", "Pause when not active", Config.PauseWhenNotActive); WriteCfgInt( "Advanced", "Overwrite Plugins Settings", Config.OverwritePluginSettings); WriteCfgInt( "Advanced", "Use Toolbar", Config.GuiToolbar); WriteCfgInt( "Advanced", "Use Statusbar", Config.GuiStatusbar); WriteCfgInt( "Advanced", "Auto Increment Save Slot", Config.AutoIncSaveSlot); WriteCfgInt( "CPU", "Core", Config.guiDynacore); //Compatibility Settings WriteCfgInt( "Compatibility", "No Audio Delay", no_audio_delay); WriteCfgInt( "Compatibility", "No Compiled Jump", no_compiled_jump); //Rom Browser columns WriteCfgInt("Rom Browser Columns","Good Name", Config.Column_GoodName); WriteCfgInt("Rom Browser Columns","Internal Name", Config.Column_InternalName); WriteCfgInt("Rom Browser Columns","Country", Config.Column_Country); WriteCfgInt("Rom Browser Columns","Size", Config.Column_Size); WriteCfgInt("Rom Browser Columns","Comments", Config.Column_Comments); WriteCfgInt("Rom Browser Columns","File Name", Config.Column_FileName); WriteCfgInt("Rom Browser Columns","MD5", Config.Column_MD5); // Directories WriteCfgInt( "Directories", "Default Plugins Directory", Config.DefaultPluginsDir); WriteCfgString("Directories","Plugins Directory",Config.PluginsDir); WriteCfgInt( "Directories","Default Saves Directory", Config.DefaultSavesDir); WriteCfgString("Directories","Saves Directory",Config.SavesDir); WriteCfgInt( "Directories", "Default Screenshots Directory", Config.DefaultScreenshotsDir); WriteCfgString("Directories","Screenshots Directory",Config.ScreenshotsDir); // Load A Whole Whackton Of Hotkeys: WriteHotkeyConfig(0, "Fast Forward"); WriteHotkeyConfig(1, "Speed Up"); WriteHotkeyConfig(2, "Slow Down"); WriteHotkeyConfig(3, "Frame Advance"); WriteHotkeyConfig(4, "Pause Resume"); WriteHotkeyConfig(5, "ReadOnly"); WriteHotkeyConfig(6, "Play"); WriteHotkeyConfig(7, "PlayStop"); WriteHotkeyConfig(8, "Record"); WriteHotkeyConfig(9, "RecordStop"); WriteHotkeyConfig(10,"Screenshot"); WriteHotkeyConfig(11,"Save Current"); WriteHotkeyConfig(12,"Load Current"); // Save/Load Hotkeys { int i; char str [128]; for(i = 1 ; i <= 9 ; i++) { sprintf(str, "Save %d", i); WriteHotkeyConfig(12+i,str); } for(i = 1 ; i <= 9 ; i++) { sprintf(str, "Load %d", i); WriteHotkeyConfig(21+i,str); } for(i = 1 ; i <= 9 ; i++) { sprintf(str, "Select %d", i); WriteHotkeyConfig(30+i,str); } } //Lua WriteCfgString("Lua", "Script Path", Config.LuaScriptPath); WriteHotkeyConfig(40, "Lua Script Reload"); WriteHotkeyConfig(41, "Lua Script CloseAll"); }
14,474
C
.c
323
38.96904
110
0.643357
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,356,525
translation.c
anta0_mupen64-rr-lua-/main/win/translation.c
/*************************************************************************** translation.c - description ------------------- copyright : (C) 2003 by ShadowPrince ([email protected]) modifications : linker ([email protected]) ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <windows.h> #include <stdlib.h> #include <stdio.h> #ifndef _MSC_VER #include <dirent.h> #endif #ifndef _WIN32_IE #define _WIN32_IE 0x0500 #endif #include <commctrl.h> #include "translation.h" #include "../../winproject/resource.h" #include "main_win.h" static int LastLang = -1; typedef struct _languages languages; struct _languages { char *file_name; char *language_name; languages *next; }; static languages *lang_list = NULL, *current_lang = NULL; void insert_lang( languages *p, char *file_name, char *language_name) { while (p->next) { p=p->next; } p->next = (languages*)malloc(sizeof(languages)); p->next->file_name = (char*)malloc(strlen(file_name)+1); strcpy( p->next->file_name, file_name); p->next->language_name = (char*)malloc(strlen(language_name)+7); strcpy( p->next->language_name, language_name); p->next->next=NULL; return; } void rewind_lang() { current_lang = lang_list; } void search_languages() { HANDLE hFind; WIN32_FIND_DATA FindFileData; char cwd[MAX_PATH]; char name[MAX_PATH]; char String[800]; lang_list = (languages*)malloc(sizeof(languages)); lang_list->next = NULL; sprintf(cwd, "%slang",AppPath); sprintf(String, "%s\\*.lng", cwd); hFind = FindFirstFile(String, &FindFileData); if (hFind == INVALID_HANDLE_VALUE) { return; } do { if (strcmp(FindFileData.cFileName, ".") != 0 && strcmp(FindFileData.cFileName, "..") != 0 && !(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { char *filePart; GetFullPathName(FindFileData.cFileName, _MAX_PATH, name, &filePart); memset(String,0,sizeof(String)); GetPrivateProfileSectionNames(String, sizeof(String), name); if (String) { insert_lang( lang_list, name, String ); } } } while(FindNextFile(hFind, &FindFileData)); FindClose(hFind); } void SetCurrentLangByName(char *language_name) { languages *p; p = lang_list->next; while(p) { if ( strcmp(p->language_name, language_name)==0) { current_lang = p; return; } p=p->next; } } void SelectLang(HWND hWnd, int LangMenuID) { char String[800]; HMENU hMenu = GetMenu(hWnd); MENUITEMINFO menuinfo; menuinfo.cbSize = sizeof(MENUITEMINFO); menuinfo.fMask = MIIM_TYPE; menuinfo.fType = MFT_STRING; menuinfo.dwTypeData = String; menuinfo.cch = sizeof(String); GetMenuItemInfo(hMenu,LangMenuID,FALSE,&menuinfo); sprintf(Config.DefaultLanguage,String); //WritePrivateProfileString("Default","Language",String,LngFilePath()); if (LastLang != -1) { CheckMenuItem( hMenu, LastLang, MF_BYCOMMAND | MFS_UNCHECKED ); } LastLang = LangMenuID; CheckMenuItem( hMenu, LastLang, MF_BYCOMMAND | MFS_CHECKED ); SetCurrentLangByName( Config.DefaultLanguage); } void SetupLanguages( HWND hWnd ) { char String[800]; HMENU hMenu = GetMenu(hWnd), hSubMenu; MENUITEMINFO menuinfo; int count; count = 1; languages *p; search_languages(); p = lang_list->next; hSubMenu = GetSubMenu(hMenu,0); hSubMenu = GetSubMenu(hSubMenu,6); menuinfo.cbSize = sizeof(MENUITEMINFO); menuinfo.fMask = MIIM_TYPE|MIIM_ID; menuinfo.fType = MFT_STRING; menuinfo.fState = MFS_ENABLED; menuinfo.dwTypeData = String; menuinfo.cch = sizeof(hSubMenu); while ( p ) { if (strcmp(p->language_name,"English") == 0) { if (strcmp(Config.DefaultLanguage, "English") == 0) { CheckMenuItem(hSubMenu, ID_LANG_ENGLISH, MF_BYCOMMAND | MFS_CHECKED ); LastLang = ID_LANG_ENGLISH; current_lang = p; } } else { menuinfo.dwTypeData = p->language_name; menuinfo.cch = strlen(p->language_name) + 1; menuinfo.wID = ID_LANG_ENGLISH + count; InsertMenuItem(hSubMenu, count++, TRUE, &menuinfo); if (strcmp(Config.DefaultLanguage, p->language_name) == 0) { CheckMenuItem(hSubMenu, menuinfo.wID, MF_BYCOMMAND | MFS_CHECKED ); LastLang = menuinfo.wID; current_lang = p; } } p = p->next ; } SetCurrentLangByName( Config.DefaultLanguage); } void freeLanguages() { languages *p,*temp; p=lang_list; while(p) { temp = p->next; free( p); p=temp; } } void Translate(char* GuiWord,char* Ret) { TranslateDefault( GuiWord, GuiWord, Ret); } void TranslateDefault(char* GuiWord,char *Default,char* Ret) { if (current_lang) { GetPrivateProfileString(current_lang->language_name,GuiWord,Default,Ret,200,current_lang->file_name); } else { sprintf( Ret, GuiWord) ; } } void SetItemTranslatedString(HWND hwnd,int ElementID,char* Str) { char String[800]; Translate(Str,String); SetDlgItemText( hwnd, ElementID, String ); } void SetItemTranslatedStringDefault(HWND hwnd,int ElementID,char* Str,char*Def) { char String[800]; TranslateDefault(Str,Def,String); SetDlgItemText( hwnd, ElementID, String ); } void SetStatusTranslatedString(HWND hStatus,int section,char* Str) { char String[800]; Translate(Str,String); if (section == 0) strcpy( statusmsg, String ); SendMessage( hStatus, SB_SETTEXT, section, (LPARAM)String ); } void SetMenuTranslatedString(HMENU hMenu,int elementID,char* Str,char* Acc) { char String[800]; MENUITEMINFO menuinfo; Translate(Str,String); if (strcmp(Acc,"")) sprintf(String, "%s\t%s", String, Acc); memset(&menuinfo, 0, sizeof(MENUITEMINFO)); menuinfo.cbSize = sizeof(MENUITEMINFO); menuinfo.fMask = MIIM_TYPE; menuinfo.fType = MFT_STRING; menuinfo.dwTypeData = String; menuinfo.cch = sizeof(String); SetMenuItemInfo(hMenu,elementID,TRUE,&menuinfo); } void SetMenuAccelerator(HMENU hMenu,int elementID,char* Acc) { char String[800]; MENUITEMINFO menuinfo; GetMenuString(hMenu,elementID,String,800,MF_BYPOSITION); char* tab = strrchr(String, '\t'); if(tab) *tab = '\0'; if(strcmp(Acc,"")) sprintf(String, "%s\t%s", String, Acc); memset(&menuinfo, 0, sizeof(MENUITEMINFO)); menuinfo.cbSize = sizeof(MENUITEMINFO); menuinfo.fMask = MIIM_TYPE; menuinfo.fType = MFT_STRING; menuinfo.dwTypeData = String; menuinfo.cch = sizeof(String); SetMenuItemInfo(hMenu,elementID,TRUE,&menuinfo); } static void SetHotkeyMenuAccelerators(HOTKEY* hotkey, HMENU hmenu, int menuItemID) { char buf [64]; extern void hotkeyToString(HOTKEY* hotkey, char* buf); hotkeyToString(hotkey, buf); if(hmenu && menuItemID >= 0) { if(strcmp(buf, "(nothing)")) SetMenuAccelerator(hmenu,menuItemID,buf); else SetMenuAccelerator(hmenu,menuItemID,""); } } void TranslateMenu(HMENU hMenu,HWND mainHWND) { HMENU submenu,subsubmenu; //Main menu SetMenuTranslatedString(hMenu,0,"File",""); SetMenuTranslatedString(hMenu,1,"Run",""); SetMenuTranslatedString(hMenu,2,"Options",""); SetMenuTranslatedString(hMenu,3,"Utilities",""); SetMenuTranslatedString(hMenu,4,"Help",""); //File menu submenu = GetSubMenu(hMenu,0) ; SetMenuTranslatedString(submenu,0,"Load ROM...","Ctrl O"); SetMenuTranslatedString(submenu,1,"Close ROM","Ctrl F4"); SetMenuTranslatedString(submenu,2,"Reset ROM","Ctrl R"); SetMenuTranslatedString(submenu,3,"Refresh ROM List","Ctrl Alt R"); SetMenuTranslatedString(submenu,5,"Recent ROMs",""); subsubmenu = GetSubMenu(submenu,5) ; SetMenuTranslatedString(subsubmenu,0,"Reset",""); SetMenuTranslatedString(subsubmenu,1,"Freeze",""); SetMenuTranslatedString(submenu,7,"Language",""); SetMenuTranslatedString(submenu,8,"Language Information...",""); SetMenuTranslatedString(submenu,10,"Exit","Alt F4"); //Run menu submenu = GetSubMenu(hMenu,1); //SetMenuTranslatedString(submenu,0,"Reset","F1"); SetMenuTranslatedString(submenu,0,"Pause",""); SetMenuTranslatedString(submenu,1,"Frame Advance",""); SetMenuTranslatedString(submenu,2,"Generate Bitmap",""); SetMenuTranslatedString(submenu,4,"Save State",""); SetMenuTranslatedString(submenu,5,"Save As...","Ctrl A"); SetMenuTranslatedString(submenu,6,"Load State",""); SetMenuTranslatedString(submenu,7,"Load As...","Ctrl L"); SetMenuTranslatedString(submenu,9,"Current Save State",""); //Options menu submenu = GetSubMenu(hMenu,2); SetMenuTranslatedString(submenu,0,"Full Screen","Alt Enter"); SetMenuTranslatedString(submenu,2,"Video Settings...",""); SetMenuTranslatedString(submenu,3,"Input Settings...",""); SetMenuTranslatedString(submenu,4,"Audio Settings...",""); SetMenuTranslatedString(submenu,5,"RSP Settings...",""); SetMenuTranslatedString(submenu,7 ,"Show Toolbar","Alt T"); SetMenuTranslatedString(submenu,8 ,"Show Statusbar","Alt S"); SetMenuTranslatedString(submenu,10 ,"Settings...","Ctrl S"); //Utility menu submenu = GetSubMenu(hMenu,3); SetMenuTranslatedString(submenu,0,"ROM Properties...","Ctrl P"); SetMenuTranslatedString(submenu,2,"Audit ROMs...",""); //SetMenuTranslatedString(submenu,3,"Benchmark...",""); SetMenuTranslatedString(submenu,3,"Generate ROM Info...",""); SetMenuTranslatedString(submenu,4,"Show Log Window",""); //SetMenuTranslatedString(submenu,5,"Kaillera...",""); SetMenuTranslatedString(submenu,6,"Movie",""); subsubmenu = GetSubMenu(submenu,6); SetMenuTranslatedString(subsubmenu,0,"Start Movie Recording...",""); SetMenuTranslatedString(subsubmenu,1,"Stop Movie Recording",""); SetMenuTranslatedString(subsubmenu,3,"Start Movie Playback...",""); SetMenuTranslatedString(subsubmenu,4,"Stop Movie Playback",""); SetMenuTranslatedString(subsubmenu,5,"Toggle Read-Only",""); SetMenuTranslatedString(subsubmenu,7,"Start AVI Capture...",""); SetMenuTranslatedString(subsubmenu,8,"Stop AVI Capture",""); //Help menu submenu = GetSubMenu(hMenu,4); SetMenuTranslatedString(submenu,0,"Contents...",""); SetMenuTranslatedString(submenu,1,"Whats new...",""); SetMenuTranslatedString(submenu,3,"About...",""); DrawMenuBar(mainHWND); SetHotkeyMenuAccelerators(&Config.hotkey[3], GetSubMenu(GetMenu(mainHWND),1), 1); SetHotkeyMenuAccelerators(&Config.hotkey[4], GetSubMenu(GetMenu(mainHWND),1), 0); SetHotkeyMenuAccelerators(&Config.hotkey[5], GetSubMenu(GetSubMenu(GetMenu(mainHWND),3),6), 5); SetHotkeyMenuAccelerators(&Config.hotkey[6], GetSubMenu(GetSubMenu(GetMenu(mainHWND),3),6), 3); SetHotkeyMenuAccelerators(&Config.hotkey[7], GetSubMenu(GetSubMenu(GetMenu(mainHWND),3),6), 4); SetHotkeyMenuAccelerators(&Config.hotkey[8], GetSubMenu(GetSubMenu(GetMenu(mainHWND),3),6), 0); SetHotkeyMenuAccelerators(&Config.hotkey[9], GetSubMenu(GetSubMenu(GetMenu(mainHWND),3),6), 1); SetHotkeyMenuAccelerators(&Config.hotkey[10], GetSubMenu(GetMenu(mainHWND),1), 2); SetHotkeyMenuAccelerators(&Config.hotkey[11], GetSubMenu(GetMenu(mainHWND),1), 4); SetHotkeyMenuAccelerators(&Config.hotkey[12], GetSubMenu(GetMenu(mainHWND),1), 6); SetHotkeyMenuAccelerators(&Config.hotkey[31], GetSubMenu(GetSubMenu(GetMenu(mainHWND),1),9), 0); SetHotkeyMenuAccelerators(&Config.hotkey[32], GetSubMenu(GetSubMenu(GetMenu(mainHWND),1),9), 1); SetHotkeyMenuAccelerators(&Config.hotkey[33], GetSubMenu(GetSubMenu(GetMenu(mainHWND),1),9), 2); SetHotkeyMenuAccelerators(&Config.hotkey[34], GetSubMenu(GetSubMenu(GetMenu(mainHWND),1),9), 3); SetHotkeyMenuAccelerators(&Config.hotkey[35], GetSubMenu(GetSubMenu(GetMenu(mainHWND),1),9), 4); SetHotkeyMenuAccelerators(&Config.hotkey[36], GetSubMenu(GetSubMenu(GetMenu(mainHWND),1),9), 5); SetHotkeyMenuAccelerators(&Config.hotkey[37], GetSubMenu(GetSubMenu(GetMenu(mainHWND),1),9), 6); SetHotkeyMenuAccelerators(&Config.hotkey[38], GetSubMenu(GetSubMenu(GetMenu(mainHWND),1),9), 7); SetHotkeyMenuAccelerators(&Config.hotkey[39], GetSubMenu(GetSubMenu(GetMenu(mainHWND),1),9), 8); } void TranslateConfigDialog(HWND hwnd) { SetItemTranslatedString(hwnd,IDC_GFXPLUGIN,"Video Plugin"); SetItemTranslatedString(hwnd,IDGFXCONFIG,"Config"); SetItemTranslatedString(hwnd,IDGFXTEST,"Test"); SetItemTranslatedString(hwnd,IDGFXABOUT,"Plugin About"); SetItemTranslatedString(hwnd,IDC_INPUTPLUGIN,"Input Plugin"); SetItemTranslatedString(hwnd,IDINPUTCONFIG,"Config"); SetItemTranslatedString(hwnd,IDINPUTTEST,"Test"); SetItemTranslatedString(hwnd,IDINPUTABOUT,"Plugin About"); SetItemTranslatedString(hwnd,IDC_SOUNDPLUGIN,"Sound Plugin"); SetItemTranslatedString(hwnd,IDSOUNDCONFIG,"Config"); SetItemTranslatedString(hwnd,IDSOUNDTEST,"Test"); SetItemTranslatedString(hwnd,IDSOUNDABOUT,"Plugin About"); SetItemTranslatedString(hwnd,IDC_RSPPLUGIN,"RSP Plugin"); SetItemTranslatedString(hwnd,IDRSPCONFIG,"Config"); SetItemTranslatedString(hwnd,IDRSPTEST,"Test"); SetItemTranslatedString(hwnd,IDRSPABOUT,"Plugin About"); } void TranslateDirectoriesConfig(HWND hwnd) { SetItemTranslatedString(hwnd,IDC_ROMS_DIRECTORIES,"ROMs Directories"); SetItemTranslatedString(hwnd,IDC_RECURSION,"Use directory recursion"); SetItemTranslatedString(hwnd,IDC_ADD_BROWSER_DIR,"Add"); SetItemTranslatedString(hwnd,IDC_REMOVE_BROWSER_DIR,"Remove"); SetItemTranslatedString(hwnd,IDC_REMOVE_BROWSER_ALL,"Remove All"); SetItemTranslatedString(hwnd,IDC_PLUGINS_GROUP,"Plugins Directory"); //SetItemTranslatedString(hwnd,IDC_DEFAULT_PLUGINS_CHECK,"Default Plugins Check"); SetItemTranslatedString(hwnd,IDC_CHOOSE_PLUGINS_DIR, "Choose" ); SetItemTranslatedString(hwnd,IDC_SAVES_GROUP,"Saves Directory"); //SetItemTranslatedString(hwnd,IDC_DEFAULT_SAVES_CHECK,"Default Saves Check"); SetItemTranslatedString(hwnd,IDC_CHOOSE_SAVES_DIR,"Choose"); SetItemTranslatedString(hwnd,IDC_SCREENSHOTS_GROUP,"Screenshots Directory"); //SetItemTranslatedString(hwnd,IDC_DEFAULT_SCREENSHOTS_CHECK,"Default Screenshots Check"); SetItemTranslatedString(hwnd,IDC_CHOOSE_SCREENSHOTS_DIR,"Choose"); } void TranslateGeneralDialog(HWND hwnd) { SetItemTranslatedString(hwnd,IDC_MESSAGES,"Alerts"); SetItemTranslatedString(hwnd,IDC_ALERTBADROM,"Alert Bad ROM"); SetItemTranslatedString(hwnd,IDC_ALERTHACKEDROM,"Alert Hacked ROM"); SetItemTranslatedString(hwnd,IDC_ALERTSAVESERRORS,"Alert Saves errors"); SetItemTranslatedString(hwnd,IDC_FPSTITLE,"Fps / VIs"); SetItemTranslatedString(hwnd,IDC_LIMITFPS,"Limit fps (auto)"); SetItemTranslatedString(hwnd,IDC_SPEEDMODIFIER,"Use Speed Modifier"); SetItemTranslatedString(hwnd,IDC_SHOWFPS,"Show FPS"); SetItemTranslatedString(hwnd,IDC_SHOWVIS,"Show VIs"); SetItemTranslatedString(hwnd,IDC_INTERP,"Interpreter"); SetItemTranslatedString(hwnd,IDC_RECOMP,"Dynamic Recompiler"); SetItemTranslatedString(hwnd,IDC_PURE_INTERP,"Pure Interpreter"); SetItemTranslatedString(hwnd,IDC_CPUCORE,"CPU Core"); SetItemTranslatedString(hwnd,IDC_INIFILE,"Ini File"); SetItemTranslatedString(hwnd,IDC_INI_COMPRESSED,"Use compressed file"); } void TranslateRomInfoDialog(HWND hwnd) { char tmp[200]; SetItemTranslatedStringDefault(hwnd,IDC_ROM_HEADER_INFO_TEXT,"RP ROM Information","ROM Information:"); SetItemTranslatedStringDefault(hwnd,IDC_ROM_FULLPATH_TEXT,"RP File Location","File Location:"); SetItemTranslatedStringDefault(hwnd,IDC_ROM_GOODNAME_TEXT,"RP Good Name","Good Name:"); SetItemTranslatedStringDefault(hwnd,IDC_ROM_INTERNAL_NAME_TEXT,"RP Internal Name","Internal Name:"); SetItemTranslatedStringDefault(hwnd,IDC_ROM_SIZE_TEXT,"RP Size","Size:"); SetItemTranslatedStringDefault(hwnd,IDC_ROM_COUNTRY_TEXT,"RP Country","Country:"); SetItemTranslatedStringDefault(hwnd,IDC_ROM_INICODE_TEXT,"RP Ini Code","Ini Code:"); SetItemTranslatedStringDefault(hwnd,IDC_ROM_MD5_TEXT,"RP MD5 Checksum","MD5 Checksum:"); SetItemTranslatedStringDefault(hwnd,IDC_MD5_CALCULATE,"RP Calculate","Calculate"); SetItemTranslatedStringDefault(hwnd,IDC_ROM_PLUGINS,"RP Plugins","Plugins:"); SetItemTranslatedStringDefault(hwnd,IDC_GFXPLUGIN,"RP Video Plugin","Video Plugin:"); SetItemTranslatedStringDefault(hwnd,IDC_SOUNDPLUGIN,"RP Sound Plugin","Sound Plugin:"); SetItemTranslatedStringDefault(hwnd,IDC_INPUTPLUGIN,"RP Input Plugin","Input Plugin:"); SetItemTranslatedStringDefault(hwnd,IDC_RSPPLUGIN,"RP RSP Plugin","RSP Plugin:"); SetItemTranslatedStringDefault(hwnd,IDC_SAVE_PROFILE,"RP Save Plugins","Save Plugins"); SetItemTranslatedStringDefault(hwnd,IDC_INI_COMMENTS_TEXT,"RP Comments","Comments:"); SetItemTranslatedString(hwnd,IDC_OK,"Ok"); SetItemTranslatedString(hwnd,IDC_CANCEL,"Cancel"); TranslateDefault("ROM Properties","ROM Properties",tmp); SetWindowText(hwnd,tmp); } void TranslateRomBrowserMenu(HMENU hMenu) { SetMenuTranslatedString(hMenu,0,"Play Game","Enter"); SetMenuTranslatedString(hMenu,1,"ROM Properties...","Ctrl P"); SetMenuTranslatedString(hMenu,3,"Refresh ROM List","Ctrl Alt R"); } void TranslateAuditDialog(HWND hwnd) { char tmp[200]; SetItemTranslatedString(hwnd,IDC_TOTAL_ROMS_TEXT,"Audit Total ROMs"); SetItemTranslatedString(hwnd,IDC_CURRENT_ROM_TEXT,"Audit Current ROM"); SetItemTranslatedString(hwnd,IDC_ROM_FULLPATH_TEXT,"Audit File Location"); SetItemTranslatedString(hwnd,IDC_START,"Start"); SetItemTranslatedString(hwnd,IDC_STOP,"Stop"); SetItemTranslatedString(hwnd,IDC_CLOSE,"Close"); TranslateDefault("Audit ROMs","Audit ROMs",tmp); SetWindowText(hwnd,tmp); } void TranslateLangInfoDialog( HWND hwnd ) { char tmp[200]; SetItemTranslatedString(hwnd,IDC_LANG_AUTHOR_TEXT,"Translation Author TEXT"); SetItemTranslatedString(hwnd,IDC_LANG_VERSION_TEXT,"Version TEXT"); SetItemTranslatedString(hwnd,IDC_LANG_DATE_TEXT,"Creation Date TEXT"); SetItemTranslatedString(hwnd,IDC_LANG_AUTHOR,"Translation Author"); SetItemTranslatedString(hwnd,IDC_LANG_VERSION,"Version"); SetItemTranslatedString(hwnd,IDC_LANG_DATE,"Creation Date"); SetItemTranslatedString(hwnd,IDOK, "Ok"); TranslateDefault("Language Information Dialog","Language Information",tmp); SetWindowText(hwnd,tmp); } void TranslateAdvancedDialog(HWND hwnd) { SetItemTranslatedString(hwnd,IDC_COMMON,"Common Options"); SetItemTranslatedString(hwnd,IDC_STARTFULLSCREEN,"Start game in full screen"); SetItemTranslatedString(hwnd,IDC_PAUSENOTACTIVE,"Pause when not active"); SetItemTranslatedString(hwnd,IDC_PLUGIN_OVERWRITE,"Use global plugins settings"); SetItemTranslatedString(hwnd,IDC_GUI_TOOLBAR,"Show toolbar"); SetItemTranslatedString(hwnd,IDC_GUI_STATUSBAR,"Show statusbar"); SetItemTranslatedString(hwnd,IDC_COMPATIBILITY,"Compatibility Options"); SetItemTranslatedString(hwnd,IDC_NO_AUDIO_DELAY,"No audio delay"); SetItemTranslatedString(hwnd,IDC_NO_COMPILED_JUMP,"No compiled jump"); SetItemTranslatedString(hwnd,IDC_ROMBROWSERCOLUMNS,"Rombrowser Columns"); SetItemTranslatedString(hwnd,IDC_COLUMN_GOODNAME,"GoodName"); SetItemTranslatedString(hwnd,IDC_COLUMN_INTERNALNAME,"Internal Name"); SetItemTranslatedString(hwnd,IDC_COLUMN_COUNTRY,"Country"); SetItemTranslatedString(hwnd,IDC_COLUMN_SIZE,"ROM size"); SetItemTranslatedString(hwnd,IDC_COLUMN_COMMENTS,"Comments"); SetItemTranslatedString(hwnd,IDC_COLUMN_FILENAME,"File Name"); SetItemTranslatedString(hwnd,IDC_COLUMN_MD5,"MD5"); }
21,282
C
.c
464
39.762931
109
0.695517
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,569
luaDefine.h
anta0_mupen64-rr-lua-/lua/luaDefine.h
#ifndef LUA_DEFINE_H #define LUA_DEFINE_H #ifdef WIN32 #define LUA_CONSOLE #ifdef LUA_CONSOLE #define LUA_TRACEINTERP #define LUA_GUI #define LUA_SPEEDMODE #define LUA_JOYPAD #define LUA_BREAKPOINTSYNC_PURE #define LUA_BREAKPOINTSYNC_INTERP #define LUA_PCBREAK_PURE #define LUA_PCBREAK_INTERP #define LUA_TRACELOG #define LUA_TRACEPURE #define LUA_EMUPAUSED_WORK #define LUA_WINDOWMESSAGE #define LUA_LIB #endif #endif #endif
471
C
.h
21
19.285714
34
0.802817
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,592
memory.h
anta0_mupen64-rr-lua-/memory/memory.h
/** * Mupen64 - memory.h * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ #ifndef MEMORY_H #define MEMORY_H int init_memory(); void free_memory(); #define read_word_in_memory() readmem[address>>16]() #define read_byte_in_memory() readmemb[address>>16]() #define read_hword_in_memory() readmemh[address>>16]() #define read_dword_in_memory() readmemd[address>>16]() #define write_word_in_memory() writemem[address>>16]() #define write_byte_in_memory() writememb[address >>16]() #define write_hword_in_memory() writememh[address >>16]() #define write_dword_in_memory() writememd[address >>16]() extern unsigned long SP_DMEM[0x1000/4*2]; extern unsigned char *SP_DMEMb; extern unsigned long *SP_IMEM; extern unsigned long PIF_RAM[0x40/4]; extern unsigned char *PIF_RAMb; extern unsigned long rdram[0x800000/4]; extern unsigned long address, word; extern unsigned char g_byte; extern unsigned short hword; extern unsigned long long int dword, *rdword; extern void (*readmem[0xFFFF])(); extern void (*readmemb[0xFFFF])(); extern void (*readmemh[0xFFFF])(); extern void (*readmemd[0xFFFF])(); extern void (*writemem[0xFFFF])(); extern void (*writememb[0xFFFF])(); extern void (*writememh[0xFFFF])(); extern void (*writememd[0xFFFF])(); typedef struct _RDRAM_register { unsigned long rdram_config; unsigned long rdram_device_id; unsigned long rdram_delay; unsigned long rdram_mode; unsigned long rdram_ref_interval; unsigned long rdram_ref_row; unsigned long rdram_ras_interval; unsigned long rdram_min_interval; unsigned long rdram_addr_select; unsigned long rdram_device_manuf; } RDRAM_register; typedef struct _SP_register { unsigned long sp_mem_addr_reg; unsigned long sp_dram_addr_reg; unsigned long sp_rd_len_reg; unsigned long sp_wr_len_reg; unsigned long w_sp_status_reg; unsigned long sp_status_reg; char halt; char broke; char dma_busy; char dma_full; char io_full; char single_step; char intr_break; char signal0; char signal1; char signal2; char signal3; char signal4; char signal5; char signal6; char signal7; unsigned long sp_dma_full_reg; unsigned long sp_dma_busy_reg; unsigned long sp_semaphore_reg; } SP_register; typedef struct _RSP_register { unsigned long rsp_pc; unsigned long rsp_ibist; } RSP_register; typedef struct _DPC_register { unsigned long dpc_start; unsigned long dpc_end; unsigned long dpc_current; unsigned long w_dpc_status; unsigned long dpc_status; char xbus_dmem_dma; char freeze; char flush; char start_glck; char tmem_busy; char pipe_busy; char cmd_busy; char cbuf_busy; char dma_busy; char end_valid; char start_valid; unsigned long dpc_clock; unsigned long dpc_bufbusy; unsigned long dpc_pipebusy; unsigned long dpc_tmem; } DPC_register; typedef struct _DPS_register { unsigned long dps_tbist; unsigned long dps_test_mode; unsigned long dps_buftest_addr; unsigned long dps_buftest_data; } DPS_register; typedef struct _mips_register { unsigned long w_mi_init_mode_reg; unsigned long mi_init_mode_reg; char init_length; char init_mode; char ebus_test_mode; char RDRAM_reg_mode; unsigned long mi_version_reg; unsigned long mi_intr_reg; unsigned long mi_intr_mask_reg; unsigned long w_mi_intr_mask_reg; char SP_intr_mask; char SI_intr_mask; char AI_intr_mask; char VI_intr_mask; char PI_intr_mask; char DP_intr_mask; } mips_register; typedef struct _VI_register { unsigned long vi_status; unsigned long vi_origin; unsigned long vi_width; unsigned long vi_v_intr; unsigned long vi_current; unsigned long vi_burst; unsigned long vi_v_sync; unsigned long vi_h_sync; unsigned long vi_leap; unsigned long vi_h_start; unsigned long vi_v_start; unsigned long vi_v_burst; unsigned long vi_x_scale; unsigned long vi_y_scale; unsigned long vi_delay; } VI_register; typedef struct _AI_register { unsigned long ai_dram_addr; unsigned long ai_len; unsigned long ai_control; unsigned long ai_status; unsigned long ai_dacrate; unsigned long ai_bitrate; unsigned long next_delay; unsigned long next_len; unsigned long current_delay; unsigned long current_len; } AI_register; typedef struct _PI_register { unsigned long pi_dram_addr_reg; unsigned long pi_cart_addr_reg; unsigned long pi_rd_len_reg; unsigned long pi_wr_len_reg; unsigned long read_pi_status_reg; unsigned long pi_bsd_dom1_lat_reg; unsigned long pi_bsd_dom1_pwd_reg; unsigned long pi_bsd_dom1_pgs_reg; unsigned long pi_bsd_dom1_rls_reg; unsigned long pi_bsd_dom2_lat_reg; unsigned long pi_bsd_dom2_pwd_reg; unsigned long pi_bsd_dom2_pgs_reg; unsigned long pi_bsd_dom2_rls_reg; } PI_register; typedef struct _RI_register { unsigned long ri_mode; unsigned long ri_config; unsigned long ri_current_load; unsigned long ri_select; unsigned long ri_refresh; unsigned long ri_latency; unsigned long ri_error; unsigned long ri_werror; } RI_register; typedef struct _SI_register { unsigned long si_dram_addr; unsigned long si_pif_addr_rd64b; unsigned long si_pif_addr_wr64b; unsigned long si_status; } SI_register; extern RDRAM_register rdram_register; extern PI_register pi_register; extern mips_register MI_register; extern SP_register sp_register; extern SI_register si_register; extern VI_register vi_register; extern RSP_register rsp_register; extern RI_register ri_register; extern AI_register ai_register; extern DPC_register dpc_register; extern DPS_register dps_register; #ifndef _BIG_ENDIAN #define sl(mot) \ ( \ ((mot & 0x000000FF) << 24) | \ ((mot & 0x0000FF00) << 8) | \ ((mot & 0x00FF0000) >> 8) | \ ((mot & 0xFF000000) >> 24) \ ) #define S8 3 #define S16 2 #define Sh16 1 #else #define sl(mot) mot #define S8 0 #define S16 0 #define Sh16 0 #endif void read_nothing(); void read_nothingh(); void read_nothingb(); void read_nothingd(); void read_nomem(); void read_nomemb(); void read_nomemh(); void read_nomemd(); void read_rdram(); void read_rdramb(); void read_rdramh(); void read_rdramd(); void read_rdramFB(); void read_rdramFBb(); void read_rdramFBh(); void read_rdramFBd(); void read_rdramreg(); void read_rdramregb(); void read_rdramregh(); void read_rdramregd(); void read_rsp_mem(); void read_rsp_memb(); void read_rsp_memh(); void read_rsp_memd(); void read_rsp_reg(); void read_rsp_regb(); void read_rsp_regh(); void read_rsp_regd(); void read_rsp(); void read_rspb(); void read_rsph(); void read_rspd(); void read_dp(); void read_dpb(); void read_dph(); void read_dpd(); void read_dps(); void read_dpsb(); void read_dpsh(); void read_dpsd(); void read_mi(); void read_mib(); void read_mih(); void read_mid(); void read_vi(); void read_vib(); void read_vih(); void read_vid(); void read_ai(); void read_aib(); void read_aih(); void read_aid(); void read_pi(); void read_pib(); void read_pih(); void read_pid(); void read_ri(); void read_rib(); void read_rih(); void read_rid(); void read_si(); void read_sib(); void read_sih(); void read_sid(); void read_flashram_status(); void read_flashram_statusb(); void read_flashram_statush(); void read_flashram_statusd(); void read_rom(); void read_romb(); void read_romh(); void read_romd(); void read_pif(); void read_pifb(); void read_pifh(); void read_pifd(); void write_nothing(); void write_nothingb(); void write_nothingh(); void write_nothingd(); void write_nomem(); void write_nomemb(); void write_nomemd(); void write_nomemh(); void write_rdram(); void write_rdramb(); void write_rdramh(); void write_rdramd(); void write_rdramFB(); void write_rdramFBb(); void write_rdramFBh(); void write_rdramFBd(); void write_rdramreg(); void write_rdramregb(); void write_rdramregh(); void write_rdramregd(); void write_rsp_mem(); void write_rsp_memb(); void write_rsp_memh(); void write_rsp_memd(); void write_rsp_reg(); void write_rsp_regb(); void write_rsp_regh(); void write_rsp_regd(); void write_rsp(); void write_rspb(); void write_rsph(); void write_rspd(); void write_dp(); void write_dpb(); void write_dph(); void write_dpd(); void write_dps(); void write_dpsb(); void write_dpsh(); void write_dpsd(); void write_mi(); void write_mib(); void write_mih(); void write_mid(); void write_vi(); void write_vib(); void write_vih(); void write_vid(); void write_ai(); void write_aib(); void write_aih(); void write_aid(); void write_pi(); void write_pib(); void write_pih(); void write_pid(); void write_ri(); void write_rib(); void write_rih(); void write_rid(); void write_si(); void write_sib(); void write_sih(); void write_sid(); void write_flashram_dummy(); void write_flashram_dummyb(); void write_flashram_dummyh(); void write_flashram_dummyd(); void write_flashram_command(); void write_flashram_commandb(); void write_flashram_commandh(); void write_flashram_commandd(); void write_rom(); void write_pif(); void write_pifb(); void write_pifh(); void write_pifd(); void update_SP(); void update_DPC(); #endif
9,979
C
.h
401
22.815461
64
0.737387
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,596
tlb.h
anta0_mupen64-rr-lua-/memory/tlb.h
/** * Mupen64 - tlb.h * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ #ifndef TLB_H #define TLB_H typedef struct _tlb { short mask; long vpn2; char g; unsigned char asid; long pfn_even; char c_even; char d_even; char v_even; long pfn_odd; char c_odd; char d_odd; char v_odd; char r; //long check_parity_mask; unsigned long start_even; unsigned long end_even; unsigned long phys_even; unsigned long start_odd; unsigned long end_odd; unsigned long phys_odd; } tlb; extern unsigned long tlb_LUT_r[0x100000]; extern unsigned long tlb_LUT_w[0x100000]; unsigned long virtual_to_physical_address(unsigned long addresse, int w); int probe_nop(unsigned long address); //unsigned long& get_tlb_LUT_r(int index) //{ // return ::tlb_LUT_r[index]; //} //unsigned long& get_tlb_LUT_w(int index) //{ // return ::tlb_LUT_w[index]; //} #endif
1,814
C
.h
66
25.045455
73
0.727011
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,692
plugin.h
anta0_mupen64-rr-lua-/main/plugin.h
/** * Mupen64 - plugin.h * Copyright (C) 2002 Hacktarux * * Mupen64 homepage: http://mupen64.emulation64.com * email address: [email protected] * * If you want to contribute to the project please contact * me first (maybe someone is already making what you are * planning to do). * * * This program is free software; you can redistribute it and/ * or modify it under the terms of the GNU General Public Li- * cence as published by the Free Software Foundation; either * version 2 of the Licence, or any later version. * * This program is distributed in the hope that it will be use- * ful, but WITHOUT ANY WARRANTY; without even the implied war- * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public Licence for more details. * * You should have received a copy of the GNU General Public * Licence along with this program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, * USA. * **/ #ifndef PLUGIN_H #define PLUGIN_H #ifdef __WIN32__ #include <Windows.h> #else #include "../main/winlnxdefs.h" #endif void plugin_scan_directory(const char *directory); void plugin_load_plugins(const char *gfx_name, const char *audio_name, const char *input_name, const char *RSP_name); char *plugin_next(); int plugin_type(); void plugin_rewind(); char *plugin_filename_by_name(const char *name); char *plugin_name_by_filename(const char *filename); void plugin_exec_config(const char *name); void plugin_exec_test(const char *name); void plugin_exec_about(const char *name); /* Plugin types */ #define PLUGIN_TYPE_RSP 1 #define PLUGIN_TYPE_GFX 2 #define PLUGIN_TYPE_AUDIO 3 #define PLUGIN_TYPE_CONTROLLER 4 /*** Controller plugin's ****/ #define PLUGIN_NONE 1 #define PLUGIN_MEMPAK 2 #define PLUGIN_RUMBLE_PAK 3 // not implemeted for non raw data #define PLUGIN_TANSFER_PAK 4 // not implemeted for non raw data #define PLUGIN_RAW 5 // the controller plugin is passed in raw data /*** Audio plugin system types ***/ #define SYSTEM_NTSC 0 #define SYSTEM_PAL 1 #define SYSTEM_MPAL 2 /***** Structures *****/ typedef struct { WORD Version; WORD Type; char Name[100]; /* Name of the DLL */ /* If DLL supports memory these memory options then set them to TRUE or FALSE if it does not support it */ BOOL NormalMemory; /* a normal BYTE array */ BOOL MemoryBswaped; /* a normal BYTE array where the memory has been pre bswap on a dword (32 bits) boundry */ } PLUGIN_INFO; typedef struct { HINSTANCE hInst; BOOL MemoryBswaped; /* If this is set to TRUE, then the memory has been pre bswap on a dword (32 bits) boundry */ BYTE * RDRAM; BYTE * DMEM; BYTE * IMEM; DWORD * MI_INTR_REG; DWORD * SP_MEM_ADDR_REG; DWORD * SP_DRAM_ADDR_REG; DWORD * SP_RD_LEN_REG; DWORD * SP_WR_LEN_REG; DWORD * SP_STATUS_REG; DWORD * SP_DMA_FULL_REG; DWORD * SP_DMA_BUSY_REG; DWORD * SP_PC_REG; DWORD * SP_SEMAPHORE_REG; DWORD * DPC_START_REG; DWORD * DPC_END_REG; DWORD * DPC_CURRENT_REG; DWORD * DPC_STATUS_REG; DWORD * DPC_CLOCK_REG; DWORD * DPC_BUFBUSY_REG; DWORD * DPC_PIPEBUSY_REG; DWORD * DPC_TMEM_REG; void (__cdecl*CheckInterrupts)( void ); void (__cdecl*ProcessDlistList)( void ); void (__cdecl*ProcessAlistList)( void ); void (__cdecl*ProcessRdpList)( void ); void (__cdecl*ShowCFB)( void ); } RSP_INFO; typedef struct { HWND hWnd; /* Render window */ HWND hStatusBar; /* if render window does not have a status bar then this is NULL */ BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre // bswap on a dword (32 bits) boundry // eg. the first 8 bytes are stored like this: // 4 3 2 1 8 7 6 5 BYTE * HEADER; // This is the rom header (first 40h bytes of the rom // This will be in the same memory format as the rest of the memory. BYTE * RDRAM; BYTE * DMEM; BYTE * IMEM; DWORD * MI_INTR_REG; DWORD * DPC_START_REG; DWORD * DPC_END_REG; DWORD * DPC_CURRENT_REG; DWORD * DPC_STATUS_REG; DWORD * DPC_CLOCK_REG; DWORD * DPC_BUFBUSY_REG; DWORD * DPC_PIPEBUSY_REG; DWORD * DPC_TMEM_REG; DWORD * VI_STATUS_REG; DWORD * VI_ORIGIN_REG; DWORD * VI_WIDTH_REG; DWORD * VI_INTR_REG; DWORD * VI_V_CURRENT_LINE_REG; DWORD * VI_TIMING_REG; DWORD * VI_V_SYNC_REG; DWORD * VI_H_SYNC_REG; DWORD * VI_LEAP_REG; DWORD * VI_H_START_REG; DWORD * VI_V_START_REG; DWORD * VI_V_BURST_REG; DWORD * VI_X_SCALE_REG; DWORD * VI_Y_SCALE_REG; void (__cdecl*CheckInterrupts)( void ); } GFX_INFO; typedef struct { HWND hwnd; HINSTANCE hinst; BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre // bswap on a dword (32 bits) boundry // eg. the first 8 bytes are stored like this: // 4 3 2 1 8 7 6 5 BYTE * HEADER; // This is the rom header (first 40h bytes of the rom // This will be in the same memory format as the rest of the memory. BYTE * RDRAM; BYTE * DMEM; BYTE * IMEM; DWORD * MI_INTR_REG; DWORD * AI_DRAM_ADDR_REG; DWORD * AI_LEN_REG; DWORD * AI_CONTROL_REG; DWORD * AI_STATUS_REG; DWORD * AI_DACRATE_REG; DWORD * AI_BITRATE_REG; void (__cdecl*CheckInterrupts)( void ); } AUDIO_INFO; typedef struct { BOOL Present; BOOL RawData; int Plugin; } CONTROL; typedef union { DWORD Value; struct { unsigned R_DPAD : 1; unsigned L_DPAD : 1; unsigned D_DPAD : 1; unsigned U_DPAD : 1; unsigned START_BUTTON : 1; unsigned Z_TRIG : 1; unsigned B_BUTTON : 1; unsigned A_BUTTON : 1; unsigned R_CBUTTON : 1; unsigned L_CBUTTON : 1; unsigned D_CBUTTON : 1; unsigned U_CBUTTON : 1; unsigned R_TRIG : 1; unsigned L_TRIG : 1; unsigned Reserved1 : 1; unsigned Reserved2 : 1; signed Y_AXIS : 8; signed X_AXIS : 8; }; } BUTTONS; typedef struct { HWND hMainWindow; HINSTANCE hinst; BOOL MemoryBswaped; // If this is set to TRUE, then the memory has been pre // bswap on a dword (32 bits) boundry, only effects header. // eg. the first 8 bytes are stored like this: // 4 3 2 1 8 7 6 5 BYTE * HEADER; // This is the rom header (first 40h bytes of the rom) CONTROL *Controls; // A pointer to an array of 4 controllers .. eg: // CONTROL Controls[4]; } CONTROL_INFO; extern CONTROL Controls[4]; extern void (__cdecl*getDllInfo)(PLUGIN_INFO *PluginInfo); extern void (__cdecl*dllConfig)(HWND hParent); extern void (__cdecl*dllTest)(HWND hParent); extern void (__cdecl*dllAbout)(HWND hParent); extern void (__cdecl*changeWindow)(); extern void (__cdecl*closeDLL_gfx)(); extern BOOL (__cdecl*initiateGFX)(GFX_INFO Gfx_Info); extern void (__cdecl*processDList)(); extern void (__cdecl*processRDPList)(); extern void (__cdecl*romClosed_gfx)(); extern void (__cdecl*romOpen_gfx)(); extern void (__cdecl*showCFB)(); extern void (__cdecl*updateScreen)(); extern void (__cdecl*viStatusChanged)(); extern void (__cdecl*viWidthChanged)(); extern void (__cdecl*readScreen)(void **dest, long *width, long *height); extern void (__cdecl*aiDacrateChanged)(int SystemType); extern void (__cdecl*aiLenChanged)(); extern DWORD (__cdecl*aiReadLength)(); //extern void (__cdecl*aiUpdate)(BOOL Wait); extern void (__cdecl*closeDLL_audio)(); extern BOOL (__cdecl*initiateAudio)(AUDIO_INFO Audio_Info); extern void (__cdecl*processAList)(); extern void (__cdecl*romClosed_audio)(); extern void (__cdecl*romOpen_audio)(); extern void (__cdecl*closeDLL_input)(); extern void (__cdecl*controllerCommand)(int Control, BYTE * Command); extern void (__cdecl*getKeys)(int Control, BUTTONS *Keys); extern void (__cdecl*initiateControllers)(CONTROL_INFO ControlInfo); extern void (__cdecl*readController)(int Control, BYTE *Command); extern void (__cdecl*romClosed_input)(); extern void (__cdecl*romOpen_input)(); extern void (__cdecl*keyDown)(WPARAM wParam, LPARAM lParam); extern void (__cdecl*keyUp)(WPARAM wParam, LPARAM lParam); extern void (__cdecl*closeDLL_RSP)(); extern DWORD (__cdecl*doRspCycles)(DWORD Cycles); extern void (__cdecl*initiateRSP)(RSP_INFO Rsp_Info, DWORD * CycleCount); extern void (__cdecl*romClosed_RSP)(); // frame buffer plugin spec extension typedef struct { DWORD addr; DWORD size; DWORD width; DWORD height; } FrameBufferInfo; extern void (__cdecl *fBRead)(DWORD addr); extern void (__cdecl *fBWrite)(DWORD addr, DWORD size); extern void (__cdecl *fBGetFrameBufferInfo)(void *p); #endif
8,739
C
.h
253
31.786561
91
0.683169
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,709
disasm.h
anta0_mupen64-rr-lua-/main/disasm.h
#ifndef R4300_DISASM_H #define R4300_DISASM_H typedef unsigned char r4300byte; typedef unsigned short r4300half; typedef signed short r4300halfsigned; typedef unsigned long r4300word; typedef signed long r4300wordsigned; typedef r4300byte CPUREG; typedef r4300byte FPUREG; typedef enum { INST_UNDEF, INST_LB, INST_LBU, INST_LD, INST_LDL, INST_LDR, INST_LH, INST_LHU, INST_LL, INST_LLD, INST_LW, INST_LWL, INST_LWR, INST_LWU, INST_SB, INST_SC, INST_SCD, INST_SD, INST_SDL, INST_SDR, INST_SH, INST_SW, INST_SWL, INST_SWR, INST_SYNC, INST_ADD, INST_ADDI, INST_ADDIU, INST_ADDU, INST_AND, INST_ANDI, INST_DADD, INST_DADDI, INST_DADDIU, INST_DADDU, INST_DDIV, INST_DDIVU, INST_DIV, INST_DIVU, INST_DMULT, INST_DMULTU, INST_DSLL, INST_DSLL32, INST_DSLLV, INST_DSRA, INST_DSRA32, INST_DSRAV, INST_DSRL, INST_DSRL32, INST_DSRLV, INST_DSUB, INST_DSUBU, INST_LUI, INST_MFHI, INST_MFLO, INST_MTHI, INST_MTLO, INST_MULT, INST_MULTU, INST_NOR, INST_OR, INST_ORI, INST_SLL, INST_SLLV, INST_SLT, INST_SLTI, INST_SLTIU, INST_SLTU, INST_SRA, INST_SRAV, INST_SRL, INST_SRLV, INST_SUB, INST_SUBU, INST_XOR, INST_XORI, INST_BEQ, INST_BEQL, INST_BGEZ, INST_BGEZAL, INST_BGEZALL, INST_BGEZL, INST_BGTZ, INST_BGTZL, INST_BLEZ, INST_BLEZL, INST_BLTZ, INST_BLTZAL, INST_BLTZALL, INST_BLTZL, INST_BNE, INST_BNEL, INST_J, INST_JAL, INST_JALR, INST_JR, INST_BREAK, INST_SYSCALL, INST_LWC1, INST_LDC1, INST_SWC1, INST_SDC1, INST_TEQ, INST_TEQI, INST_TGE, INST_TGEI, INST_TGEIU, INST_TGEU, INST_TLT, INST_TLTI, INST_TLTIU, INST_TLTU, INST_TNE, INST_TNEI, INST_CACHE, INST_ERET, INST_MFC0, INST_MTC0, INST_TLBP, INST_TLBR, INST_TLBWI, INST_TLBWR, INST_MFC1, INST_DMFC1, INST_CFC1, INST_MTC1, INST_DMTC1, INST_CTC1, INST_BC1F, INST_BC1T, INST_BC1FL, INST_BC1TL, INST_ADD_S, INST_SUB_S, INST_MUL_S, INST_DIV_S, INST_SQRT_S, INST_ABS_S, INST_MOV_S, INST_NEG_S, INST_ROUND_L_S, INST_TRUNC_L_S, INST_CEIL_L_S, INST_FLOOR_L_S, INST_ROUND_W_S, INST_TRUNC_W_S, INST_CEIL_W_S, INST_FLOOR_W_S, INST_CVT_D_S, INST_CVT_W_S, INST_CVT_L_S, INST_C_F_S, INST_C_UN_S, INST_C_EQ_S, INST_C_UEQ_S, INST_C_OLT_S, INST_C_ULT_S, INST_C_OLE_S, INST_C_ULE_S, INST_C_SF_S, INST_C_NGLE_S, INST_C_SEQ_S, INST_C_NGL_S, INST_C_LT_S, INST_C_NGE_S, INST_C_LE_S, INST_C_NGT_S, INST_ADD_D, INST_SUB_D, INST_MUL_D, INST_DIV_D, INST_SQRT_D, INST_ABS_D, INST_MOV_D, INST_NEG_D, INST_ROUND_L_D, INST_TRUNC_L_D, INST_CEIL_L_D, INST_FLOOR_L_D, INST_ROUND_W_D, INST_TRUNC_W_D, INST_CEIL_W_D, INST_FLOOR_W_D, INST_CVT_S_D, INST_CVT_W_D, INST_CVT_L_D, INST_C_F_D, INST_C_UN_D, INST_C_EQ_D, INST_C_UEQ_D, INST_C_OLT_D, INST_C_ULT_D, INST_C_OLE_D, INST_C_ULE_D, INST_C_SF_D, INST_C_NGLE_D, INST_C_SEQ_D, INST_C_NGL_D, INST_C_LT_D, INST_C_NGE_D, INST_C_LE_D, INST_C_NGT_D, INST_CVT_S_W, INST_CVT_D_W, INST_CVT_S_L, INST_CVT_D_L, INST_COUNT } INST; //•\ަ—p typedef enum { INSTF_NONE, //---- i type INSTF_LUI, INSTF_ISIGN, INSTF_IUNSIGN, INSTF_0BRANCH, INSTF_1BRANCH, INSTF_2BRANCH, INSTF_ADDRR, INSTF_ADDRW, INSTF_JR, //---- j type INSTF_J, //---- r type INSTF_MFC0, INSTF_MTC0, INSTF_MFC1, INSTF_MTC1, INSTF_R1, INSTF_R2, INSTF_R3, INSTF_SA, //---- lf type INSTF_LFR, INSTF_LFW, //---- cf type (S, D) INSTF_R2F, INSTF_C, INSTF_R3F, //---- INSTF_COUNT } INSTFMT; typedef enum { INSTFTYPE_NONE, INSTFTYPE_I, INSTFTYPE_J, INSTFTYPE_R, INSTFTYPE_LF, INSTFTYPE_CF, INSTFTYPE_COUNT } INSTFTYPE; typedef union { struct { CPUREG rs; CPUREG rt; r4300half immediate; } i; struct { r4300word inst_index; } j; struct { CPUREG rs; CPUREG rt; CPUREG rd; r4300byte sa; } r; struct { FPUREG base; FPUREG ft; r4300half offset; } lf; struct { FPUREG ft; FPUREG fs; FPUREG fd; } cf; } INSTOPERAND; typedef struct { INST inst; INSTFMT format; INSTFTYPE type; INSTOPERAND operand; } INSTDECODE; INST GetInstruction(r4300word w); void DecodeInstruction(r4300word w, INSTDECODE *d); const char *GetOpecodeString(INSTDECODE *d); char *GetOperandString(char *buf, INSTDECODE *d, r4300word pc); char *DisassembleInstruction(char *buf, r4300word w, r4300word pc); //buf size:27 extern const INSTFMT InstFormat[INST_COUNT]; extern const INSTFTYPE InstFormatType[INSTF_COUNT]; extern const char * const OpecodeName[INST_COUNT]; extern void (*InstFormatTypeFunc[INSTFTYPE_COUNT])(r4300word, INSTOPERAND*); extern const char * const CPURegisterName[32]; extern const char * const COP0RegisterName[32]; #endif
4,618
C
.h
154
26.935065
82
0.701246
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,356,725
translation.h
anta0_mupen64-rr-lua-/main/win/translation.h
/*************************************************************************** translation.h - description ------------------- copyright : (C) 2003 by ShadowPrince email : [email protected] ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <Windows.h> void SelectLang(HWND hWnd, int LangMenuID); void SetupLanguages ( HWND hWnd ) ; void Translate(char* GuiWord,char* Ret); void TranslateDefault(char* GuiWord,char *Default,char* Ret); void SetItemTranslatedString(HWND hwnd,int ElementID,char* Str); void SetStatusTranslatedString(HWND hStatus,int section,char* Str); void SetMenuTranslatedString(HMENU hMenu,int elementID,char* Str,char* Acc); void SetMenuAccelerator(HMENU hMenu,int elementID,char* Acc); void TranslateMenu(HMENU hMenu,HWND mainHWND); void TranslateConfigDialog(HWND hwnd); void TranslateDirectoriesConfig(HWND hwnd); void TranslateRomInfoDialog(HWND hwnd); void TranslateRomBrowserMenu(HMENU hMenu); void TranslateAuditDialog(HWND hwnd); void TranslateGeneralDialog(HWND hwnd); void TranslateLangInfoDialog( HWND hwnd ); void TranslateAdvancedDialog(HWND hwnd) ; void freeLanguages();
1,896
C
.h
33
53
78
0.529919
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,356,727
GUI_LogWindow.h
anta0_mupen64-rr-lua-/main/win/GUI_LogWindow.h
/*************************************************************************** GUI_LogWindow.h - description ------------------- copyright : (C) 2003 by ShadowPrince email : [email protected] ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef _GUI_LOGWINDOW_H #define _GUI_LOGWINDOW_H #include <Windows.h> extern int extLogger ; int GUI_CreateLogWindow( HWND hwnd ); void ShowWarning(char *Str, ...); void ShowError(char *Str, ...); void ShowInfo(char *Str, ...); void ShowHideLogWindow(); void ShowLogWindow(); void HideLogWindow(); void ClearLogWindow(); void CloseLogWindow(); #endif
1,380
C
.h
28
44.107143
78
0.394303
anta0/mupen64-rr-lua-
3
20
0
GPL-2.0
9/7/2024, 2:05:41 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,381,828
sys_cod4defs.h
haithun_CoD4X17a_testing/sys_cod4defs.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef __SYS_COD4DEFS_H__ #define __SYS_COD4DEFS_H__ #define COD4_DLL "cod4_lnxded.so" #define COD4_BINNAME "cod4_lnxded" #define TEXT_SECTION_OFFSET 0x2c20 #define TEXT_SECTION_LENGTH 0x1bf1a4 #define RODATA_SECTION_OFFSET 0x1c1e00 #define RODATA_SECTION_LENGTH 0x36898 #define DATA_SECTION_OFFSET 0x222580 #define DATA_SECTION_OFFSET_FIX 0x1000 #define DATA_SECTION_LENGTH 0x9454 #define IMAGE_BASE 0x8048000 #define Q3_VERSION "1.7a" #define GAME_STRING "CoD4 X" #include "version.h" #ifndef BUILD_NUMBER #define BUILD_NUMBER -1 #endif #define MAX_CLIENTS 64 #define MAX_CONFIGSTRINGS 2442 #endif
1,595
C
.c
37
40.378378
87
0.706874
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,839
scr_vm_fs.c
haithun_CoD4X17a_testing/scr_vm_fs.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "q_shared.h" #include "qcommon_io.h" #include "filesystem.h" #include "scr_vm.h" #include "cvar.h" #include <string.h> static int scr_fopencount; static scr_fileHandle_t scr_fsh[MAX_SCRIPT_FILEHANDLES]; /* ============== Scr_FS_CloseFile If the FILE pointer is an open pak file, leave it open. For some reason, other dll's can't just cal fclose() on files returned by FS_FOpenFile... ============== */ qboolean Scr_FS_CloseFile( scr_fileHandle_t* f ) { // we didn't find it as a pak, so close it as a unique file if (f->fh) { fclose (f->fh); Com_Memset( f, 0, sizeof( scr_fileHandle_t )); return qtrue; } Com_Memset( f, 0, sizeof( scr_fileHandle_t )); return qfalse; } /* ======================================================================================== Handle based file calls for virtual machines ======================================================================================== */ /* ============= FS_FreeFile ============= */ /* void Scr_FS_FreeFile( void *buffer ) { if ( !buffer ) { Com_Error( ERR_FATAL, "FS_FreeFile( NULL )" ); } *fs_loadStack = (*fs_loadStack)-1; free( buffer ); } */ /* ================= Scr_FS_ReadLine Custom function that only reads single lines Properly handles line reads ================= */ int Scr_FS_ReadLine( void *buffer, int len, fileHandle_t f ) { char *read; char *buf; if ( !fs_searchpaths ) { Com_Error( ERR_FATAL, "Filesystem call made without initialization\n" ); } if(f > MAX_SCRIPT_FILEHANDLES || f < 1){ Scr_Error("Scr_FS_ReadLine: Out of range filehandle\n"); return 0; } buf = buffer; *buf = 0; read = fgets (buf, len, scr_fsh[f -1].fh); if (read == NULL) { //Error if(feof(scr_fsh[f -1].fh)) return 0; Com_PrintScriptRuntimeWarning("Scr_FS_ReadLine: couldn't read line"); return -1; } return 1; } qboolean Scr_FS_AlreadyOpened( char* qpath, char* filename, size_t fnamelen){ int i = 0; char qpathbuf[MAX_OSPATH]; Q_strncpyz(qpathbuf, qpath, sizeof(qpathbuf)); FS_ConvertPath(qpathbuf); do{ Q_strncpyz(filename, &qpathbuf[i], fnamelen); i = Q_strichr(&qpathbuf[i], '/'); i += 1; }while(i > 0); for(i = 0; i < MAX_SCRIPT_FILEHANDLES; i++){ if(!Q_stricmp(filename, scr_fsh[i].filename)){ Com_PrintScriptRuntimeWarning("Script_FileOpen: Tried to open a file with the same name two times: %s\n", filename); *filename = 0; return qtrue; } } return qfalse; } /* =========== Scr_FS_FOpenFile =========== */ qboolean Scr_FS_FOpenFile( const char *filename, fsMode_t mode, scr_fileHandle_t* f ) { char *ospath; f->fh = NULL; if ( !fs_searchpaths ) { Com_Error( ERR_FATAL, "Filesystem call made without initialization" ); } // search homepath ospath = FS_BuildOSPath( fs_homepath->string, "", filename ); // remove trailing slash if((ospath[strlen(ospath)-1]) == '/') ospath[strlen(ospath)-1] = '\0'; if ( fs_debug->boolean ) { Com_Printf( "Scr_FS_FOpenFile (fs_homepath): %s\n", ospath ); } switch(mode){ case FS_READ: f->fh = fopen( ospath, "rt" ); break; case FS_WRITE: if( !FS_CreatePath( ospath )) { f->fh = fopen( ospath, "wt" ); } break; case FS_APPEND: if( !FS_CreatePath( ospath )) { f->fh = fopen( ospath, "at" ); } break; default: Scr_Error("Scr_FS_FOpenFile: bad mode.\n"); return qfalse; } if (!f->fh){ // NOTE TTimo on non *nix systems, fs_homepath == fs_basepath, might want to avoid if (Q_stricmp(fs_homepath->string,fs_basepath->string)){ // search basepath ospath = FS_BuildOSPath( fs_basepath->string, "", filename); // remove trailing slash if((ospath[strlen(ospath)-1]) == '/') ospath[strlen(ospath)-1] = '\0'; if ( fs_debug->boolean ){ Com_Printf( "Scr_FS_FOpenFile (fs_basepath): %s\n", ospath ); } switch(mode){ case FS_READ: f->fh = fopen( ospath, "rt" ); break; case FS_WRITE: if( !FS_CreatePath( ospath )) { f->fh = fopen( ospath, "wt" ); } break; case FS_APPEND: if( !FS_CreatePath( ospath )) { f->fh = fopen( ospath, "at" ); } break; default: return qfalse; } } } if ( f->fh ) { f->baseOffset = ftell(f->fh); fseek(f->fh,0,SEEK_END); f->fileSize = ftell(f->fh); fseek(f->fh,0,SEEK_SET); return qtrue; } return qfalse; } fileHandle_t Scr_OpenScriptFile( char* qpath, scr_fileHandleType_t ft, fsMode_t mode){ int i; char filename[MAX_QPATH]; if ( !fs_searchpaths ) { Com_Error( ERR_FATAL, "Filesystem call made without initialization" ); } if(Scr_FS_AlreadyOpened(qpath, filename, sizeof(filename))){ return 0; } for(i=0; i < MAX_SCRIPT_FILEHANDLES; i++){ if(!scr_fsh[i].fh){ if(!Scr_FS_FOpenFile(qpath, mode, &scr_fsh[i])){ return 0; } scr_fsh[i].type = ft; Q_strncpyz(scr_fsh[i].filename, filename, MAX_QPATH); scr_fopencount++; return i+1; } } Com_PrintScriptRuntimeWarning("Scr_OpenScriptFile: Exceeded limit of %i opened files\n", MAX_SCRIPT_FILEHANDLES); return 0; } qboolean Scr_CloseScriptFile( fileHandle_t fh){ if ( !fs_searchpaths ) { Com_Error( ERR_FATAL, "Filesystem call made without initialization" ); } if(fh > MAX_SCRIPT_FILEHANDLES || fh < 1){ Scr_Error("Scr_CloseScriptFile: Out of range filehandle\n"); return qfalse; } switch(scr_fsh[fh -1].type){ case SCR_FH_FILE: if(!Scr_FS_CloseFile(&scr_fsh[fh -1])){ return qfalse; } break; case SCR_FH_PARALIST: //ToDo Additional handling for memcached files if(!Scr_FS_CloseFile(&scr_fsh[fh -1])){ return qfalse; } break; case SCR_FH_INDEXPARALIST: //ToDo Additional handling for memcached files if(!Scr_FS_CloseFile(&scr_fsh[fh -1])){ return qfalse; } } scr_fopencount--; return qtrue; } /* ================= FS_Read Properly handles partial reads ================= */ int Scr_FS_Read( void *buffer, int len, fileHandle_t f ) { int block, remaining; int read; byte *buf; int tries; if ( !fs_searchpaths ) { Com_Error( ERR_FATAL, "Filesystem call made without initialization" ); } if(f > MAX_SCRIPT_FILEHANDLES || f < 1){ Scr_Error("Scr_FS_Read: Out of range filehandle\n"); return 0; } buf = (byte *)buffer; remaining = len; tries = 0; while (remaining) { block = remaining; read = fread (buf, 1, block, scr_fsh[f -1].fh); if (read == 0) { // we might have been trying to read from a CD, which // sometimes returns a 0 read on windows if (!tries) { tries = 1; } else { return len-remaining; //Com_Error (ERR_FATAL, "FS_Read: 0 bytes read"); } } if (read == -1) { Scr_Error ("Scr_FS_Read: -1 bytes read"); } remaining -= read; buf += read; } return len; } /* ================= Scr_FS_Write Properly handles partial writes ================= */ int Scr_FS_Write( const void *buffer, int len, fileHandle_t h ) { int block, remaining; int written; byte *buf; int tries; FILE *f; if ( !fs_searchpaths ) { Com_Error( ERR_FATAL, "Filesystem call made without initialization" ); } if(h > MAX_SCRIPT_FILEHANDLES || h < 1){ Scr_Error("Scr_FS_Write: Out of range filehandle\n"); return 0; } f = scr_fsh[h -1].fh; buf = (byte *)buffer; remaining = len; tries = 0; while (remaining) { block = remaining; written = fwrite (buf, 1, block, f); if (written == 0) { if (!tries) { tries = 1; } else { Com_Printf( "Scr_FS_Write: 0 bytes written\n" ); return 0; } } if (written == -1) { Com_Printf( "Scr_FS_Write: -1 bytes written\n" ); return 0; } remaining -= written; buf += written; } return len; } #define PK3_SEEK_BUFFER_SIZE 65536 /* ================= Scr_FS_Seek ================= */ int Scr_FS_Seek( fileHandle_t f, long offset, int origin ) { int _origin; if ( !fs_searchpaths ) { Com_Error( ERR_FATAL, "Filesystem call made without initialization" ); return -1; } if(f > MAX_SCRIPT_FILEHANDLES || f < 1){ Scr_Error("Scr_FS_Seek: Out of range filehandle\n"); return -1; } FILE *file; file = scr_fsh[f -1].fh; switch( origin ) { case FS_SEEK_CUR: _origin = SEEK_CUR; break; case FS_SEEK_END: _origin = SEEK_END; break; case FS_SEEK_SET: _origin = SEEK_SET; break; default: _origin = SEEK_CUR; Scr_Error( "Bad origin in Scr_FS_Seek" ); break; } return fseek( file, offset, _origin ); }
10,593
C
.c
356
23.457865
128
0.553252
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,840
sys_con_tty.h
haithun_CoD4X17a_testing/sys_con_tty.h
/* =========================================================================== Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef __SYS_CON_TTY_H__ #define __SYS_CON_TTY_H__ void Sys_AnsiColorPrint( const char *msg ); void CON_Shutdown( void ); void CON_Init(void); char *CON_Input( void ); void CON_Print( const char *msg ); #endif
1,178
C
.c
24
45.708333
87
0.650655
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,841
trace.h
haithun_CoD4X17a_testing/trace.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef __TRACE_H__ #define __TRACE_H__ // a trace is returned when a box is swept through the world typedef struct trace_s{ float fraction; //0x00 time completed, 1.0 = didn't hit anything int unknown[6]; /* qboolean allsolid; // if true, plane is not valid qboolean startsolid; // if true, the initial point was in a solid area float fraction; // time completed, 1.0 = didn't hit anything //0x00 vec3_t endpos; // final position cplane_t plane; // surface normal at impact, transformed to world space int surfaceFlags; // surface hit int contents; // contents on other side of surface hit*/ int var_02; //0x1c short entityNum; //0x20 entity the contacted sirface is a part of } trace_t; // trace->entityNum can also be 0 to (MAX_GENTITIES-1) // or ENTITYNUM_NONE, ENTITYNUM_WORLD typedef int clipHandle_t; qboolean __cdecl CM_TraceBox(const float*, const float*, const float*, float); clipHandle_t __cdecl CM_TempBoxModel(const float* mins, const float* maxs, int capsule); void __cdecl CM_TransformedBoxTrace(trace_t* trace, const float* start, const float* end, const float* mins, const float* maxs, clipHandle_t cliphandle, int contentmask, const float* origin, const float* angle); #endif
2,309
C
.c
41
53.390244
127
0.681455
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,843
qcommon_parsecmdline.h
haithun_CoD4X17a_testing/qcommon_parsecmdline.h
/* =========================================================================== Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef __COMMON_PARSECMDLINE_H__ #define __COMMON_PARSECMDLINE_H__ #include "q_shared.h" void Com_StartupVariable( const char *match ); qboolean Com_AddStartupCommands( void ); void Com_ParseCommandLine( char *commandLine ); #endif
1,200
C
.c
23
48.695652
87
0.666096
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,848
cmd.c
haithun_CoD4X17a_testing/cmd.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include <string.h> #include "cmd.h" #include "qcommon_io.h" #include "qcommon_mem.h" #include "qcommon.h" #include "filesystem.h" cmd_function_t **cmd_functions_addr = (cmd_function_t**)(0x887eb98); #define cmd_functions *cmd_functions_addr /* ============ Cmd_AddCommand ============ */ qboolean Cmd_AddCommand( const char *cmd_name, xcommand_t function ) { cmd_function_t *cmd; // fail if the command already exists for ( cmd = cmd_functions ; cmd ; cmd = cmd->next ) { if ( !strcmp( cmd_name, cmd->name )) { // allow completion-only commands to be silently doubled if ( function != NULL ) { Com_PrintWarning( "Cmd_AddCommand: %s already defined\n", cmd_name ); } return qfalse; } } // use a small malloc to avoid zone fragmentation cmd = Z_Malloc( sizeof( cmd_function_t ) + strlen(cmd_name) + 1); strcpy((char*)(cmd +1), cmd_name); cmd->name = (char*)(cmd +1); cmd->function = function; cmd->next = cmd_functions; cmd_functions = cmd; return qtrue; } /* ============ Cmd_RemoveCommand ============ */ qboolean Cmd_RemoveCommand( const char *cmd_name ) { cmd_function_t *cmd, **back; back = &cmd_functions; while ( 1 ) { cmd = *back; if ( !cmd ) { // command wasn't active return qfalse; } if ( !strcmp( cmd_name, cmd->name ) ) { *back = cmd->next; Z_Free( cmd ); return qtrue; } back = &cmd->next; } return qfalse; } /* =============== Cmd_Echo_f Just prints the rest of the line to the console =============== */ static void Cmd_Echo_f (void) { char buf[MAX_STRING_CHARS]; Com_Printf ("%s\n", Cmd_Args(buf, sizeof(buf))); } qboolean Cmd_SetPower(const char *cmd_name, int power) { cmd_function_t *cmd; if(!cmd_name) return qfalse; for(cmd = cmd_functions ; cmd ; cmd = cmd->next){ if(!Q_stricmp(cmd_name, cmd->name)){ if(cmd->minPower != power){ cmd->minPower = power; } return qtrue; } } return qfalse; } int Cmd_GetPower(const char* cmd_name) { cmd_function_t *cmd; for(cmd = cmd_functions ; cmd ; cmd = cmd->next){ if(!Q_stricmp(cmd_name,cmd->name)){ if(!cmd->minPower) return 100; else return cmd->minPower; } } return -1; //Don't exist } void Cmd_ResetPower() { cmd_function_t *cmd; //Init the permission table with default values for(cmd = cmd_functions ; cmd ; cmd = cmd->next) cmd->minPower = 100; } /* ============ SV_Cmd_Argc Returns count of commandline arguments ============ */ int SV_Cmd_Argc( void ) { int cmd_argc; __asm__ ( "mov 0x8879a40,%%eax \n\t" "mov 0x8879a84(,%%eax,4), %%eax \n\t" :"=a" (cmd_argc)); return cmd_argc; } /* ============ Cmd_Argc Returns count of commandline arguments ============ */ int Cmd_Argc( void ) { int cmd_argc; __asm__ ( "mov 0x88799a0,%%eax \n\t" "mov 0x88799e4(,%%eax,4), %%eax \n\t" :"=a" (cmd_argc)); return cmd_argc; } /* ============ SV_Cmd_Argv Returns commandline argument by number ============ */ char *SV_Cmd_Argv( int arg ) { char* cmd_argv; __asm__ ( "mov 0x8879a40,%%eax \n\t" "mov $0x822be98,%%edx \n\t" "cmpl %%ecx,0x8879a84(,%%eax,4) \n\t" "jle 1f \n\t" "mov 0x8879aa4(,%%eax,4),%%eax \n\t" "lea (%%eax,%%ecx,4),%%edx \n\t" "mov 0x4(%%eax),%%edx \n\t" "lea (%%eax,%%ecx,4),%%edx \n\t" "mov (%%edx),%%edx \n\t" "1: \n\t" " \n\t" :"=d" (cmd_argv) :"c" (arg) :"eax" ); return (cmd_argv); } /* ============ SV_Cmd_ArgvBuffer The interpreted versions use this because they can't have pointers returned to them ============ */ void SV_Cmd_ArgvBuffer( int arg, char *buffer, int bufferLength ) { Q_strncpyz( buffer, SV_Cmd_Argv(arg), bufferLength ); } /* ============ Cmd_Argv Returns commandline argument by number ============ */ char *Cmd_Argv( int arg ) { char* cmd_argv; __asm__ ( "mov 0x88799a0,%%eax \n\t" "mov $0x00,%%edx \n\t" "cmpl %%ecx,0x88799e4(,%%eax,4) \n\t" "jle 1f \n\t" "mov 0x8879a04(,%%eax,4),%%eax \n\t" //? "lea (%%eax,%%ecx,4),%%edx \n\t" "mov (%%edx),%%edx \n\t" "1: \n\t" " \n\t" :"=d" (cmd_argv) :"c" (arg) :"eax" ); if(cmd_argv == NULL) return ""; else return (cmd_argv); } /* ============ Cmd_Args Returns a single string containing argv(1) to argv(argc()-1) ============ */ char *Cmd_Args( char* buff, int bufsize ) { int i; int cmd_argc = Cmd_Argc(); buff[0] = 0; for ( i = 1 ; i < cmd_argc ; i++ ) { Q_strcat( buff, bufsize, Cmd_Argv(i) ); if ( i != cmd_argc-1 ) { Q_strcat( buff, bufsize, " " ); } } return buff; } /* ============ Cmd_Argvs Returns a single string containing argv(int arg) to argv(argc()-arg) ============ */ char *Cmd_Argsv( int arg, char* buff, int bufsize ) { int i; int cmd_argc = Cmd_Argc(); buff[0] = 0; for ( i = arg ; i < cmd_argc ; i++ ) { Q_strcat( buff, bufsize, Cmd_Argv(i) ); if ( i != cmd_argc-1 ) { Q_strcat( buff, bufsize, " " ); } } return buff; } /* =========================================== command line completion =========================================== */ /* ============ Cmd_CommandCompletion ============ */ void Cmd_CommandCompletion( void(*callback)(const char *s) ) { cmd_function_t *cmd; for (cmd=cmd_functions ; cmd ; cmd=cmd->next) { callback( cmd->name ); } } /* ============ Cmd_CompleteArgument ============ */ void Cmd_CompleteArgument( const char *command, char *args, int argNum ) { cmd_function_t *cmd; for( cmd = cmd_functions; cmd; cmd = cmd->next ) { if( !Q_stricmp( command, cmd->name ) && cmd->complete ) { cmd->complete( args, argNum ); } } } /* ============ Cmd_SetCommandCompletionFunc ============ */ void Cmd_SetCommandCompletionFunc( const char *command, completionFunc_t complete ) { cmd_function_t *cmd; for( cmd = cmd_functions; cmd; cmd = cmd->next ) { if( !Q_stricmp( command, cmd->name ) ) { cmd->complete = complete; } } } qboolean Cmd_InfoSetPower( const char *infostring ) { int power; char cmdname[40]; power = atoi(Info_ValueForKey(infostring, "power")); Q_strncpyz(cmdname, Info_ValueForKey(infostring, "cmd"), sizeof(cmdname)); if(!Cmd_SetPower(cmdname, power)){ Com_DPrintf("Warning: Commandname %s is not known yet\n", cmdname); return qfalse; } return qtrue; } void Cmd_WritePowerConfig(char* buffer, int size) { char infostring[MAX_INFO_STRING]; Q_strcat(buffer, size,"\n//Minimum power settings\n"); cmd_function_t *cmd; for ( cmd = cmd_functions ; cmd ; cmd = cmd->next ){ *infostring = 0; Info_SetValueForKey(infostring, "type", "cmdMinPower"); Info_SetValueForKey(infostring, "cmd", cmd->name); Info_SetValueForKey(infostring, "power", va("%i",cmd->minPower)); Q_strcat(buffer, size, infostring); Q_strcat(buffer, size, "\\\n"); } } /* ============ Cmd_ListPower_f ============ */ static void Cmd_ListPower_f() { cmd_function_t *cmd; int i, hidden, j, l; char *match; if ( Cmd_Argc() > 1 ) { match = Cmd_Argv( 1 ); } else { match = NULL; } i = 0; hidden = 0; for ( cmd = cmd_functions ; cmd ; cmd = cmd->next ) { if ( (match && !Com_Filter( match, cmd->name, qfalse ))) { continue; } if(cmd->minPower == 100){ hidden++; continue; } Com_Printf ("%s", cmd->name ); l = 24 - strlen(cmd->name); j = 0; do { Com_Printf (" "); j++; } while(j < l); Com_Printf( "%d\n", cmd->minPower ); i++; } Com_Printf( "\n%i commands with specified power settings are shown\n", i ); Com_Printf( "%i commands are hidden because the required power level for those commands is set to 100\n", hidden ); Com_Printf( "Type cmdlist to get a complete list of all commands\n"); } /* ============ Cmd_List_f ============ */ static void Cmd_List_f( void ) { cmd_function_t *cmd; int i; char *match; if ( Cmd_Argc() > 1 ) { match = Cmd_Argv( 1 ); } else { match = NULL; } i = 0; for ( cmd = cmd_functions ; cmd ; cmd = cmd->next ) { if ( (match && !Com_Filter( match, cmd->name, qfalse )) || SV_RemoteCmdGetInvokerPower() < cmd->minPower) { continue; } Com_Printf( "%s\n", cmd->name ); i++; } Com_Printf( "%i commands\n", i ); } /* =============== Cmd_Exec_f =============== */ /* void Cmd_Exec_f( void ) { char *f; int len; int read; fileHandle_t file; char filename[MAX_QPATH]; char buf[4096]; if ( Cmd_Argc() != 2 ) { Com_Printf( "exec <filename> : execute a script file\n" ); return; } Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) ); COM_DefaultExtension( filename, sizeof( filename ), ".cfg" ); FS_FOpenFileRead(filename, &file); //len = FS_ReadFile( filename, (void **)&f ); if ( !file ) { Com_Printf( "couldn't exec %s\n",Cmd_Argv( 1 ) ); return; } Com_Printf( "execing %s\n",Cmd_Argv( 1 ) ); while(qtrue) { read = FS_ReadLine(buf, sizeof(buf), file); if(read == 0){ FS_FCloseFile(file); return; } if(read == -1){ Com_Printf("Can not read from nvconfig.dat\n"); FS_FCloseFile(file); return; } if(!*buf || *buf == '\n'){ continue; } Cbuf_Execute(buf, 0) } } void Cmd_Exec_f( void ) { char *f; char filename[MAX_QPATH]; if ( Cmd_Argc() != 2 ) { Com_Printf( "exec <filename> : execute a script file\n" ); return; } Q_strncpyz( filename, Cmd_Argv( 1 ), sizeof( filename ) ); COM_DefaultExtension( filename, sizeof( filename ), ".cfg" ); FS_ReadFile( filename, (void **)&f ); if ( !f ) { Com_PrintError( "couldn't exec %s\n",Cmd_Argv( 1 ) ); return; } Com_Printf( "execing %s\n",Cmd_Argv( 1 ) ); Cbuf_ExecuteBuffer( 0,0, f ); FS_FreeFile( f ); } */ void Cmd_Init( void ) { *(int*)0x88799a0 = -1; *(int*)0x887c300 = 0; *(int*)0x887c304 = 0; *(int*)0x8879a40 = -1; *(int*)0x887eb40 = 0; *(int*)0x887eb44 = 0; Cmd_AddCommand( "cmdlist",Cmd_List_f ); Cmd_AddCommand ("cmdpowerlist", Cmd_ListPower_f); Cmd_AddCommand( "exec",Cmd_Exec_f ); Cmd_AddCommand( "vstr",Cmd_Vstr_f ); Cmd_AddCommand( "echo",Cmd_Echo_f ); Cmd_AddCommand( "wait", Cmd_Wait_f ); }
11,216
C
.c
444
22.407658
116
0.592419
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,849
misc.h
haithun_CoD4X17a_testing/misc.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef __MISC_H__ #define __MISC_H__ #include "q_shared.h" #include "player.h" #define STRBUFFBASEPTR_ADDR 0x897d780 void __cdecl Swap_Init(void); void __cdecl CSS_InitConstantConfigStrings(void); void __cdecl Con_InitChannels(void); void __cdecl SEH_UpdateLanguageInfo(void); void __cdecl SetAnimCheck(int); qboolean __cdecl BG_IsWeaponValid( playerState_t *ps, unsigned int index); qboolean __cdecl SEH_StringEd_GetString( const char* input ); void __cdecl DObjInit(void); void __cdecl SL_Init(void); void __cdecl SL_RemoveRefToString( unsigned int ); char* SL_ConvertToString(unsigned int index); void AddRedirectLocations(void); #endif /* void __cdecl HECmd_SetText)( scr_entref_t ); tHECmd_SetText HECmd_SetText = (tHECmd_SetText)(0x808f7f6); */
1,743
C
.c
38
43.263158
87
0.698582
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,850
nvconfig.c
haithun_CoD4X17a_testing/nvconfig.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ //Non volatile config //Changed settings will be written to / loaded from a file called nvconfig.cfg //If a nonvolatile setting is changed it is saved to that file immediately #include "q_shared.h" #include "qcommon_io.h" #include "qcommon_mem.h" #include "filesystem.h" #include "cmd.h" #include "server.h" #include "hl2rcon.h" #include <string.h> #define MAX_NVCONFIG_SIZE 2048*128 #define NV_ProcessBegin NV_LoadConfig #define NV_ProcessEnd NV_WriteConfig /* ================ NV_ParseConfigLine ================ */ qboolean NV_ParseConfigLine(char* line, int linenumber){ if(!Q_stricmp(Info_ValueForKey(line, "type") , "cmdMinPower")){ if(!Cmd_InfoSetPower( line )){ Com_DPrintf("Warning at line: %d\n", linenumber); return qtrue; //Don't rise errors here! This can happen for commands we add at a later stage } return qtrue; }else if(!Q_stricmp(Info_ValueForKey(line, "type") , "rconAdmin")){ if(!HL2Rcon_InfoAddAdmin( line )) { Com_Printf("Error at line: %d\n", linenumber); return qfalse; } return qtrue; }else if(!Q_stricmp(Info_ValueForKey(line, "type") , "admin")){ if(!SV_RemoteCmdInfoAddAdmin( line )) { Com_Printf("Error at line: %d\n", linenumber); return qfalse; } return qtrue; }else{ Com_Printf("Error: unknown type (line: %d)\n", linenumber); return qfalse; } } /* ================ NV_LoadConfig ================ */ void NV_LoadConfig(){ int read, i; int error = 0; char buf[256]; *buf = 0; fileHandle_t file; SV_RemoteCmdClearAdminList(); HL2Rcon_ClearSourceRconAdminList(); FS_SV_FOpenFileRead("nvconfig.dat", &file); if(!file){ Com_DPrintf("Couldn't open nvconfig.dat for reading\n"); return; } Com_Printf( "loading nvconfig.dat\n"); i = 0; while(qtrue){ read = FS_ReadLine(buf,sizeof(buf),file); if(read == 0){ FS_FCloseFile(file); Com_Printf("Loaded nvconfig.dat %i errors\n", error); return; } if(read == -1){ Com_Printf("Can not read from nvconfig.dat\n"); FS_FCloseFile(file); return; } i++;//linecouter if(!*buf || *buf == '/' || *buf == '\n'){ continue; } if(!NV_ParseConfigLine(buf, i)){ error++; } } } /* ================ NV_WriteConfig ================ */ void NV_WriteConfig(){ char* buffer; buffer = Hunk_AllocateTempMemory(MAX_NVCONFIG_SIZE); if(!buffer){ Com_Printf( "Error Updating NVConfig: Hunk_Alloc failed\n" ); return; } Com_Memset(buffer,0,MAX_NVCONFIG_SIZE); Q_strcat(buffer,MAX_NVCONFIG_SIZE,"//Autogenerated non volatile config settings\n"); Cmd_WritePowerConfig( buffer, MAX_NVCONFIG_SIZE ); SV_RemoteCmdWriteAdminConfig( buffer, MAX_NVCONFIG_SIZE ); HL2Rcon_WriteAdminConfig( buffer, MAX_NVCONFIG_SIZE ); FS_SV_WriteFile("nvconfig.dat", buffer, strlen(buffer)); Hunk_FreeTempMemory( buffer ); Com_DPrintf("NV-Config Updated\n"); }
4,197
C
.c
123
28.325203
104
0.610644
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,852
cmd_completion.h
haithun_CoD4X17a_testing/cmd_completion.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef __CMD_COMPLETION_H__ #define __CMD_COMPLETION_H__ #include "cvar.h" #include "cmd.h" /* ============================================================== Edit fields and command line history/completion ============================================================== */ //typedef void (*completionFunc_t)( char *args, int argNum ); #define MAX_EDIT_LINE 256 typedef struct { int cursor; int scroll; int widthInChars; char buffer[MAX_EDIT_LINE]; } field_t; void Cvar_CommandCompletionPrint( cvar_t const *cvar, void* none); void Cvar_CommandCompletionFind( cvar_t const *cvar, void* none); void Cvar_CompleteCvarName( char *args, int argNum ); void Field_Clear( field_t *edit ); void Field_CompleteCommand( char *cmd, qboolean doCommands, qboolean doCvars ); void Field_AutoComplete( field_t *field ); #endif
1,860
C
.c
41
42.560976
87
0.642976
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,381,855
misc.c
haithun_CoD4X17a_testing/misc.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "misc.h" #include "qcommon_io.h" #include "g_sv_shared.h" #include "punkbuster.h" #include "hl2rcon.h" char* SL_ConvertToString(unsigned int index) { char** ptr = (char**)STRBUFFBASEPTR_ADDR; char* base = *ptr; return &base[ index*12 + 4]; } void AddRedirectLocations() { Com_AddRedirect(PbCapatureConsoleOutput_wrapper); }
1,339
C
.c
31
39.741935
87
0.66358
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,860
g_sv_messages.c
haithun_CoD4X17a_testing/g_sv_messages.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "q_shared.h" #include "qcommon.h" #include "g_hud.h" #include "server.h" #include "qcommon_io.h" #include "g_sv_shared.h" #include <string.h> #define MAX_MESSAGES 63 #define MAX_MSGBUFF 4096 typedef struct{ char* ruleStrings[MAX_MESSAGES +1]; char* adStrings[MAX_MESSAGES +1]; char msgBuff[MAX_MSGBUFF]; }msgDisplay_t; static msgDisplay_t messages; static char motdBuff[200]; void G_DestroyMessage(game_hudelem_t* hudelem){ if(!hudelem || !hudelem->inuse) return; ucolor_t color; color.red = 255; color.green = 255; color.blue = 255; color.alpha = 0; G_HudSetFadingOverTime(hudelem, 700, color); } void G_ShowMessage(game_hudelem_t* hudelem, const char* rule, int time){ if(!hudelem || !hudelem->inuse) return; ucolor_t color; color.red = 255; color.green = 255; color.blue = 255; color.alpha = 255; G_HudSetFadingOverTime(hudelem, 700, color); G_HudSetText(hudelem, rule); Com_AddTimedEvent(time+700, G_DestroyMessage, 1, hudelem); } void G_PrintRuleForPlayer(client_t *cl){ if(cl->msgType != 1) return; char *rule = messages.ruleStrings[cl->currentAd]; if(rule == NULL){ //No looping, go to adverts cl->msgType++; return; } if(!cl->hudMsg) G_SetupHudMessagesForPlayer(cl); if(!cl->hudMsg) return; //Failure to get hudelem G_HudSetPosition(cl->hudMsg, 0, 25, HUDSCRNALIGN_CENTER, HUDSCRNALIGN_TOP, HUDALIGN_CENTER, HUDALIGN_TOP); G_HudSetFont(cl->hudMsg, 1.6, HUDFONT_DEFAULT); G_ShowMessage(cl->hudMsg, rule, 5000); cl->currentAd++; } void G_PrintAdvertForPlayer(client_t *cl){ if(cl->msgType != 2) return; char *ad = messages.adStrings[cl->currentAd]; if(ad == NULL){ if(messages.adStrings[0] == NULL){ if(cl->hudMsg) G_HudDestroy(cl->hudMsg); //Nothing to show cl->hudMsg = NULL; return; } cl->currentAd = 0; ad = messages.adStrings[cl->currentAd]; } if(!cl->hudMsg) G_SetupHudMessagesForPlayer(cl); if(!cl->hudMsg) return; //Failure to get hudelem G_HudSetPosition(cl->hudMsg, 0, 0, HUDSCRNALIGN_CENTER, HUDSCRNALIGN_TOP, HUDALIGN_CENTER, HUDALIGN_TOP); G_HudSetFont(cl->hudMsg, 1.4, HUDFONT_DEFAULT); G_ShowMessage(cl->hudMsg, ad, 8000); cl->currentAd++; } void G_SetupHudMessagesForPlayer(client_t* cl){ ucolor_t glowcolor; ucolor_t color; color.red = 255; color.green = 255; color.blue = 255; color.alpha = 0; glowcolor.red = 0; glowcolor.green = 0; glowcolor.blue = 0; glowcolor.alpha = 0; if(cl == NULL) return; if(!cl->hudMsg) cl->hudMsg = G_GetNewHudElem(cl - svs.clients); if(!cl->hudMsg) return; G_HudSetColor(cl->hudMsg, color, glowcolor); cl->hudMsg->displayoption = HUDDISPLAY_HIDEINMENU | HUDDISPLAY_FOREGROUND; cl->hudMsg->sort = 100; } void G_DestroyAdsForPlayer(client_t *cl){ if(!cl->hudMsg) return; G_HudDestroy(cl->hudMsg); cl->hudMsg = NULL; } void G_AddRule(const char* newtext){ char* textbuf = messages.msgBuff; int len; int i; int newstrlen = strlen(newtext); if(newstrlen < 3) return; //Find an empty slot to reference this string for(i = 0; i < MAX_MESSAGES; i++) { if(messages.ruleStrings[i] == NULL) break; } if(i == MAX_MESSAGES){ Com_PrintWarning("Exceeded the limit of %i rules\n", MAX_MESSAGES); return; } int j = 0; while(j < MAX_MSGBUFF) { //Is our text already there if(!Q_stricmp(newtext, textbuf)) { return; //Already an added rule } len = strlen(textbuf); if(!len) //No more added textstrings in buffer break; textbuf = &textbuf[len+1]; j += (len + 1); } if(newstrlen >= MAX_MSGBUFF - j){ Com_PrintWarning("Exceeded the maximum combined length of all advert and rules\n"); return; } //append the new text string to our buffer Q_strncpyz(textbuf, newtext, newstrlen+1); //Reference it now messages.ruleStrings[i] = textbuf; } void G_AddAdvert(const char* newtext){ char* textbuf = messages.msgBuff; int len; int i; int newstrlen = strlen(newtext); if(newstrlen < 3) return; //Find an empty slot to reference this string for(i = 0; i < MAX_MESSAGES; i++) { if(messages.adStrings[i] == NULL) break; } if(i == MAX_MESSAGES){ Com_PrintWarning("Exceeded the limit of %i adverts\n", MAX_MESSAGES); return; } int j = 0; while(j < MAX_MSGBUFF) { //Is our text already there if(!Q_stricmp(newtext, textbuf)) { return; //Already an added rule } len = strlen(textbuf); if(!len) //No more added textstrings in buffer break; textbuf = &textbuf[len+1]; j += (len + 1); } if(newstrlen >= MAX_MSGBUFF - j){ Com_PrintWarning("Exceeded the maximum combined length of all advert and rules\n"); return; } //append the new text string to our buffer Q_strncpyz(textbuf, newtext, newstrlen+1); //Reference it now messages.adStrings[i] = textbuf; } void G_InitMotd(){ const char *motd = SV_GetMessageOfTheDay(); int i = 0; int j = 0; int lSCounterI = 0; int lSCounterO = 0; int overallcount = 0; char *outputstr = motdBuff; const char *inputstr = motd; while( inputstr[i] && (overallcount+1) < sizeof(motdBuff)){ if( inputstr[i] == ' '){ /*Save the positions of the last recent wordspacer*/ lSCounterI = i; lSCounterO = j; } if(inputstr[i] == '^' && inputstr[i+1] >= '0' && inputstr[i+1] <= '9'){ i += 2; continue; }else{ outputstr[j] = inputstr[i]; } if( j >= 64){ if(lSCounterO > 40) { j = lSCounterO; i = lSCounterI; } outputstr[j] = '\n'; outputstr += j+1; inputstr += i+1; overallcount++; lSCounterO = 0; lSCounterI = 0; i = 0; j = 0; continue; } j++; i++; overallcount++; } outputstr[j] = 0; } void G_SwitchToRules(client_t *cl){ cl->msgType++; } void G_RemoveMotd(game_hudelem_t* hudelem1, game_hudelem_t* hudelem2){ G_HudSetMovingOverTime( hudelem1, 800, -800, 90); G_HudSetMovingOverTime( hudelem2, 800, 800, 90); Com_AddTimedEvent(800, G_HudDestroy, 1, hudelem1); Com_AddTimedEvent(800, G_HudDestroy, 1, hudelem2); } #define MAX_LENGTH_30 30 #define MAX_LENGTH_20 46 #define MAX_LENGTH_14 66 void G_ShowMotd(unsigned int clnum) { game_hudelem_t* hudelem1; game_hudelem_t* hudelem2; if(clnum > 63) return; client_t *cl = &svs.clients[clnum]; int len = strlen(motdBuff); float fontscale; if(len < 3){ cl->msgType++; return;//No message of the day } if(len < 30) fontscale = 3.0; else if(len < 46) fontscale = 2.0; else fontscale = 1.4; ucolor_t glowcolor; ucolor_t color; color.red = 204; color.green = 255; color.blue = 204; color.alpha = 255; glowcolor.red = 76; glowcolor.green = 153; glowcolor.blue = 76; glowcolor.alpha = 10; Com_DPrintf("Draw Message of the Day of client num: %i\n", clnum); hudelem1 = G_GetNewHudElem(clnum); if(!hudelem1) return; hudelem2 = G_GetNewHudElem(clnum); if(!hudelem2){ G_HudDestroy(hudelem1); return; } G_HudSetColor(hudelem1, color, glowcolor); G_HudSetColor(hudelem2, color, glowcolor); G_HudSetPosition(hudelem1, 800, 90, HUDSCRNALIGN_CENTER, HUDSCRNALIGN_MIDDLE, HUDALIGN_CENTER, HUDALIGN_MIDDLE); G_HudSetPosition(hudelem2, -800, 90, HUDSCRNALIGN_CENTER, HUDSCRNALIGN_MIDDLE, HUDALIGN_CENTER, HUDALIGN_MIDDLE); G_HudSetFont(hudelem1, fontscale, HUDFONT_OBJECTIVE); G_HudSetFont(hudelem2, fontscale, HUDFONT_OBJECTIVE); hudelem1->displayoption = HUDDISPLAY_HIDEINMENU | HUDDISPLAY_FOREGROUND; hudelem2->displayoption = HUDDISPLAY_HIDEINMENU | HUDDISPLAY_FOREGROUND; hudelem1->sort = 100; hudelem2->sort = 99; G_HudSetText(hudelem1, motdBuff); G_HudSetText(hudelem2, motdBuff); G_HudSetMovingOverTime(hudelem1, 800, 0, 90); G_HudSetMovingOverTime(hudelem2, 800, 0, 90); Com_AddTimedEvent(10800, G_RemoveMotd, 2, hudelem1, hudelem2); Com_AddTimedEvent(15000, G_SwitchToRules, 1, cl); } void G_ClearAllMessages() { Com_Memset(&messages, 0, sizeof(msgDisplay_t)); }
9,967
C
.c
313
25.421725
117
0.618632
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,381,861
sv_punkbuster.c
haithun_CoD4X17a_testing/sv_punkbuster.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "q_shared.h" #include "qcommon_io.h" #include "cvar.h" #include "sys_net.h" #include "server.h" #include "g_shared.h" #include "punkbuster.h" #include <string.h> #include <stdlib.h> #ifndef MAX_PACKETLEN #define MAX_PACKETLEN 1400 #endif /*********************************************************************************************/ // Mandatory functions for PunkBuster operation /*********************************************************************************************/ __cdecl int PbSvSendToAddrPort(char* netdest, unsigned short port, int msgsize, char* message){ char *sourcemsg; char msg[256]; netadr_t netadr; __asm("leal -0x836(,%%ebp,1), %%eax\n\t" :"=a"(sourcemsg)); if(!Q_strncmp(sourcemsg, "PunkBuster Server:", 18)){ Q_strncpyz(msg, sourcemsg, sizeof(msg)); if(strstr(msg,"NoGUID*")) //Prevent telling about Players without GUIDs to streaming-servers return 0; } NET_StringToAdr(va("%s:%i", netdest, port), &netadr, NA_UNSPEC); netadr.sock = 0; netadr_t *sockadr; if((sockadr = NET_GetDefaultCommunicationSocket()) != NULL) netadr.sock = sockadr->sock; NET_SendPacket(NS_SERVER, msgsize, message, &netadr); return 0; } __cdecl int PbSvSendToClient(int msgsize, char* message, int clientnum){ client_t *cl; cl = &svs.clients[clientnum]; if(cl->state >= CS_CONNECTED){ byte string[MAX_PACKETLEN]; int i; // set the OutOfBand header string[0] = 0xff; string[1] = 0xff; string[2] = 0xff; string[3] = 0xff; if(msgsize + 4 > MAX_PACKETLEN){ Com_PrintWarning("Buffer Overflow in NET_OutOfBandData %i bytes\n", msgsize); return 0; } for ( i = 0; i < msgsize ; i++ ) { string[i+4] = message[i]; } NET_SendPacket( NS_SERVER, i+4, string, &cl->netchan.remoteAddress ); } return 0; } __cdecl char* PbSvGameQuery(int para_01, char* string){ int maxclients; client_t *cl; gclient_t *gclient; string[255] = 0; int var_01; if(!string) return NULL; switch(para_01){ case 0x65: maxclients = sv_maxclients->integer; if(!maxclients) return 0; *string = 0x30; Com_sprintf(string, 255, "%i", maxclients); return 0; case 0x66: maxclients = sv_maxclients->integer; var_01 = atoi(string); Com_Memset(string, 0, 0x68); if(var_01 < 0 || var_01 > maxclients) return "PB_Error: Query Failed"; cl = &svs.clients[var_01]; if(cl->state < CS_ACTIVE || cl->noPb == qtrue) return "PB_Error: Query Failed"; Q_strncpyz(string, cl->name, 254); Q_strncpyz(&string[33], cl->pbguid, 221); Q_strncpyz(&string[66], NET_AdrToString(&cl->netchan.remoteAddress), 188); return NULL; case 0x67: Q_strncpyz(string, Cvar_GetVariantString(string),255); return NULL; case 0x72: maxclients = sv_maxclients->integer; *string = 0; var_01 = atoi(string); if(var_01 < 0 || var_01 > maxclients) return "PB_Error: Query Failed";; cl = &svs.clients[var_01]; gclient = &level.clients[para_01]; if(cl->state < CS_ACTIVE || cl->noPb) return "PB_Error: Query Failed";; Com_sprintf(string,255,"ping=%d score=%d", cl->ping, gclient->pers.scoreboard.score); return NULL; default: return NULL; } } void PbCapatureConsoleOutput_wrapper(const char *msg, int msglen) { PbCapatureConsoleOutput(msg, 4096); }
4,508
C
.c
117
33.162393
101
0.609386
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,862
scr_vm_main.c
haithun_CoD4X17a_testing/scr_vm_main.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "q_shared.h" #include "scr_vm.h" #include "scr_vm_functions.h" #include "qcommon_io.h" #include "cvar.h" #include "misc.h" typedef struct{ char* name; xfunction_t offset; qboolean developer; }v_function_t; #define G_SCR_DATA_ADDR (void*)0x8583ba0 void Scr_AddStockFunctions(){ Scr_AddFunction("createprintchannel", (void*)0x80bf832, 0); Scr_AddFunction("setprintchannel", (void*)0x80bf75c, 0); Scr_AddFunction("print", (void*)0x80bf706, 0); Scr_AddFunction("println", (void*)0x80c267e, 1); Scr_AddFunction("iprintln", (void*)0x80c2b8a, 0); Scr_AddFunction("iprintlnbold", (void*)0x80c2c14, 0); Scr_AddFunction("print3d", (void*)0x80c0c7e, 0); Scr_AddFunction("line", (void*)0x80bac00, 1); Scr_AddFunction("logstring", (void*)0x80bac06, 0); Scr_AddFunction("getent", (void*)0x80c7c72, 0); Scr_AddFunction("getentarray", (void*)0x80c7b44, 0); Scr_AddFunction("spawn", (void*)0x80bf638, 0); Scr_AddFunction("spawnplane", (void*)0x80c0fde, 0); Scr_AddFunction("spawnturret", (void*)0x80c0f52, 0); Scr_AddFunction("precacheturret", (void*)0x80bcd46, 0); Scr_AddFunction("spawnstruct", (void*)0x815f09a, 0); Scr_AddFunction("spawnhelicopter", (void*)0x80c0e54, 0); Scr_AddFunction("assert", (void*)0x80bb0fc, 1); Scr_AddFunction("assertex", (void*)0x80bb2e0, 1); Scr_AddFunction("assertmsg", (void*)0x80bb2b4, 1); Scr_AddFunction("isdefined", (void*)0x80bbf2c, 0); Scr_AddFunction("isstring", (void*)0x80bbf06, 0); Scr_AddFunction("isalive", (void*)0x80bbeaa, 0); Scr_AddFunction("getdvar", (void*)0x80bf5ec, 0); Scr_AddFunction("getdvarint", (void*)0x80bf5a8, 0); Scr_AddFunction("getdvarfloat", (void*)0x80bf56c, 0); Scr_AddFunction("setdvar", (void*)0x80c07ce, 0); Scr_AddFunction("gettime", (void*)0x80bb514, 0); Scr_AddFunction("getentbynum", (void*)0x80bbf96, 0); Scr_AddFunction("getweaponmodel", (void*)0x80bf490, 0); Scr_AddFunction("getanimlength", (void*)0x80bf416, 0); Scr_AddFunction("animhasnotetrack", (void*)0x80bf3aa, 0); Scr_AddFunction("getnotetracktimes", (void*)0x80bf346, 0); Scr_AddFunction("getbrushmodelcenter", (void*)0x80c199a, 0); Scr_AddFunction("objective_add", (void*)0x80c2234, 0); Scr_AddFunction("objective_delete", (void*)0x80c1da4, 0); Scr_AddFunction("objective_state", (void*)0x80c210a, 0); Scr_AddFunction("objective_icon", (void*)0x80be226, 0); Scr_AddFunction("objective_position", (void*)0x80c17ca, 0); Scr_AddFunction("objective_onentity", (void*)0x80c1716, 0); Scr_AddFunction("objective_current", (void*)0x80bef76, 0); Scr_AddFunction("missile_createattractorent", (void*)0x8093486, 0); Scr_AddFunction("missile_createattractororigin", (void*)0x8096c28, 0); Scr_AddFunction("missile_createrepulsorent", (void*)0x8096b5c, 0); Scr_AddFunction("missile_createrepulsororigin", (void*)0x8096a80, 0); Scr_AddFunction("missile_deleteattractor", (void*)0x80933b0, 0); Scr_AddFunction("bullettrace", (void*)0x80c65fa, 0); Scr_AddFunction("bullettracepassed", (void*)0x80bee92, 0); Scr_AddFunction("sighttracepassed", (void*)0x80c0198, 0); Scr_AddFunction("physicstrace", (void*)0x80be7b2, 0); Scr_AddFunction("playerphysicstrace", (void*)0x80c1e6a, 0); Scr_AddFunction("getmovedelta", (void*)0x80bec78, 0); Scr_AddFunction("getangledelta", (void*)0x80bed82, 0); Scr_AddFunction("getnorthyaw", (void*)0x80c1f0e, 0); Scr_AddFunction("randomint", (void*)0x80bec22, 0); Scr_AddFunction("randomfloat", (void*)0x80beb8a, 0); Scr_AddFunction("randomintrange", (void*)0x80bebb6, 0); Scr_AddFunction("randomfloatrange", (void*)0x80beb12, 0); Scr_AddFunction("sin", (void*)0x80beae6, 0); Scr_AddFunction("cos", (void*)0x80beaba, 0); Scr_AddFunction("tan", (void*)0x80bda00, 0); Scr_AddFunction("asin", (void*)0x80bea50, 0); Scr_AddFunction("acos", (void*)0x80be9e6, 0); Scr_AddFunction("atan", (void*)0x80be9ba, 0); Scr_AddFunction("int", (void*)0x80c1f56, 0); Scr_AddFunction("abs", (void*)0x80bd9e2, 0); Scr_AddFunction("min", (void*)0x80bd9a2, 0); Scr_AddFunction("max", (void*)0x80bd962, 0); Scr_AddFunction("floor", (void*)0x80bd92c, 0); Scr_AddFunction("ceil", (void*)0x80bd8f6, 0); Scr_AddFunction("sqrt", (void*)0x80be97e, 0); Scr_AddFunction("vectorfromlinetopoint", (void*)0x80c19fc, 0); Scr_AddFunction("pointonsegmentnearesttopoint", (void*)0x80c1c58, 0); Scr_AddFunction("distance", (void*)0x80c23dc, 0); Scr_AddFunction("distance2d", (void*)0x80be934, 0); Scr_AddFunction("distancesquared", (void*)0x80c2016, 0); Scr_AddFunction("length", (void*)0x80bde88, 0); Scr_AddFunction("lengthsquared", (void*)0x80c1c1c, 0); Scr_AddFunction("closer", (void*)0x80c206e, 0); Scr_AddFunction("vectordot", (void*)0x80c1bca, 0); Scr_AddFunction("vectornormalize", (void*)0x80c69aa, 0); Scr_AddFunction("vectortoangles", (void*)0x80be762, 0); Scr_AddFunction("vectorlerp", (void*)0x80be6da, 0); Scr_AddFunction("anglestoup", (void*)0x80be8ea, 0); Scr_AddFunction("anglestoright", (void*)0x80be8a0, 0); Scr_AddFunction("anglestoforward", (void*)0x80be856, 0); Scr_AddFunction("combineangles", (void*)0x80be652, 0); Scr_AddFunction("issubstr", (void*)0x80be60e, 0); Scr_AddFunction("getsubstr", (void*)0x80bb1de, 0); Scr_AddFunction("tolower", (void*)0x80be59c, 0); Scr_AddFunction("strtok", (void*)0x80be3d0, 0); Scr_AddFunction("musicplay", (void*)0x80bbe0c, 0); Scr_AddFunction("musicstop", (void*)0x80c1642, 0); Scr_AddFunction("soundfade", (void*)0x80bbd94, 0); Scr_AddFunction("ambientplay", (void*)0x80c1536, 0); Scr_AddFunction("ambientstop", (void*)0x80c146c, 0); Scr_AddFunction("precachemodel", (void*)0x80be37c, 0); Scr_AddFunction("precacheshellshock", (void*)0x80be308, 0); Scr_AddFunction("precacheitem", (void*)0x80be28a, 0); Scr_AddFunction("precacheshader", (void*)0x80be126, 0); Scr_AddFunction("precachestring", (void*)0x80be0ea, 0); Scr_AddFunction("precacherumble", (void*)0x80bb010, 0); Scr_AddFunction("loadfx", (void*)0x80be064, 0); Scr_AddFunction("playfx", (void*)0x80c6a38, 0); Scr_AddFunction("playfxontag", (void*)0x80bdec6, 0); Scr_AddFunction("playloopedfx", (void*)0x80c6fe8, 0); Scr_AddFunction("spawnfx", (void*)0x80c6d1e, 0); Scr_AddFunction("triggerfx", (void*)0x80c13b0, 0); Scr_AddFunction("physicsexplosionsphere", (void*)0x80bd00e, 0); Scr_AddFunction("physicsexplosioncylinder", (void*)0x80bcd78, 0); Scr_AddFunction("physicsjolt", (void*)0x80bcf16, 0); Scr_AddFunction("physicsjitter", (void*)0x80bce34, 0); Scr_AddFunction("setexpfog", (void*)0x80bdc1e, 0); Scr_AddFunction("grenadeexplosioneffect", (void*)0x80c0d86, 0); Scr_AddFunction("radiusdamage", (void*)0x80bdc12, 0); Scr_AddFunction("setplayerignoreradiusdamage", (void*)0x80bb0e2, 0); Scr_AddFunction("getnumparts", (void*)0x80c00d8, 0); Scr_AddFunction("getpartname", (void*)0x80c0104, 0); Scr_AddFunction("earthquake", (void*)0x80c112e, 0); Scr_AddFunction("newhudelem", GScr_NewHudElem, 0); Scr_AddFunction("newclienthudelem", GScr_NewClientHudElem, 0); Scr_AddFunction("newteamhudelem", (void*)0x808f95e, 0); Scr_AddFunction("resettimeout", (void*)0x815d050, 0); Scr_AddFunction("weaponfiretime", (void*)0x80bda62, 0); Scr_AddFunction("isweaponcliponly", (void*)0x80bd8b8, 0); Scr_AddFunction("isweapondetonationtimed", (void*)0x80bd59e, 0); Scr_AddFunction("weaponclipsize", (void*)0x80bd710, 0); Scr_AddFunction("weaponissemiauto", (void*)0x80bd6c0, 0); Scr_AddFunction("weaponisboltaction", (void*)0x80bd676, 0); Scr_AddFunction("weapontype", (void*)0x80bd866, 0); Scr_AddFunction("weaponclass", (void*)0x80bd81a, 0); Scr_AddFunction("weaponinventorytype", (void*)0x80bd7c8, 0); Scr_AddFunction("weaponstartammo", (void*)0x80bd62c, 0); Scr_AddFunction("weaponmaxammo", (void*)0x80bd5e2, 0); Scr_AddFunction("weaponaltweaponname", (void*)0x80bd75a, 0); Scr_AddFunction("isplayer", (void*)0x80bbe50, 0); Scr_AddFunction("isplayernumber", (void*)0x80bb4b6, 0); Scr_AddFunction("setwinningplayer", (void*)0x80bd504, 0); Scr_AddFunction("setwinningteam", (void*)0x80bd412, 0); Scr_AddFunction("announcement", (void*)0x80c0758, 0); Scr_AddFunction("clientannouncement", (void*)0x80c06d4, 0); Scr_AddFunction("getteamscore", (void*)0x80bbac0, 0); Scr_AddFunction("setteamscore", (void*)0x80bbcdc, 0); Scr_AddFunction("setclientnamemode", (void*)0x80bb88e, 0); Scr_AddFunction("updateclientnames", (void*)0x80bd356, 0); Scr_AddFunction("getteamplayersalive", (void*)0x80bb9f8, 0); Scr_AddFunction("objective_team", (void*)0x80bbb3a, 0); Scr_AddFunction("logprint", (void*)0x80bd1ac, 0); Scr_AddFunction("worldentnumber", (void*)0x80bb500, 0); Scr_AddFunction("obituary", (void*)0x80bd0ca, 0); Scr_AddFunction("positionwouldtelefrag", (void*)0x80c18a6, 0); Scr_AddFunction("getstarttime", (void*)0x80bb4ea, 0); Scr_AddFunction("precachemenu", (void*)0x80bcc4e, 0); Scr_AddFunction("precachestatusicon", (void*)0x80bc932, 0); Scr_AddFunction("precacheheadicon", (void*)0x80bc614, 0); Scr_AddFunction("precachelocationselector", (void*)0x80bc4a6, 0); Scr_AddFunction("map_restart", (void*)0x80bb6d2, 0); Scr_AddFunction("exitlevel", (void*)0x80bbfe2, 0); Scr_AddFunction("addtestclient", GScr_SpawnBot, 0); Scr_AddFunction("removetestclient", GScr_RemoveBot, 0); Scr_AddFunction("removealltestclients", GScr_RemoveAllBots, 0); Scr_AddFunction("makedvarserverinfo", (void*)0x80c05bc, 0); Scr_AddFunction("setarchive", (void*)0x80bb034, 0); Scr_AddFunction("allclientsprint", (void*)0x80bbc8c, 0); Scr_AddFunction("clientprint", (void*)0x80bbc20, 0); Scr_AddFunction("mapexists", (void*)0x80bb556, 0); Scr_AddFunction("isvalidgametype", (void*)0x80c25f8, 0); Scr_AddFunction("matchend", (void*)0x80bb04c, 0); Scr_AddFunction("setplayerteamrank", (void*)0x80bb052, 0); Scr_AddFunction("sendranks", (void*)0x80bb058, 0); Scr_AddFunction("endparty", (void*)0x80bb05e, 0); Scr_AddFunction("setteamradar", (void*)0x80bb958, 0); Scr_AddFunction("getteamradar", (void*)0x80bb8d8, 0); Scr_AddFunction("getassignedteam", (void*)0x80bb48e, 0); Scr_AddFunction("setvotestring", (void*)0x80bb7e0, 0); Scr_AddFunction("setvotetime", (void*)0x80bb73e, 0); Scr_AddFunction("setvoteyescount", (void*)0x80bb360, 0); Scr_AddFunction("setvotenocount", (void*)0x80bb320, 0); Scr_AddFunction("openfile", GScr_FS_FOpen, 0); Scr_AddFunction("closefile", GScr_FS_FClose, 0); Scr_AddFunction("fprintln", GScr_FS_WriteLine, 0); Scr_AddFunction("fprintfields", (void*)0x80c1c16, 1); Scr_AddFunction("freadln", GScr_FS_ReadLine, 0); Scr_AddFunction("fgetarg", (void*)0x80bb02e, 1); Scr_AddFunction("kick", GScr_KickClient, 0); Scr_AddFunction("ban", GScr_BanClient, 0); Scr_AddFunction("map", (void*)0x80bb628, 0); Scr_AddFunction("playrumbleonposition", (void*)0x80bb03a, 0); Scr_AddFunction("playrumblelooponposition", (void*)0x80bb040, 0); Scr_AddFunction("stopallrumbles", (void*)0x80bb046, 0); Scr_AddFunction("soundexists", (void*)0x80bb52a, 0); Scr_AddFunction("issplitscreen", (void*)0x80bb4a2, 0); Scr_AddFunction("setminimap", (void*)0x80c2436, 0); Scr_AddFunction("setmapcenter", (void*)0x80bb450, 0); Scr_AddFunction("setgameendtime", (void*)0x80bb41e, 0); Scr_AddFunction("getarraykeys", (void*)0x80bb3c4, 0); Scr_AddFunction("searchforonlinegames", (void*)0x80bb06a, 0); Scr_AddFunction("quitlobby", (void*)0x80bb070, 0); Scr_AddFunction("quitparty", (void*)0x80bb076, 0); Scr_AddFunction("startparty", (void*)0x80bb07c, 0); Scr_AddFunction("startprivatematch", (void*)0x80bb082, 0); Scr_AddFunction("visionsetnaked", (void*)0x80c12f8, 0); Scr_AddFunction("visionsetnight", (void*)0x80c1240, 0); Scr_AddFunction("tablelookup", (void*)0x80bb122, 0); Scr_AddFunction("tablelookupistring", (void*)0x80c1b0e, 0); Scr_AddFunction("endlobby", (void*)0x80bb088, 0); Scr_AddFunction("fs_fopen", GScr_FS_FOpen, 0); Scr_AddFunction("fs_fclose", GScr_FS_FClose, 0); Scr_AddFunction("fs_fcloseall", GScr_FS_FCloseAll, 0); Scr_AddFunction("fs_testfile", GScr_FS_TestFile, 0); Scr_AddFunction("fs_readline", GScr_FS_ReadLine, 0); Scr_AddFunction("fs_writeline", GScr_FS_WriteLine, 0); Scr_AddFunction("fs_remove", GScr_FS_Remove, 0); Scr_AddFunction("getrealtime", GScr_GetRealTime, 0); Scr_AddFunction("timetostring", GScr_TimeToString, 0); Scr_AddFunction("strtokbypixlen", GScr_StrTokByPixLen, 0); Scr_AddFunction("strpixlen", GScr_StrPixLen, 0); Scr_AddFunction("strcolorstrip", GScr_StrColorStrip, 0); Scr_AddFunction("copystr", GScr_CopyString, 0); Scr_AddFunction("strrepl", GScr_StrRepl, 0); Scr_AddFunction("strtokbylen", GScr_StrTokByLen, 0); Scr_AddFunction("exec", GScr_CbufAddText, 0); Scr_AddFunction("sha256", GScr_SHA256, 0); } void Scr_AddStockMethods(){ //PlayerCmd Scr_AddMethod("giveweapon", (void*)0x80abc48, 0); Scr_AddMethod("takeweapon", (void*)0x80abbb4, 0); Scr_AddMethod("takeallweapons", (void*)0x80abb0e, 0); Scr_AddMethod("getcurrentweapon", (void*)0x80ad386, 0); Scr_AddMethod("getcurrentoffhand", (void*)0x80aa3f2, 0); Scr_AddMethod("hasweapon", (void*)0x80a9098, 0); Scr_AddMethod("switchtoweapon", (void*)0x80ac484, 0); Scr_AddMethod("switchtooffhand", (void*)0x80ac37a, 0); Scr_AddMethod("givestartammo", (void*)0x80ac2b4, 0); Scr_AddMethod("givemaxammo", (void*)0x80ac1a4, 0); Scr_AddMethod("getfractionstartammo", (void*)0x80ac09c, 0); Scr_AddMethod("getfractionmaxammo", (void*)0x80abf94, 0); Scr_AddMethod("setorigin", (void*)0x80ace3e, 0); Scr_AddMethod("getvelocity", (void*)0x80ab73a, 0); Scr_AddMethod("setplayerangles", (void*)0x80ab7b0, 0); Scr_AddMethod("getplayerangles", (void*)0x80ab6c2, 0); Scr_AddMethod("usebuttonpressed", (void*)0x80a9b46, 0); Scr_AddMethod("attackbuttonpressed", (void*)0x80a9aae, 0); Scr_AddMethod("adsbuttonpressed", (void*)0x80a9a14, 0); Scr_AddMethod("meleebuttonpressed", (void*)0x80a997c, 0); Scr_AddMethod("fragbuttonpressed", (void*)0x80a98e2, 0); Scr_AddMethod("secondaryoffhandbuttonpressed", (void*)0x80a9848, 0); Scr_AddMethod("playerads", (void*)0x80ab916, 0); Scr_AddMethod("isonground", (void*)0x80a979a, 0); Scr_AddMethod("pingplayer", (void*)0x80a8810, 0); Scr_AddMethod("setviewmodel", (void*)0x80ab61a, 0); Scr_AddMethod("getviewmodel", (void*)0x80ab4f4, 0); Scr_AddMethod("setoffhandsecondaryclass", (void*)0x80a9610, 0); Scr_AddMethod("getoffhandsecondaryclass", (void*)0x80ab576, 0); Scr_AddMethod("beginlocationselection", (void*)0x80ab366, 0); Scr_AddMethod("endlocationselection", (void*)0x80a86b2, 0); Scr_AddMethod("buttonpressed", (void*)0x80a9838, 0); Scr_AddMethod("sayall", (void*)0x80ab296, 0); Scr_AddMethod("sayteam", (void*)0x80ab1c6, 0); Scr_AddMethod("showscoreboard", (void*)0x80ab142, 0); Scr_AddMethod("setspawnweapon", (void*)0x80ab052, 0); Scr_AddMethod("dropitem", (void*)0x80aaf2a, 0); Scr_AddMethod("finishplayerdamage", (void*)0x80ac58e, 0); Scr_AddMethod("suicide", (void*)0x80aae5c, 0); Scr_AddMethod("openmenu", (void*)0x80aad5c, 0); Scr_AddMethod("openmenunomouse", (void*)0x80aac5c, 0); Scr_AddMethod("closemenu", (void*)0x80a8ffa, 0); Scr_AddMethod("closeingamemenu", (void*)0x80a8f5c, 0); Scr_AddMethod("freezecontrols", (void*)0x80a89c8, 0); Scr_AddMethod("disableweapons", (void*)0x80a879c, 0); Scr_AddMethod("enableweapons", (void*)0x80a8728, 0); Scr_AddMethod("setreverb", (void*)0x80aa95e, 0); Scr_AddMethod("deactivatereverb", (void*)0x80aa848, 0); Scr_AddMethod("setchannelvolumes", (void*)0x80aaafe, 0); Scr_AddMethod("deactivatechannelvolumes", (void*)0x80aa726, 0); Scr_AddMethod("setweaponammoclip", (void*)0x80aa540, 0); Scr_AddMethod("setweaponammostock", (void*)0x80ad248, 0); Scr_AddMethod("getweaponammoclip", (void*)0x80aa494, 0); Scr_AddMethod("getweaponammostock", (void*)0x80aa638, 0); Scr_AddMethod("anyammoforweaponmodes", (void*)0x80aa2f8, 0); Scr_AddMethod("iprintln", (void*)0x80aa262, 0); Scr_AddMethod("iprintlnbold", (void*)0x80aa1cc, 0); Scr_AddMethod("spawn", PlayerCmd_spawn, 0); Scr_AddMethod("setentertime", (void*)0x80a8a46, 0); Scr_AddMethod("cloneplayer", (void*)0x80acf50, 0); Scr_AddMethod("setclientdvar", (void*)0x80a9f74, 0); Scr_AddMethod("setclientdvars", (void*)0x80a9d56, 0); Scr_AddMethod("playlocalsound", (void*)0x80a9c9a, 0); Scr_AddMethod("stoplocalsound", (void*)0x80a9bde, 0); Scr_AddMethod("istalking", (void*)0x80a96f8, 0); Scr_AddMethod("allowspectateteam", (void*)0x80a9518, 0); Scr_AddMethod("getguid", (void*)0x80a9492, 0); Scr_AddMethod("getuid", PlayerCmd_GetUid, 0); Scr_AddMethod("getxuid", (void*)0x80a9418, 0); Scr_AddMethod("allowads", (void*)0x80ab852, 0); Scr_AddMethod("allowjump", (void*)0x80a8932, 0); Scr_AddMethod("allowsprint", (void*)0x80a889c, 0); Scr_AddMethod("setspreadoverride", (void*)0x80a9318, 0); Scr_AddMethod("resetspreadoverride", (void*)0x80a8bbe, 0); Scr_AddMethod("setactionslot", (void*)0x80a9156, 0); Scr_AddMethod("getweaponslist", (void*)0x80abeba, 0); Scr_AddMethod("getweaponslistprimaries", (void*)0x80abdd0, 0); Scr_AddMethod("setperk", (void*)0x80ad4ae, 0); Scr_AddMethod("hasperk", (void*)0x80ad576, 0); Scr_AddMethod("clearperks", (void*)0x80ad428, 0); Scr_AddMethod("unsetperk", (void*)0x80ad634, 0); Scr_AddMethod("updatescores", (void*)0x80a8e50, 0); Scr_AddMethod("updatedmscores", (void*)0x80a8c5e, 0); Scr_AddMethod("setrank", (void*)0x80a8ac4, 0); Scr_AddMethod("getuserinfo", PlayerCmd_GetUserinfo, 0); Scr_AddMethod("getping", PlayerCmd_GetPing, 0); //HUD Functions Scr_AddMethod("settext", HECmd_SetText, 0); Scr_AddMethod("clearalltextafterhudelem", (void*)0x808f768, 0); Scr_AddMethod("setshader", (void*)0x808e52e, 0); Scr_AddMethod("settargetent", (void*)0x808f8ea, 0); Scr_AddMethod("cleartargetent", (void*)0x808f718, 0); Scr_AddMethod("settimer", (void*)0x808f702, 0); Scr_AddMethod("settimerup", (void*)0x808f6ec, 0); Scr_AddMethod("settenthstimer", (void*)0x808f6d6, 0); Scr_AddMethod("settenthstimerup", (void*)0x808f6c0, 0); Scr_AddMethod("setclock", (void*)0x808f53e, 0); Scr_AddMethod("setclockup", (void*)0x808f528, 0); Scr_AddMethod("setvalue", (void*)0x808f1ac, 0); Scr_AddMethod("setwaypoint", (void*)0x808f116, 0); Scr_AddMethod("fadeovertime", (void*)0x808efe6, 0); Scr_AddMethod("scaleovertime", (void*)0x808ee86, 0); Scr_AddMethod("moveovertime", (void*)0x808ed56, 0); Scr_AddMethod("reset", (void*)0x808ebfa, 0); Scr_AddMethod("destroy", (void*)0x808eba6, 0); Scr_AddMethod("setpulsefx", (void*)0x808feb8, 0); Scr_AddMethod("setplayernamestring", (void*)0x808ea9e, 0); Scr_AddMethod("setmapnamestring", (void*)0x808e85a, 0); Scr_AddMethod("setgametypestring", (void*)0x808e976, 0); //Scr Cmd Functions Scr_AddMethod("attach", (void*)0x80c4360, 0); Scr_AddMethod("detach", (void*)0x80c3950, 0); Scr_AddMethod("detachall", (void*)0x80c3904, 0); Scr_AddMethod("getattachsize", (void*)0x80c38a8, 0); Scr_AddMethod("getattachmodelname", (void*)0x80c381a, 0); Scr_AddMethod("getattachtagname", (void*)0x80c3794, 0); Scr_AddMethod("getattachignorecollision", (void*)0x80c3702, 0); Scr_AddMethod("getammocount", (void*)0x80c4c3c, 0); Scr_AddMethod("getclanid", (void*)0x80bb2a4, 0); Scr_AddMethod("getclanname", (void*)0x80bb294, 0); Scr_AddMethod("hidepart", (void*)0x80c356e, 0); Scr_AddMethod("showpart", (void*)0x80c33d8, 0); Scr_AddMethod("showallparts", (void*)0x80c331c, 0); Scr_AddMethod("linkto", (void*)0x80c30a6, 0); Scr_AddMethod("unlink", (void*)0x80c305a, 0); Scr_AddMethod("enablelinkto", (void*)0x80c2fb8, 0); Scr_AddMethod("getorigin", (void*)0x80c2f54, 0); Scr_AddMethod("geteye", (void*)0x80c2eea, 0); Scr_AddMethod("useby", (void*)0x80c2e52, 0); Scr_AddMethod("setstablemissile", (void*)0x80c2c9e, 0); Scr_AddMethod("istouching", (void*)0x80c2d22, 0); Scr_AddMethod("playsound", (void*)0x80c6548, 0); Scr_AddMethod("playsoundasmaster", (void*)0x80c3e2a, 0); Scr_AddMethod("playsoundtoteam", (void*)0x80c3edc, 0); Scr_AddMethod("playsoundtoplayer", (void*)0x80c26ea, 0); Scr_AddMethod("playloopsound", (void*)0x80c3dc0, 0); Scr_AddMethod("stoploopsound", (void*)0x80c3d68, 0); Scr_AddMethod("playrumbleonentity", (void*)0x80bac12, 0); Scr_AddMethod("playrumblelooponentity", (void*)0x80bac18, 0); Scr_AddMethod("stoprumble", (void*)0x80bac1e, 0); Scr_AddMethod("delete", (void*)0x80c3cd6, 0); Scr_AddMethod("setmodel", (void*)0x80c3c6c, 0); Scr_AddMethod("getnormalhealth", (void*)0x80c3bea, 0); Scr_AddMethod("setnormalhealth", (void*)0x80c3aa2, 0); Scr_AddMethod("show", (void*)0x80c418e, 0); Scr_AddMethod("hide", (void*)0x80c4138, 0); Scr_AddMethod("laseron", (void*)0x80c40ec, 0); Scr_AddMethod("laseroff", (void*)0x80c40a0, 0); Scr_AddMethod("showtoplayer", (void*)0x80c4252, 0); Scr_AddMethod("setcontents", (void*)0x80c41e4, 0); Scr_AddMethod("getstance", (void*)0x80c42d2, 0); // Scr_AddMethod("setstance", ScrCmd_SetStance, 0); Scr_AddMethod("setjumpheight", PlayerCmd_SetJumpHeight, 0); Scr_AddMethod("setgravity", PlayerCmd_SetGravity, 0); Scr_AddMethod("setmovespeed", PlayerCmd_SetMoveSpeed, 0); Scr_AddMethod("setcursorhint", (void*)0x80c6348, 0); Scr_AddMethod("sethintstring", (void*)0x80c619e, 0); Scr_AddMethod("usetriggerrequirelookat", (void*)0x80c613a, 0); Scr_AddMethod("shellshock", (void*)0x80c4a36, 0); Scr_AddMethod("gettagorigin", (void*)0x80c5c12, 0); Scr_AddMethod("gettagangles", (void*)0x80c5b94, 0); Scr_AddMethod("stopshellshock", (void*)0x80c49cc, 0); Scr_AddMethod("setdepthoffield", (void*)0x80c46f6, 0); Scr_AddMethod("setviewmodeldepthoffield", (void*)0x80c4636, 0); Scr_AddMethod("viewkick", (void*)0x80c455c, 0); Scr_AddMethod("localtoworldcoords", (void*)0x80c5aac, 0); Scr_AddMethod("setrightarc", (void*)0x80c5a32, 0); Scr_AddMethod("setleftarc", (void*)0x80c59ba, 0); Scr_AddMethod("settoparc", (void*)0x80c5940, 0); Scr_AddMethod("setbottomarc", (void*)0x80c58c8, 0); Scr_AddMethod("radiusdamage", (void*)0x80c5e32, 0); Scr_AddMethod("detonate", (void*)0x80c5d46, 0); Scr_AddMethod("damageconetrace", (void*)0x80c5d34, 0); Scr_AddMethod("sightconetrace", (void*)0x80c5d22, 0); Scr_AddMethod("getentitynumber", (void*)0x80c60ea, 0); Scr_AddMethod("enablegrenadetouchdamage", (void*)0x80c6082, 0); Scr_AddMethod("disablegrenadetouchdamage", (void*)0x80c601a, 0); Scr_AddMethod("enableaimassist", (void*)0x80c5ed6, 0); Scr_AddMethod("disableaimassist", (void*)0x80c5e78, 0); Scr_AddMethod("placespawnpoint", (void*)0x80c56c6, 0); Scr_AddMethod("setteamfortrigger", (void*)0x80c534a, 0); Scr_AddMethod("clientclaimtrigger", (void*)0x80c5246, 0); Scr_AddMethod("clientreleasetrigger", (void*)0x80c515a, 0); Scr_AddMethod("releaseclaimedtrigger", (void*)0x80c50b8, 0); Scr_AddMethod("getstat", (void*)0x80c55f6, 0); Scr_AddMethod("setstat", (void*)0x80c5490, 0); Scr_AddMethod("sendleaderboards", (void*)0x80bb064, 0); Scr_AddMethod("setmovespeedscale", (void*)0x80c4c0e, 0); Scr_AddMethod("logstring", (void*)0x80bac0c, 0); Scr_AddMethod("missile_settarget", (void*)0x80c5f34, 0); Scr_AddMethod("isonladder", (void*)0x80c5040, 0); Scr_AddMethod("ismantling", (void*)0x80c4fc8, 0); Scr_AddMethod("startragdoll", (void*)0x80c4f08, 0); Scr_AddMethod("isragdoll", (void*)0x80c4eb4, 0); Scr_AddMethod("getcorpseanim", (void*)0x80c4dfc, 0); Scr_AddMethod("itemweaponsetammo", (void*)0x80c4c96, 0); //Scr Ent Functions Scr_AddMethod("moveto", (void*)0x809b606, 0); Scr_AddMethod("movex", (void*)0x809abf2, 0); Scr_AddMethod("movey", (void*)0x809abd6, 0); Scr_AddMethod("movez", (void*)0x809abba, 0); Scr_AddMethod("movegravity", (void*)0x809ae2a, 0); Scr_AddMethod("rotateto", (void*)0x809a85e, 0); Scr_AddMethod("rotatepitch", (void*)0x809b8c6, 0); Scr_AddMethod("rotateyaw", (void*)0x809b8aa, 0); Scr_AddMethod("rotateroll", (void*)0x809b88e, 0); Scr_AddMethod("devaddpitch", (void*)0x8099f60, 0); Scr_AddMethod("devaddyaw", (void*)0x8099f66, 0); Scr_AddMethod("devaddroll", (void*)0x8099f6c, 0); Scr_AddMethod("vibrate", (void*)0x809bad0, 0); Scr_AddMethod("rotatevelocity", (void*)0x809b178, 0); Scr_AddMethod("solid", (void*)0x809a0ac, 0); Scr_AddMethod("notsolid", (void*)0x8099fd2, 0); Scr_AddMethod("setcandamage", (void*)0x809a19e, 0); Scr_AddMethod("physicslaunch", (void*)0x809afb4, 0); //Helicopter Functions Scr_AddMethod("freehelicopter", (void*)0x80ba8bc, 0); Scr_AddMethod("setspeed", (void*)0x809d096, 0); Scr_AddMethod("getspeed", (void*)0x809d070, 0); Scr_AddMethod("getspeedmph", (void*)0x809d044, 0); Scr_AddMethod("resumespeed", (void*)0x809cf4a, 0); Scr_AddMethod("setyawspeed", (void*)0x809ce22, 0); Scr_AddMethod("setmaxpitchroll", (void*)0x809cd6c, 0); Scr_AddMethod("setturningability", (void*)0x809d0ae, 0); Scr_AddMethod("setairresistance", (void*)0x809cd36, 0); Scr_AddMethod("sethoverparams", (void*)0x809cc24, 0); Scr_AddMethod("setneargoalnotifydist", (void*)0x809cb42, 0); Scr_AddMethod("setvehgoalpos", (void*)0x809ca7c, 0); Scr_AddMethod("setgoalyaw", (void*)0x809ca42, 0); Scr_AddMethod("cleargoalyaw", (void*)0x809ca14, 0); Scr_AddMethod("settargetyaw", (void*)0x809c9da, 0); Scr_AddMethod("cleartargetyaw", (void*)0x809c9ac, 0); Scr_AddMethod("setlookatent", (void*)0x809c900, 0); Scr_AddMethod("clearlookatent", (void*)0x809c8d2, 0); Scr_AddMethod("setvehweapon", (void*)0x809c890, 0); Scr_AddMethod("fireweapon", (void*)0x809d9e2, 0); Scr_AddMethod("setturrettargetvec", (void*)0x809d48a, 0); Scr_AddMethod("setturrettargetent", (void*)0x809d550, 0); Scr_AddMethod("clearturrettarget", (void*)0x809d0de, 0); Scr_AddMethod("setvehicleteam", (void*)0x809cb72, 0); Scr_AddMethod("setdamagestage", (void*)0x80ba890, 0); Scr_AddMethod("getgeolocation", PlayerCmd_GetGeoLocation, 0); } void Scr_InitFunctions() { //Reset everything 1st Scr_ClearFunctions(); Scr_ClearMethods(); //Then add everything again Scr_AddStockFunctions(); Scr_AddStockMethods(); } int GScr_LoadScriptAndLabel(const char* scriptName, const char* labelName, qboolean mandatory ){ int fh; PrecacheEntry load_buffer; if(!Scr_LoadScript(scriptName, &load_buffer ,0)){ if(mandatory){ Com_Error(ERR_DROP, "Could not find script '%s'", scriptName); }else{ Com_DPrintf("Notice: Could not find script '%s' - this part will be disabled\n", scriptName); } return 0; } fh = Scr_GetFunctionHandle(scriptName, labelName); if(!fh){ if(mandatory){ Com_Error(ERR_DROP, "Could not find label '%s' in script '%s'", labelName, scriptName); }else{ Com_DPrintf("Notice: Could not find label '%s' in script '%s' - this part will be disabled\n", labelName, scriptName); } return 0; } return fh; } /**************** Mandatory *************************/ #define g_scr_data (*((g_scr_data_t*) (G_SCR_DATA_ADDR))) typedef struct{ int map; //0x8583ba0 int unk1; int gametype; int startgametype; int playerconnect; int playerdisconnect; int playerdamage; int playerkilled; int unk2; int unk3; int playerlaststand; //0x8583bc8 int unkbig[1057]; int delete; //0x8584c50 int initstruct; int createstruct; }g_scr_data_t; void GScr_LoadGameTypeScript(void){ /**************** Mandatory *************************/ char gametype_path[64]; Com_sprintf(gametype_path, sizeof(gametype_path), "maps/mp/gametypes/%s", g_gametype->string); g_scr_data.gametype = GScr_LoadScriptAndLabel(gametype_path, "main", 1); g_scr_data.startgametype = GScr_LoadScriptAndLabel("maps/mp/gametypes/_callbacksetup", "CodeCallback_StartGameType", 1); g_scr_data.playerconnect = GScr_LoadScriptAndLabel("maps/mp/gametypes/_callbacksetup", "CodeCallback_PlayerConnect", 1); g_scr_data.playerdisconnect = GScr_LoadScriptAndLabel("maps/mp/gametypes/_callbacksetup", "CodeCallback_PlayerDisconnect", 1); g_scr_data.playerdamage = GScr_LoadScriptAndLabel("maps/mp/gametypes/_callbacksetup", "CodeCallback_PlayerDamage", 1); g_scr_data.playerkilled = GScr_LoadScriptAndLabel("maps/mp/gametypes/_callbacksetup", "CodeCallback_PlayerKilled", 1); g_scr_data.playerlaststand = GScr_LoadScriptAndLabel("maps/mp/gametypes/_callbacksetup", "CodeCallback_PlayerLastStand", 1); /**************** Additional *************************/ script_CallBacks_new[SCR_CB_NEW_SAY] = GScr_LoadScriptAndLabel("maps/mp/gametypes/_callbacksetup", "CodeCallback_PlayerSayCmd", 0); if(!script_CallBacks_new[SCR_CB_NEW_SAY]){ script_CallBacks_new[SCR_CB_NEW_SAY] = GScr_LoadScriptAndLabel("maps/mp/gametypes/_callbacksetup", "CodeCallback_PlayerSayAll", 0); say_forwardAll = qtrue; }else{ say_forwardAll = qfalse; } } typedef struct { char* name; int val1; int val2; void *setfun; }scrEntityFields_t; //Other functions access scrEntityFields_t too void GScr_AddFieldsForEntity() { int i; scrEntityFields_t *ptr; for(ptr = (scrEntityFields_t*)0x82202a0, i = 0; ptr->name; ptr++, i++ ) { Scr_AddFields( 0, ptr->name, i); } } /* client_fields_t clientField[] = { { "name", 0, 0, (void*)0x808b5b2, (void*)0x808b5d6 }, { "sessionteam", 0, 0, (void*)0x808b764, (void*)0x808b3da }, { "sessionstate", 0, 0, (void*)0x808b508, (void*)0x808b376 }, { "maxhealth", 12264, 12264, (void*)0x808b1c8, NULL }, { "score", 12152, 12152, (void*)0x808b73e, NULL }, { "deaths", 12156, 12156, NULL, NULL }, { "statusicon", 0, 0, (void*)0x808b718, (void*)0x808b672 }, { "headicon", 0, 0, (void*)0x808b6ce, (void*)0x808b5e6 }, { "headiconteam", 0, 0, (void*)0x808b43e, (void*)0x808b2fa }, { "kills", 12160, 12160, NULL, NULL }, { "assists", 12164, 12164, NULL, NULL }, { "hasradar", 12664, 12664, NULL, NULL }, { "spectatorclient", 12136, 12136, (void*)0x808b2c2, NULL }, { "killcamentity", 12140, 12140, (void*)0x808b288, NULL }, { "archivetime", 12148, 12148, (void*)0x808b258, (void*)0x808b23c }, { "psoffsettime", 12400, 12400, (void*)0x808b1aa, (void*)0x808b194 }, { "pers", 12168, 12168, (void*)0x808b5b2, NULL }, { NULL, 0, 0, NULL, NULL } }; */ void GScr_AddFieldsForClient() { int i; client_fields_t *ptr; for(ptr = (client_fields_t *)0x8215780, i = 0; ptr->name; ptr++, i++ ) { Scr_AddFields( 0, ptr->name, 0xc000+i); } } /* Bug in array - don't use! void Scr_GetClientField(gclient_t* gcl, int num) { client_fields_t *field = (client_fields_t *)0x8215780; field = &field[num]; // client_fields_t *field = &clientField[num]; if(field->getfun) field->getfun(gcl, field); else Scr_GetGenericField(gcl, field->type, field->val1); } void Scr_SetClientField(gclient_t* gcl, int num) { client_fields_t *field = (client_fields_t *)0x8215780; field = &field[num]; // client_fields_t *field = &clientField[num]; if(field->setfun) field->setfun(gcl, field); else Scr_SetGenericField(gcl, field->type, field->val1); } */ __cdecl void GScr_LoadScripts(void){ char mappath[MAX_QPATH]; cvar_t* mapname; int i; Scr_BeginLoadScripts(); Scr_InitFunctions(); g_scr_data.delete = GScr_LoadScriptAndLabel("codescripts/delete", "main", 1); g_scr_data.initstruct = GScr_LoadScriptAndLabel("codescripts/struct", "initstructs", 1); g_scr_data.createstruct = GScr_LoadScriptAndLabel("codescripts/struct", "createstruct", 1); GScr_LoadGameTypeScript(); mapname = Cvar_RegisterString( "mapname", "" ,CVAR_LATCH | CVAR_SYSTEMINFO ,"The current map name"); Com_sprintf(mappath, sizeof(mappath), "maps/mp/%s", mapname->string ); g_scr_data.map = GScr_LoadScriptAndLabel(mappath, "main", qfalse); for(i=0; i < 4; i++) Scr_SetClassMap(i); GScr_AddFieldsForEntity(); GScr_AddFieldsForClient(); GScr_AddFieldsForHudElems(); GScr_AddFieldsForRadiant(); Scr_EndLoadScripts(); } typedef struct{ int var_08; //0x895bf08 int unk[397]; int var_01; //0x895c540 int var_02; //0x895c544 unsigned int var_03; //0x895c548 unsigned int var_04; //0x895c54c int var_05; int var_06; char arrayunk[0x20000]; char* var_10; //0x897c558 void* scr_buffer_handle; //0x897c55c int unk2[198039]; char* script_filepath; //0x8a3dbbc int var_12; //0x8a3dbc0 }scrStruct_t; #define scrStruct (*((scrStruct_t*)(SCRSTRUCT_ADDR))) __cdecl unsigned int Scr_LoadScript(const char* scriptname, PrecacheEntry *precache, int iarg_02){ sval_u result; char filepath[MAX_QPATH]; char* old_script_filepath; void *scr_buffer_handle; int old_var12; int old_var08; unsigned int handle; unsigned int variable; unsigned int object; handle = Scr_CreateCanonicalFilename(scriptname); if(FindVariable(scrStruct.var_03, handle)) { SL_RemoveRefToString(handle); variable = FindVariable(scrStruct.var_04, handle); if(variable) { return FindObject(variable); } return 0; }else{ variable = GetNewVariable(scrStruct.var_03, handle); SL_RemoveRefToString(handle); old_var12 = scrStruct.var_12; /* Try to load our extended scriptfile (gsx) first. This allows to create mod- and mapscripts with our extended functionality while it is still possible to fall back to default script if our extended functionality is not available. */ Com_sprintf(filepath, sizeof(filepath), "%s.gsx", SL_ConvertToString(handle)); scr_buffer_handle = Scr_AddSourceBuffer(SL_ConvertToString(handle), filepath, TempMalloc(0), 1); if(!scr_buffer_handle) { /* If no extended script was found just load traditional script (gsc) */ Com_sprintf(filepath, sizeof(filepath), "%s.gsc", SL_ConvertToString(handle)); scr_buffer_handle = Scr_AddSourceBuffer(SL_ConvertToString(handle), filepath, TempMalloc(0), 1); } if(!scr_buffer_handle) { return 0; } old_var08 = scrStruct.var_08; scrStruct.var_08 = 0; scrStruct.var_02 = 0; Scr_InitAllocNode(); old_script_filepath = scrStruct.script_filepath; scrStruct.script_filepath = filepath; scrStruct.var_10 = "+"; scrStruct.scr_buffer_handle = scr_buffer_handle; ScriptParse(&result ,0); object = GetObjectA( GetVariable(scrStruct.var_04, handle) ); ScriptCompile(result, object, variable, precache, iarg_02); scrStruct.script_filepath = old_script_filepath; scrStruct.var_12 = old_var12; scrStruct.var_08 = old_var08; return object; } } //Was only needed to extract the arrays /* void GetVirtualFunctionArray(){ char buffer[1024*1024]; char line[128]; int i; char *funname; xfunction_t funaddr; int funtype; v_function_t *ptr; Com_Memset(buffer, 0, sizeof(buffer)); for(i = 0, ptr = (v_function_t*)0x821c620; ptr->offset != NULL && i < 25; ptr++, i++){ funname = ptr->name; funaddr = ptr->offset; funtype = ptr->developer; Com_sprintf(line, sizeof(line), "\t{\"%s\", (void*)%p, %x},\n", funname, funaddr, funtype); Q_strcat(buffer, sizeof(buffer), line); } FS_WriteFile("array.txt", buffer, strlen(buffer)); Com_Quit_f(); } */ /* void GetVirtualFunctionArray(){ char buffer[1024*1024]; char line[128]; int i; char *funname; xfunction_t funaddr; int funtype; v_function_t *ptr; Com_Memset(buffer, 0, sizeof(buffer)); for(i = 0, ptr = (v_function_t*)0x826e060; ptr->offset != NULL; ptr++, i++){ funname = ptr->name; funaddr = ptr->offset; funtype = ptr->developer; Com_sprintf(line, sizeof(line), "\tScr_AddFunction(\"%s\", (void*)%p, %i);\n", funname, funaddr, funtype); Q_strcat(buffer, sizeof(buffer), line); } FS_WriteFile("array.txt", buffer, strlen(buffer)); Com_Quit_f(); } typedef struct{ char *name; int offset; int bits; int zero; }subnetlist_t; typedef struct{ subnetlist_t *sub; int size; }netlist_t; void GetDeltaEntArray(){ char buffer[1024*1024]; char line[128]; netlist_t *ptr; subnetlist_t *subptr; int i, j; Com_Memset(buffer, 0, sizeof(buffer)); for(j=0, ptr = (netlist_t*)0x82293c0; ptr->sub != NULL ; ptr++, j++){ subptr = ptr->sub; Com_sprintf(line, sizeof(line), "netField_t entityStateFields_%i[] =\n{\n", j); Q_strcat(buffer, sizeof(buffer), line); for(i = 0; i < ptr->size; i++, subptr++) { Com_sprintf(line, sizeof(line), "\t{ NETF( %s ), %i, %i, %i},\n", subptr->name, subptr->offset, subptr->bits, subptr->zero); Q_strcat(buffer, sizeof(buffer), line); } Com_sprintf(line, sizeof(line), "};\n\n\n"); Q_strcat(buffer, sizeof(buffer), line); } FS_WriteFile("array.txt", buffer, strlen(buffer)); Com_Quit_f(); } typedef struct{ char *name; int offset; int bits; int unknown; }netlistPlayer_t; void GetDeltaPlayerArray(){ char buffer[1024*1024]; char line[128]; netlistPlayer_t *ptr; int j; Com_Memset(buffer, 0, sizeof(buffer)); for(j=0, ptr = (netlistPlayer_t*)0x82283c0; ptr->name != NULL; ptr++, j++){ Com_sprintf(line, sizeof(line), "\tint\t\t%s; %i\n", ptr->name, ptr->offset); Q_strcat(buffer, sizeof(buffer), line); Com_Printf("%s\n", line); } FS_WriteFile("array.txt", buffer, strlen(buffer)); Com_Quit_f(); } typedef struct __attribute__((packed)){ byte mov1; byte mov2; byte mov3; char* string; byte call1; byte call2; byte call3; byte call4; byte call5; byte mov11; byte mov12; short* index; }stringindexcmd_t; void StringIndexArray(){ char buffer[1024*1024]; char line[128]; int j; stringindexcmd_t* ptr; Com_Memset(buffer, 0, sizeof(buffer)); for(j=0, ptr = (stringindexcmd_t*)0x80a396e; ptr->mov3 != 0x90 ; ptr++, j++){ Com_Printf("String: %s\n", ptr->string); Com_sprintf(line, sizeof(line), "\tshort %s;\n", ptr->string); Q_strcat(buffer, sizeof(buffer), line); } FS_WriteFile("array.txt", buffer, strlen(buffer)); Com_Quit_f(); } void GetPlayerFieldArray(){ char buffer[1024*1024]; char line[128]; scrClientFields_t *ptr; int j; Com_Memset(buffer, 0, sizeof(buffer)); for(j=0, ptr = (scrClientFields_t*)0x8215780; ptr->name != NULL; ptr++, j++){ Com_sprintf(line, sizeof(line), "\tScr_AddPlayerField(%s, %d, %d, %p, %p)\n", ptr->name, ptr->val1, ptr->val1, ptr->setfun, ptr->getfun); Q_strcat(buffer, sizeof(buffer), line); Com_Printf("%s\n", line); } FS_WriteFile("array.txt", buffer, strlen(buffer)); Com_Quit_f(); } */
39,249
C
.c
874
41.929062
139
0.714372
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,875
cvar.c
haithun_CoD4X17a_testing/cvar.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "cvar.h" #include "cmd.h" #include "cmd_completion.h" // nothing outside the Cvar_*() functions should modify these fields! #ifndef __CMD_COMPLETION_H__ void Cvar_CompleteCvarName(){} #endif void Cvar_VariableStringBuffer(const char* cvarname, char* buff, size_t size){ Q_strncpyz(buff, Cvar_GetVariantString(cvarname), size); } /* ============ Cvar_Init Reads in all archived cvars ============ */ void Cvar_Init (void) { Cmd_AddCommand ("toggle", Cvar_Toggle_f); Cmd_SetCommandCompletionFunc( "toggle", Cvar_CompleteCvarName ); Cmd_AddCommand ("togglep", Cvar_TogglePrint_f); Cmd_SetCommandCompletionFunc( "togglep", Cvar_CompleteCvarName ); Cmd_AddCommand ("set", Cvar_Set_f); Cmd_SetCommandCompletionFunc( "set", Cvar_CompleteCvarName ); Cmd_AddCommand ("sets", Cvar_SetS_f); Cmd_SetCommandCompletionFunc( "sets", Cvar_CompleteCvarName ); Cmd_AddCommand ("seta", Cvar_SetA_f); Cmd_SetCommandCompletionFunc( "seta", Cvar_CompleteCvarName ); Cmd_AddCommand ("setfromdvar", Cvar_SetFromCvar_f); Cmd_SetCommandCompletionFunc( "setfromdvar", Cvar_CompleteCvarName ); Cmd_AddCommand ("setfromlocString", Cvar_SetFromLocalizedStr_f); Cmd_SetCommandCompletionFunc( "setfromlocString", Cvar_CompleteCvarName ); Cmd_AddCommand ("setdvartotime", Cvar_SetToTime_f); Cmd_SetCommandCompletionFunc( "setdvartotime", Cvar_CompleteCvarName ); Cmd_AddCommand ("reset", Cvar_Reset_f); Cmd_SetCommandCompletionFunc( "reset", Cvar_CompleteCvarName ); Cmd_AddCommand ("setu", Cvar_SetU_f); Cmd_SetCommandCompletionFunc( "setu", Cvar_CompleteCvarName ); Cmd_AddCommand ("dvarlist", Cvar_List_f); Cmd_AddCommand ("dvardump", Cvar_Dump_f); Cmd_AddCommand ("dvar_bool", Cvar_RegisterBool_f); Cmd_AddCommand ("dvar_int", Cvar_RegisterInt_f); Cmd_AddCommand ("dvar_float", Cvar_RegisterFloat_f); cvar_t **tmp = (cvar_t**)(0x14078480); *tmp = Cvar_RegisterBool("sv_cheats", qfalse, CVAR_INIT, "Enable cheating on server"); } /* ============ Cvar_VariableValue ============ */ float Cvar_VariableValue( const char *var_name ) { cvar_t *var; var = Cvar_FindMalleableVar (var_name); if (!var || var->type != CVAR_FLOAT) return 0; return var->value; } /* ============ Cvar_VariableIntegerValue ============ */ int Cvar_VariableIntegerValue( const char *var_name ) { cvar_t *var; var = Cvar_FindMalleableVar (var_name); if (!var || var->type != CVAR_INT) return 0; return var->integer; } /* ============ Cvar_VariableString ============ */ const char* Cvar_VariableString( const char *var_name ) { cvar_t *var; var = Cvar_FindMalleableVar (var_name); if (!var || var->type != CVAR_STRING) return ""; return var->string; }
3,697
C
.c
99
35.090909
87
0.700699
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,876
sys_unix.c
haithun_CoD4X17a_testing/sys_unix.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "q_shared.h" #include "q_platform.h" #include "qcommon_io.h" #include <sys/resource.h> #include <libgen.h> #include <signal.h> #include <sys/mman.h> #include <string.h> #include <unistd.h> #include <stdlib.h> #include <errno.h> #include <dlfcn.h> /* ================== Sys_RandomBytes ================== */ qboolean Sys_RandomBytes( byte *string, int len ) { FILE *fp; fp = fopen( "/dev/urandom", "r" ); if( !fp ) return qfalse; if( !fread( string, sizeof( byte ), len, fp ) ) { fclose( fp ); return qfalse; } fclose( fp ); return qtrue; } void Sys_DoStartProcess( char *cmdline ) { switch ( fork() ) { case - 1: // main thread break; case 0: if ( strchr( cmdline, ' ' ) ) { system( cmdline ); } else { execl( cmdline, cmdline, NULL ); printf( "execl failed: %s\n", strerror( errno ) ); } _exit( 0 ); break; } } /* ================== Sys_Dirname ================== */ const char *Sys_Dirname( char *path ) { return dirname( path ); } /* ================== Sys_Cwd ================== */ char *Sys_Cwd( void ) { static char cwd[MAX_OSPATH]; char *result = getcwd( cwd, sizeof( cwd ) - 1 ); if( result != cwd ) return NULL; cwd[MAX_OSPATH-1] = 0; return cwd; } void Sys_InitCrashDumps(){ // core dumps may be disallowed by parent of this process; change that struct rlimit core_limit; core_limit.rlim_cur = RLIM_INFINITY; core_limit.rlim_max = RLIM_INFINITY; if (setrlimit(RLIMIT_CORE, &core_limit) < 0) Com_PrintWarning("setrlimit: %s\nCore dumps may be truncated or non-existant\n", strerror(errno)); } qboolean Sys_MemoryProtectWrite(void* startoffset, int len) { if(mprotect(startoffset - ((int)startoffset % getpagesize()), len + (len % getpagesize()), PROT_READ | PROT_WRITE) != 0) { perror("Sys_MemoryProtectWrite: mprotect change memory to writable error"); return qfalse; } return qtrue; } qboolean Sys_MemoryProtectExec(void* startoffset, int len) { if(mprotect(startoffset - ((int)startoffset % getpagesize()), len + (len % getpagesize()), PROT_READ | PROT_EXEC) != 0) { perror("Sys_MemoryProtectExec: mprotect change memory to readonly/execute error"); return qfalse; } return qtrue; } qboolean Sys_MemoryProtectReadonly(void* startoffset, int len) { if(mprotect(startoffset - ((int)startoffset % getpagesize()), len + (len % getpagesize()), PROT_READ) != 0) { perror("Sys_MemoryProtectReadonly: mprotect change memory to readonly error"); return qfalse; } return qtrue; } static char homePath[MAX_OSPATH]; /* ================== Sys_DefaultHomePath ================== */ const char *Sys_DefaultHomePath(void) { char *p; if( !*homePath ) { if( ( p = getenv( "HOME" ) ) != NULL ) { Com_sprintf(homePath, sizeof(homePath), "%s%c", p, PATH_SEP); #ifdef MACOS_X Q_strcat(homePath, sizeof(homePath), "Library/Application Support/"); Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_MACOSX); #else Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_UNIX); #endif } } return homePath; } #ifndef MACOS_X /* ================ Sys_TempPath ================ */ const char *Sys_TempPath( void ) { const char *TMPDIR = getenv( "TMPDIR" ); if( TMPDIR == NULL || TMPDIR[ 0 ] == '\0' ) return "/tmp"; else return TMPDIR; } #endif
4,426
C
.c
163
24.177914
121
0.636838
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,880
hl2rcon.h
haithun_CoD4X17a_testing/hl2rcon.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "q_shared.h" #include "sys_net.h" #include "msg.h" #ifndef __HL2RCON_H__ #define __HL2RCON_H__ /* ======================================================================== Source Rcon facility ======================================================================== */ #define MAX_RCONUSERS 8 #define MAX_RCONLOGINS 64 typedef struct{ netadr_t remote; int socketfd; int lastpacketid; qboolean streamlog; qboolean streamchat; qboolean streamgamelog; qboolean streamevents; int rconPower; //unused for now char rconUsername[32]; }rconUser_t; typedef struct{ char username[32]; char salt[129]; char sha256[65]; int power; }rconLogin_t; typedef struct{ rconLogin_t rconUsers[MAX_RCONLOGINS]; rconUser_t activeRconUsers[MAX_RCONUSERS]; //For redirect int redirectUser; }sourceRcon_t; typedef enum{ SERVERDATA_RESPONSE_VALUE = 0, SERVERDATA_EXECCOMMAND = 2, SERVERDATA_AUTH_RESPONSE = 2, SERVERDATA_AUTH = 3, SERVERDATA_CHANGEPASSWORD = 63, SERVERDATA_TURNONSTREAM = 64, SERVERDATA_GAMELOG = 65, SERVERDATA_CONLOG = 66, SERVERDATA_CHAT = 67, SERVERDATA_GETSTATUS = 68, SERVERDATA_STATUSRESPONSE = 69, SERVERDATA_SAY = 70, SERVERDATA_EVENT = 71 }sourceRconCommands_t; typedef enum{ RCONEVENT_PLAYERENTERGAME = 0, RCONEVENT_PLAYERLEAVE = 1, RCONEVENT_LEVELSTART = 2, RCONEVENT_PLAYERENTERTEAM = 3 }sourceRconEvents_t; void HL2Rcon_SetSourceRconAdmin_f( void ); void HL2Rcon_UnsetSourceRconAdmin_f( void ); void HL2Rcon_ListSourceRconAdmins_f( void ); void HL2Rcon_ChangeSourceRconAdminPassword( const char* password ); void HL2Rcon_SourceRconStreaming_enable( int type ); qboolean HL2Rcon_AddSourceRconAdminToList(const char* username, const char* password, const char* salt, int power); void HL2Rcon_ClearSourceRconAdminList( void ); void HL2Rcon_SourceRconDisconnect(netadr_t *from, int socketfd, int connectionId); tcpclientstate_t HL2Rcon_SourceRconAuth(netadr_t *from, msg_t *msg, int socketfd, int *connectionId); void HL2Rcon_SourceRconSendConsole( const char* data, int msglen); void HL2Rcon_SourceRconSendChat( const char* data, int clientnum, int type); void HL2Rcon_SourceRconSendDataToEachClient( const byte* data, int msglen, int type); void HL2Rcon_SourceRconFlushRedirect(char* outputbuf, qboolean lastcommand); qboolean HL2Rcon_SourceRconEvent(netadr_t *from, msg_t *msg, int socketfd, int connectionId); void HL2Rcon_AddSourceAdminCommands(); void HL2Rcon_SourceRconSendGameLog( const char* data, int msglen); void HL2Rcon_SourceRconSendChatToEachClient( const char *text, rconUser_t *self, int cid, qboolean onlyme); void HL2Rcon_EventClientEnterTeam(int cid, int team); void HL2Rcon_EventClientEnterWorld(int cid); void HL2Rcon_EventClientLeave(int cid); void HL2Rcon_EventLevelStart(); void HL2Rcon_Init(); qboolean HL2Rcon_InfoAddAdmin(const char* line); void HL2Rcon_WriteAdminConfig(char* buffer, int size); #endif
3,922
C
.c
97
37.845361
115
0.724238
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,882
hl2rcon.c
haithun_CoD4X17a_testing/hl2rcon.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "hl2rcon.h" #include "q_shared.h" #include "qcommon.h" #include "qcommon_io.h" #include "cmd.h" #include "nvconfig.h" #include "msg.h" #include "sys_net.h" #include "server.h" #include "net_game_conf.h" #include "sha256.h" #include "punkbuster.h" #include "net_game.h" #include "g_sv_shared.h" #include <stdint.h> #include <string.h> #include <stdlib.h> /* ======================================================================== Source Rcon facility ======================================================================== */ #ifndef MAX_MSGLEN #define MAX_MSGLEN 0x20000 #endif sourceRcon_t sourceRcon; #define HL2RCON_SOURCEOUTPUTBUF_LENGTH 4096 void HL2Rcon_SetSourceRconAdmin_f( void ){ const char* username; const char* password; const char* sha256; byte salt[129]; int power, i; rconLogin_t* user; rconLogin_t* free = NULL; if(Cmd_Argc() != 4){ Com_Printf("Usage: rconaddadmin <username, password, power>\n"); return; } username = Cmd_Argv(1); password = Cmd_Argv(2); power = atoi(Cmd_Argv(3)); if(!username || !*username || !password || strlen(password) < 6 || power < 1 || power > 100){ Com_Printf("Usage: rconaddadmin <username, password (at least 6 characters), power (and integer between 1 and 100)>\n"); return; } NV_ProcessBegin(); for(i = 0, user = sourceRcon.rconUsers; i < MAX_RCONLOGINS; i++, user++){ if(!Q_stricmp(user->username, username)){ Com_Printf("A rconadmin with this username is already registered\n"); return; } if(!free && !*user->username ) free = user; } if(!free){ Com_Printf("Too many registered rconadmins. Limit is: %d\n", MAX_RCONLOGINS); return; } Com_RandomBytes(salt, sizeof(salt)); for(i = 0; i < sizeof(salt) -1; i++){ if(salt[i] > 126){ salt[i] -= 125; } if(salt[i] < 21){ salt[i] += 21; } if(salt[i] == ';') salt[i]++; if(salt[i] == '\\') salt[i]++; if(salt[i] == '%') salt[i]++; if(salt[i] == '"') salt[i]++; } salt[sizeof(salt) -1] = 0; sha256 = Com_SHA256(va("%s.%s", password, salt)); Q_strncpyz(free->username, username, sizeof(free->username)); Q_strncpyz(free->sha256, sha256, sizeof(free->sha256)); Q_strncpyz(free->salt, (char*)salt, sizeof(free->salt)); free->power = power; NV_ProcessEnd(); } void HL2Rcon_UnsetSourceRconAdmin_f( void ){ const char* username; int i; rconLogin_t* user; if(Cmd_Argc() != 2){ Com_Printf("Usage: rcondeladmin < username >\n"); return; } username = Cmd_Argv(1); NV_ProcessBegin(); for(i = 0, user = sourceRcon.rconUsers; i < MAX_RCONLOGINS; i++, user++){ if(!Q_stricmp(user->username, username)){ Com_Printf("Removed %s from the list of rconadmins\n", user->username); Com_Memset(user, 0, sizeof(rconLogin_t)); NV_ProcessEnd(); return; } } Com_Printf("No such admin: %s\n", username); } void HL2Rcon_ListSourceRconAdmins_f( void ){ int i; rconLogin_t* user; Com_Printf("------- SourceRconAdmins: -------\n"); for(i = 0, user = sourceRcon.rconUsers; i < MAX_RCONLOGINS; i++, user++){ if(*user->username) Com_Printf(" %2d: Name: %s, Power: %d\n", i+1, user->username, user->power); } Com_Printf("---------------------------------\n"); } void HL2Rcon_ChangeSourceRconAdminPassword( const char* password ){ const char* sha256; char salt[129]; rconLogin_t* user; int i; if(sourceRcon.redirectUser < 1 || sourceRcon.redirectUser > MAX_RCONUSERS){ Com_Printf("This command can only be used from SourceRcon\n"); return; } if(!password || strlen(password) < 6){ Com_Printf("Error: password too short. (at least 6 characters)\n"); return; } NV_ProcessBegin(); user = &sourceRcon.rconUsers[sourceRcon.redirectUser -1]; Com_RandomBytes((byte*)salt, sizeof(salt)); salt[sizeof(salt) -1] = 0; for(i = 0; i < sizeof(salt) -1; i++){ if(salt[i] > 126){ salt[i] -= 125; } if(salt[i] < 21){ salt[i] += 21; } if(salt[i] == ';') salt[i]++; if(salt[i] == '\\') salt[i]++; if(salt[i] == '%') salt[i]++; if(salt[i] == '"') salt[i]++; } sha256 = Com_SHA256(va("%s.%s", password, salt)); Q_strncpyz(user->sha256, sha256, sizeof(user->sha256)); Q_strncpyz(user->salt, salt, sizeof(user->salt)); NV_ProcessEnd(); Com_Printf("Password changed to: %s\n", password); } void HL2Rcon_SourceRconStreaming_enable( int type ){ rconUser_t* user; char* c; char* cg; char* ch; char* ev; if(sourceRcon.redirectUser < 1 || sourceRcon.redirectUser > MAX_RCONUSERS){ Com_Printf("This command can only be used from SourceRcon\n"); return; } user = &sourceRcon.activeRconUsers[sourceRcon.redirectUser -1]; user->streamlog = type & 1; user->streamgamelog = type & 2; user->streamchat = type & 4; user->streamevents = type & 8; if(user->streamlog) c = "logfile"; else c = ""; if(user->streamgamelog) cg = "gamelog"; else cg = ""; if(user->streamchat) ch = "chat"; else ch = ""; if(user->streamevents) ev = "events"; else ev = ""; Com_Printf("Streaming turned on for: %s %s %s %s\n", c, cg, ch, ev); } void HL2Rcon_ClearSourceRconAdminList( ) { Com_Memset(sourceRcon.rconUsers, 0, sizeof(sourceRcon.rconUsers)); } qboolean HL2Rcon_AddSourceRconAdminToList(const char* username, const char* password, const char* salt, int power){ rconLogin_t* user; rconLogin_t* free = NULL; int i; if(!username || !*username || !password || strlen(password) < 6 || power < 1 || power > 100 || !salt || strlen(salt) != 128) return qfalse; for(i = 0, user = sourceRcon.rconUsers; i < MAX_RCONLOGINS; i++, user++){ if(!Q_stricmp(user->username, username)){ return qfalse; } if(!free && !*user->username ) free = user; } if(!free) return qfalse; Q_strncpyz(free->username, username, sizeof(free->username)); Q_strncpyz(free->sha256, password, sizeof(free->sha256)); Q_strncpyz(free->salt, salt, sizeof(free->salt)); free->power = power; return qtrue; } void HL2Rcon_SourceRconDisconnect(netadr_t *from, int socketfd, int connectionId){ if(connectionId < 0 || connectionId >= MAX_RCONUSERS){ Com_Error(ERR_FATAL, "HL2Rcon_SourceRconDisconnect: bad connectionId: %i", connectionId); return; } sourceRcon.activeRconUsers[connectionId].remote.type = NA_BAD; sourceRcon.activeRconUsers[connectionId].streamlog = 0; sourceRcon.activeRconUsers[connectionId].streamchat = 0; sourceRcon.activeRconUsers[connectionId].streamgamelog = 0; sourceRcon.activeRconUsers[connectionId].streamevents = 0; } tcpclientstate_t HL2Rcon_SourceRconAuth(netadr_t *from, msg_t *msg, int socketfd, int *connectionId){ int packetlen; int packettype; int packetid; char* loginstring; char* username; char* password; const char* sha256; char hstring[256]; byte msgbuf[32]; msg_t sendmsg; rconUser_t* user; rconLogin_t* login; int i; if(SV_PlayerBannedByip(from)){ return TCP_AUTHBAD; } MSG_BeginReading(msg); packetlen = MSG_ReadLong(msg); if(packetlen != msg->cursize - 4)//Not a source rcon packet return TCP_AUTHNOTME; packetid = MSG_ReadLong(msg); packettype = MSG_ReadLong(msg); if(packettype != SERVERDATA_AUTH)//Not a source rcon auth-packet return TCP_AUTHNOTME; MSG_Init(&sendmsg, msgbuf, sizeof(msgbuf)); MSG_WriteLong(&sendmsg, 10); MSG_WriteLong(&sendmsg, 0); MSG_WriteLong(&sendmsg, SERVERDATA_RESPONSE_VALUE); MSG_WriteShort(&sendmsg, 0); if(NET_SendData(socketfd, sendmsg.data, sendmsg.cursize)) { return TCP_AUTHBAD; } MSG_Init(&sendmsg, msgbuf, sizeof(msgbuf)); MSG_WriteLong(&sendmsg, 10); loginstring = MSG_ReadStringLine(msg); Cmd_TokenizeString(loginstring); if(Cmd_Argc() != 2){ goto badrcon; } username = Cmd_Argv(0); password = Cmd_Argv(1); if(strlen(password) < 6){ goto badrcon; } for(i = 0, login = sourceRcon.rconUsers; i < MAX_RCONLOGINS; i++, login++){ if(!Q_stricmp(login->username, username)) break; } if(i == MAX_RCONLOGINS){ goto badrcon; } Com_sprintf(hstring, sizeof(hstring), "%s.%s", password, login->salt); sha256 = Com_SHA256(hstring); if(Q_strncmp(login->sha256, sha256, 128)) goto badrcon; Com_Printf("Rcon login from: %s Name: %s\n", NET_AdrToString (from), login->username); Cmd_EndTokenizeString(); for(i = 0, user = sourceRcon.activeRconUsers; i < MAX_RCONUSERS; i++, user++){ if(user->remote.type == NA_BAD) break; } if(i == MAX_RCONUSERS){ return TCP_AUTHBAD; //Close connection } user->remote = *from; user->rconPower = login->power; Q_strncpyz(user->rconUsername, login->username, sizeof(user->rconUsername)); user->socketfd = socketfd; user->streamchat = 0; user->streamlog = 0; user->lastpacketid = packetid; *connectionId = i; MSG_WriteLong(&sendmsg, user->lastpacketid); MSG_WriteLong(&sendmsg, SERVERDATA_AUTH_RESPONSE); MSG_WriteShort(&sendmsg, 0); if(NET_SendData(socketfd, sendmsg.data, sendmsg.cursize)) { return TCP_AUTHBAD; } return TCP_AUTHSUCCESSFULL; badrcon: Cmd_EndTokenizeString(); Com_Printf ("Bad rcon from %s (TCP)\n", NET_AdrToString (from) ); //Don't allow another attempt for 20 seconds SV_PlayerAddBanByip(from, "Bad rcon", 0, NULL, 0, Com_GetRealtime() + 20); MSG_Init(&sendmsg, msgbuf, sizeof(msgbuf)); MSG_WriteLong(&sendmsg, 10); MSG_WriteLong(&sendmsg, -1); MSG_WriteLong(&sendmsg, SERVERDATA_AUTH_RESPONSE); MSG_WriteShort(&sendmsg, 0); NET_SendData(socketfd, sendmsg.data, sendmsg.cursize); return TCP_AUTHBAD; } void HL2Rcon_SourceRconSendConsole( const char* data, int msglen) { HL2Rcon_SourceRconSendDataToEachClient( (const byte*)data, msglen, SERVERDATA_CONLOG); } void HL2Rcon_SourceRconSendGameLog( const char* data, int msglen) { HL2Rcon_SourceRconSendDataToEachClient( (const byte*)data, msglen, SERVERDATA_GAMELOG); } void HL2Rcon_SourceRconSendChat( const char* data, int clientnum, int mode) { HL2Rcon_SourceRconSendChatToEachClient( data, NULL, clientnum, qfalse); } void HL2Rcon_SourceRconSendDataToEachClient( const byte* data, int msglen, int type){ rconUser_t* user; int i; msg_t msg; int32_t *updatelen; byte sourcemsgbuf[MAX_MSGLEN]; qboolean msgbuild = qfalse; for(i = 0, user = sourceRcon.activeRconUsers; i < MAX_RCONUSERS; i++, user++ ){ if(!user->streamgamelog && type == SERVERDATA_GAMELOG) continue; if(!user->streamlog && type == SERVERDATA_CONLOG) continue; if(!user->streamevents && type == SERVERDATA_EVENT) continue; if(!msgbuild){ MSG_Init(&msg, sourcemsgbuf, sizeof(sourcemsgbuf)); MSG_WriteLong(&msg, 0); //writing 0 for now MSG_WriteLong(&msg, 0); MSG_WriteLong(&msg, type); if(type == SERVERDATA_EVENT) MSG_WriteData(&msg, data, msglen); else MSG_WriteBigString(&msg, (char*)data); MSG_WriteByte(&msg, 0); //Adjust the length updatelen = (int32_t*)msg.data; *updatelen = msg.cursize - 4; msgbuild = qtrue; } NET_SendData(user->socketfd, msg.data, msg.cursize); } } void HL2Rcon_SourceRconSendChatToEachClient( const char *text, rconUser_t *self, int cid, qboolean onlyme){ rconUser_t* user; int i; msg_t msg; int32_t *updatelen; byte sourcemsgbuf[MAX_MSGLEN]; for(i = 0, user = sourceRcon.activeRconUsers; i < MAX_RCONUSERS; i++, user++ ){ if(!user->streamchat) continue; MSG_Init(&msg, sourcemsgbuf, sizeof(sourcemsgbuf)); MSG_WriteLong(&msg, 0); //writing 0 for now MSG_WriteLong(&msg, 0); MSG_WriteLong(&msg, SERVERDATA_CHAT); if(self){ if(self == user) { MSG_WriteByte(&msg, -2); }else{ MSG_WriteByte(&msg, -1); if(onlyme) { continue; } } MSG_WriteBigString(&msg, user->rconUsername); }else{ MSG_WriteByte(&msg, cid); } MSG_WriteBigString(&msg, text); MSG_WriteByte(&msg, 0); //Adjust the length updatelen = (int32_t*)msg.data; *updatelen = msg.cursize - 4; NET_SendData(user->socketfd, msg.data, msg.cursize); } } void HL2Rcon_SourceRconFlushRedirect(char* outputbuf, qboolean lastcommand){ rconUser_t* user; if(sourceRcon.redirectUser < 1 || sourceRcon.redirectUser > MAX_RCONUSERS) return; user = &sourceRcon.activeRconUsers[sourceRcon.redirectUser -1]; msg_t msg; int32_t *updatelen; byte sourcemsgbuf[HL2RCON_SOURCEOUTPUTBUF_LENGTH+16]; MSG_Init(&msg, sourcemsgbuf, sizeof(sourcemsgbuf)); MSG_WriteLong(&msg, 0); //writing 0 for now MSG_WriteLong(&msg, user->lastpacketid); MSG_WriteLong(&msg, SERVERDATA_RESPONSE_VALUE); MSG_WriteBigString(&msg, outputbuf); MSG_WriteByte(&msg, 0); //Adjust the length updatelen = (int32_t*)msg.data; *updatelen = msg.cursize - 4; NET_SendData(user->socketfd, msg.data, msg.cursize); } void HL2Rcon_SayToPlayers(int clientnum, int team, const char* chatline) { char line[512]; rconUser_t* user; if(sourceRcon.redirectUser < 1 || sourceRcon.redirectUser > MAX_RCONUSERS){ Com_Printf("This command can only be used from SourceRcon\n"); return; } user = &sourceRcon.activeRconUsers[sourceRcon.redirectUser -1]; if(clientnum != -1) { Com_sprintf(line, sizeof(line), "^5%s^7(Rcon): %s\n", user->rconUsername, chatline); HL2Rcon_SourceRconSendChatToEachClient( chatline, user, 0, qtrue); }else{ Com_sprintf(line, sizeof(line), "^2%s^7(Rcon): %s\n", user->rconUsername, chatline); HL2Rcon_SourceRconSendChatToEachClient( chatline, user, 0, qfalse); } SV_SayToPlayers(clientnum, team, line); } qboolean HL2Rcon_SourceRconEvent(netadr_t *from, msg_t *msg, int socketfd, int connectionId){ // int packetlen; int packettype; int type; int8_t team; int8_t clientnum; int32_t *updatelen; char* command; char* password; char* chatline; char sv_outputbuf[HL2RCON_SOURCEOUTPUTBUF_LENGTH]; msg_t msg2; byte data[20000]; MSG_BeginReading(msg); while(msg->readcount < msg->cursize) { //packetlen = MSG_ReadLong(msg); if(connectionId < 0 || connectionId >= MAX_RCONUSERS) return qtrue; rconUser_t* user; user = &sourceRcon.activeRconUsers[connectionId]; user->lastpacketid = MSG_ReadLong(msg); packettype = MSG_ReadLong(msg); switch(packettype) { case SERVERDATA_GETSTATUS: //status request //Pop the end of body byte MSG_ReadByte(msg); MSG_Init(&msg2, data, sizeof(data)); MSG_WriteLong(&msg2, 0); //writing 0 for now MSG_WriteLong(&msg2, user->lastpacketid); // ID MSG_WriteLong(&msg2, SERVERDATA_STATUSRESPONSE); // Type: status response SV_WriteRconStatus(&msg2); MSG_WriteByte(&msg2, 0); //Adjust the length updatelen = (int32_t*)msg2.data; *updatelen = msg2.cursize - 4; NET_SendData(socketfd, msg2.data, msg2.cursize); break; case SERVERDATA_EXECCOMMAND: command = MSG_ReadString(msg); //Pop the end of body byte MSG_ReadByte(msg); Com_Printf("Rcon from: %s command: %s\n", NET_AdrToString(from), command); sourceRcon.redirectUser = connectionId+1; Com_BeginRedirect (sv_outputbuf, sizeof(sv_outputbuf), HL2Rcon_SourceRconFlushRedirect); Cmd_ExecuteSingleCommand(0,0, command); if(!Q_stricmpn(command, "pb_sv_", 6)) PbServerForceProcess(); Com_EndRedirect (); sourceRcon.redirectUser = 0; break; case SERVERDATA_CHANGEPASSWORD: password = MSG_ReadString(msg); //Pop the end of body byte MSG_ReadByte(msg); sourceRcon.redirectUser = connectionId+1; Com_BeginRedirect (sv_outputbuf, sizeof(sv_outputbuf), HL2Rcon_SourceRconFlushRedirect); HL2Rcon_ChangeSourceRconAdminPassword( password ); Com_EndRedirect (); sourceRcon.redirectUser = 0; break; case SERVERDATA_TURNONSTREAM: type = MSG_ReadByte(msg); //Pop the end of body byte MSG_ReadByte(msg); sourceRcon.redirectUser = connectionId+1; Com_BeginRedirect (sv_outputbuf, sizeof(sv_outputbuf), HL2Rcon_SourceRconFlushRedirect); HL2Rcon_SourceRconStreaming_enable( type ); Com_EndRedirect (); sourceRcon.redirectUser = 0; break; case SERVERDATA_SAY: clientnum = MSG_ReadByte(msg); // -1 if Team or for all is used team = MSG_ReadByte(msg); // teamnumber or -1 if it is for all team or clientnum is set chatline = MSG_ReadString(msg); //Pop the end of body byte MSG_ReadByte(msg); sourceRcon.redirectUser = connectionId+1; HL2Rcon_SayToPlayers(clientnum, team, chatline); sourceRcon.redirectUser = 0; break; default: //Not a source rcon packet Com_Printf("Not a valid source rcon packet from: %s received. Type: %d - Closing connection\n", NET_AdrToString(from), packettype); return qtrue; } } return qfalse; } void HL2Rcon_Init(){ static qboolean initialized; if ( initialized ) { return; } initialized = qtrue; Cmd_AddCommand ("rcondeladmin", HL2Rcon_UnsetSourceRconAdmin_f); Cmd_AddCommand ("rconaddadmin", HL2Rcon_SetSourceRconAdmin_f); Cmd_AddCommand ("rconlistadmins", HL2Rcon_ListSourceRconAdmins_f); NET_TCPAddEventType(HL2Rcon_SourceRconEvent, HL2Rcon_SourceRconAuth, HL2Rcon_SourceRconDisconnect, 9038723); Com_AddRedirect(HL2Rcon_SourceRconSendConsole); G_PrintAddRedirect(HL2Rcon_SourceRconSendGameLog); G_AddChatRedirect(HL2Rcon_SourceRconSendChat); } void HL2Rcon_EventClientEnterWorld(int cid){ byte data[2]; data[0] = RCONEVENT_PLAYERENTERGAME; data[1] = cid; HL2Rcon_SourceRconSendDataToEachClient( data, 2, SERVERDATA_EVENT); } void HL2Rcon_EventClientLeave(int cid){ byte data[2]; data[0] = RCONEVENT_PLAYERLEAVE; data[1] = cid; HL2Rcon_SourceRconSendDataToEachClient( data, 2, SERVERDATA_EVENT); } void HL2Rcon_EventLevelStart() { byte data[1]; data[0] = RCONEVENT_LEVELSTART; HL2Rcon_SourceRconSendDataToEachClient( data, 1, SERVERDATA_EVENT); } void HL2Rcon_EventClientEnterTeam(int cid, int team){ byte data[2]; data[0] = RCONEVENT_PLAYERENTERTEAM; data[1] = cid; data[2] = team; HL2Rcon_SourceRconSendDataToEachClient( data, 3, SERVERDATA_EVENT); } qboolean HL2Rcon_InfoAddAdmin(const char* line) { char password[65]; char salt[129]; char username[32]; int power; power = atoi(Info_ValueForKey(line, "power")); Q_strncpyz(password, Info_ValueForKey(line, "password") , sizeof(password)); Q_strncpyz(salt, Info_ValueForKey(line, "salt") , sizeof(salt)); Q_strncpyz(username, Info_ValueForKey(line, "username") , sizeof(username)); if(!HL2Rcon_AddSourceRconAdminToList(username, password, salt, power)){ Com_Printf("Error: duplicated username or bad power or too many admins\n"); return qfalse; } return qtrue; } void HL2Rcon_WriteAdminConfig(char* buffer, int size) { char infostring[MAX_INFO_STRING]; int i; rconLogin_t *rconadmin; Q_strcat(buffer, size, "\n//RconAdmins\n"); for ( rconadmin = sourceRcon.rconUsers, i = 0; i < MAX_RCONLOGINS ; rconadmin++, i++ ){ *infostring = 0; if(!*rconadmin->username) continue; Info_SetValueForKey(infostring, "type", "rconAdmin"); Info_SetValueForKey(infostring, "power", va("%i", rconadmin->power)); Info_SetValueForKey(infostring, "password", rconadmin->sha256); Info_SetValueForKey(infostring, "salt", rconadmin->salt); Info_SetValueForKey(infostring, "username", rconadmin->username); Q_strcat(buffer, size, infostring); Q_strcat(buffer, size, "\\\n"); } }
20,431
C
.c
616
29.603896
133
0.691058
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,884
cmd_completion.c
haithun_CoD4X17a_testing/cmd_completion.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include <string.h> #include "q_shared.h" #include "cmd_completion.h" #include "qcommon_io.h" /* =========================================== command line completion =========================================== */ #define MAX_TOKEN_CHARS 1024 /* ================== Field_Clear ================== */ void Field_Clear( field_t *edit ) { memset(edit->buffer, 0, MAX_EDIT_LINE); edit->cursor = 0; edit->scroll = 0; } static const char *completionString; static char shortestMatch[MAX_TOKEN_CHARS]; static int matchCount; // field we are working on, passed to Field_AutoComplete(&g_consoleCommand for instance) static field_t *completionField; /* =============== FindMatches =============== */ static void FindMatches( const char *s ) { int i; if ( Q_stricmpn( s, completionString, strlen( completionString ) ) ) { return; } matchCount++; if ( matchCount == 1 ) { Q_strncpyz( shortestMatch, s, sizeof( shortestMatch ) ); return; } // cut shortestMatch to the amount common with s for ( i = 0 ; shortestMatch[i] ; i++ ) { if ( i >= strlen( s ) ) { shortestMatch[i] = 0; break; } if ( tolower(shortestMatch[i]) != tolower(s[i]) ) { shortestMatch[i] = 0; } } } /* =============== PrintMatches =============== */ static void PrintMatches( const char *s ) { if ( !Q_stricmpn( s, shortestMatch, strlen( shortestMatch ) ) ) { Com_Printf( " %s\n", s ); } } /* =============== Field_FindFirstSeparator =============== */ static char *Field_FindFirstSeparator( char *s ) { int i; for( i = 0; i < strlen( s ); i++ ) { if( s[ i ] == ';' ) return &s[ i ]; } return NULL; } /* =============== Field_Complete =============== */ static qboolean Field_Complete( void ) { int completionOffset; if( matchCount == 0 ) return qtrue; completionOffset = strlen( completionField->buffer ) - strlen( completionString ); Q_strncpyz( &completionField->buffer[ completionOffset ], shortestMatch, sizeof( completionField->buffer ) - completionOffset ); completionField->cursor = strlen( completionField->buffer ); if( matchCount == 1 ) { Q_strcat( completionField->buffer, sizeof( completionField->buffer ), " " ); completionField->cursor++; return qtrue; } Com_Printf( "]%s\n", completionField->buffer ); return qfalse; } /* =============== Field_CompleteFilename =============== *//* void Field_CompleteFilename( const char *dir, const char *ext, qboolean stripExt, qboolean allowNonPureFilesOnDisk ) { matchCount = 0; shortestMatch[ 0 ] = 0; FS_FilenameCompletion( dir, ext, stripExt, FindMatches, allowNonPureFilesOnDisk ); if( !Field_Complete( ) ) FS_FilenameCompletion( dir, ext, stripExt, PrintMatches, allowNonPureFilesOnDisk ); } */ /* =============== Field_CompleteCommand =============== */ void Field_CompleteCommand( char *cmd, qboolean doCommands, qboolean doCvars ) { int completionArgument = 0; // Skip leading whitespace and quotes cmd = Com_SkipCharset( cmd, " \"" ); Cmd_TokenizeString( cmd ); completionArgument = Cmd_Argc( ); // If there is trailing whitespace on the cmd if( *( cmd + strlen( cmd ) - 1 ) == ' ' ) { completionString = ""; completionArgument++; } else completionString = Cmd_Argv( completionArgument - 1 ); if( completionArgument > 1 ) { const char *baseCmd = Cmd_Argv( 0 ); char *p; if( ( p = Field_FindFirstSeparator( cmd ) ) ) Field_CompleteCommand( p + 1, qtrue, qtrue ); // Compound command else Cmd_CompleteArgument( baseCmd, cmd, completionArgument ); }else{ if( completionString[0] == '\\' || completionString[0] == '/' ) completionString++; matchCount = 0; shortestMatch[ 0 ] = 0; if( strlen( completionString ) == 0 ){ Cmd_EndTokenizeString( ); return; } if( doCommands ) Cmd_CommandCompletion( FindMatches ); if( doCvars ) Cvar_ForEach(Cvar_CommandCompletionFind, NULL); if( !Field_Complete( ) ) { // run through again, printing matches if( doCommands ) Cmd_CommandCompletion( PrintMatches ); if( doCvars ) Cvar_ForEach(Cvar_CommandCompletionPrint, NULL); } } Cmd_EndTokenizeString( ); } /* =============== Field_AutoComplete Perform Tab expansion =============== */ void Field_AutoComplete( field_t *field ) { completionField = field; Field_CompleteCommand( completionField->buffer, qtrue, qtrue ); } /* ============ Cvar_CommandCompletion ============ */ void Cvar_CommandCompletionPrint( cvar_t const *cvar, void* none) { PrintMatches( cvar->name ); } void Cvar_CommandCompletionFind( cvar_t const *cvar, void* none) { FindMatches( cvar->name ); } /* ================== Cvar_CompleteCvarName ================== */ void Cvar_CompleteCvarName( char *args, int argNum ) { if( argNum == 2 ) { // Skip "<cmd> " char *p = Com_SkipTokens( args, 1, " " ); if( p > args ) Field_CompleteCommand( p, qfalse, qtrue ); } }
5,908
C
.c
220
24.477273
88
0.642463
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,886
qcommon_parsecmdline.c
haithun_CoD4X17a_testing/qcommon_parsecmdline.c
/* =========================================================================== Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include <string.h> #include "cmd.h" #include "cvar.h" /* ======================================================================== Command line parsing ======================================================================== */ #define MAX_CONSOLE_LINES 32 int com_numConsoleLines; char *com_consoleLines[MAX_CONSOLE_LINES]; /* =============== Com_StartupVariable Searches for command line parameters that are set commands. If match is not NULL, only that cvar will be looked for. That is necessary because cddir and basedir need to be set before the filesystem is started, but all other sets should be after execing the config and default. =============== */ void Com_StartupVariable( const char *match ) { int i; for (i=0 ; i < com_numConsoleLines ; i++) { Cmd_TokenizeString( com_consoleLines[i] ); if(!match || !strcmp(Cmd_Argv(1), match)) { if ( !strcmp( Cmd_Argv(0), "set" )){ Cvar_Set_f(); Cmd_EndTokenizeString(); continue; }else if( !strcmp( Cmd_Argv(0), "seta" ) ) { Cvar_SetA_f(); } } Cmd_EndTokenizeString(); } } /* ================= Com_AddStartupCommands Adds command line parameters as script statements Commands are seperated by + signs Returns qtrue if any late commands were added, which will keep the demoloop from immediately starting ================= */ qboolean Com_AddStartupCommands( void ) { int i; qboolean added; char buf[1024]; added = qfalse; // quote every token, so args with semicolons can work for (i=0 ; i < com_numConsoleLines ; i++) { if ( !com_consoleLines[i] || !com_consoleLines[i][0] ) { continue; } // set commands already added with Com_StartupVariable if ( !Q_stricmpn( com_consoleLines[i], "set", 3 )) { continue; } added = qtrue; Com_sprintf(buf,sizeof(buf),"%s\n",com_consoleLines[i]); Cbuf_ExecuteBuffer( 0,0, buf); } return added; } /* ================== Com_ParseCommandLine Break it up into multiple console lines ================== */ void Com_ParseCommandLine( char *commandLine ) { int inq = 0; com_consoleLines[0] = commandLine; com_numConsoleLines = 1; while ( *commandLine ) { if (*commandLine == '"') { inq = !inq; } // look for a + seperating character // if commandLine came from a file, we might have real line seperators if ( (*commandLine == '+' && !inq) || *commandLine == '\n' || *commandLine == '\r' ) { if ( com_numConsoleLines == MAX_CONSOLE_LINES ) { return; } com_consoleLines[com_numConsoleLines] = commandLine + 1; com_numConsoleLines = (com_numConsoleLines)+1; *commandLine = 0; } commandLine++; } }
3,695
C
.c
110
29.818182
95
0.611798
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,887
scr_vm_classfunc.c
haithun_CoD4X17a_testing/scr_vm_classfunc.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "q_shared.h" #include "player.h" #include "scr_vm.h" #include "g_shared.h" #include "misc.h" #include "g_sv_shared.h" #include "hl2rcon.h" __cdecl void ClientScr_SetSessionTeam(gclient_t* gcl, client_fields_t* gfl) { short index; int cid; if((void*)gcl - (void*)level.clients >= MAX_CLIENTS * sizeof(gclient_t)) { Scr_Error("Client is not pointing to the level.clients array."); return; } index = Scr_GetConstString(0); if(index == stringIndex.axis) gcl->sess.sessionTeam = TEAM_RED; else if(index == stringIndex.allies) gcl->sess.sessionTeam = TEAM_BLUE; else if(index == stringIndex.spectator) gcl->sess.sessionTeam = TEAM_SPECTATOR; else if(index == stringIndex.none) gcl->sess.sessionTeam = TEAM_FREE; else{ Scr_Error(va("'%s' is an illegal sessionteam string. Must be allies, axis, none, or spectator.", SL_ConvertToString(index))); return; } cid = gcl - level.clients; ClientUserinfoChanged( cid ); HL2Rcon_EventClientEnterTeam( cid, gcl->sess.sessionTeam ); }
2,095
C
.c
49
37.897959
133
0.65451
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,889
net_game_conf.h
haithun_CoD4X17a_testing/net_game_conf.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ // server.h //#include "../game/q_shared.h" //#include "../qcommon/qcommon.h" //#include "../game/g_public.h" //#include "../game/bg_public.h" //============================================================================= #ifndef __NET_GAMECONF_H__ #define __NET_GAMECONF_H__ #ifndef AUTHORIZE_SERVER_NAME #define AUTHORIZE_SERVER_NAME "cod4master.activision.com" #endif #ifndef PORT_AUTHORIZE #define PORT_AUTHORIZE 20800 #endif #define PORT_SERVER 28960 #define PROTOCOL_VERSION 6 #define MAX_MSGLEN 0x20000 // the svc_strings[] array in cl_parse.c should mirror this // // server to client // enum svc_ops_e { svc_nop, svc_gamestate, svc_configstring, // [short] [string] only in gamestate messages svc_baseline, // only in gamestate messages svc_serverCommand, // [string] to be executed by client game module svc_download, // [short] size [size bytes] svc_snapshot, svc_EOF, }; // // client to server // enum clc_ops_e { clc_move, // [[usercmd_t] clc_moveNoDelta, // [[usercmd_t] clc_clientCommand, // [string] message clc_EOF, clc_nop }; #endif
2,185
C
.c
59
34.576271
87
0.636105
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,891
g_sv_client.c
haithun_CoD4X17a_testing/g_sv_client.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "q_shared.h" #include "entity.h" #include "player.h" #include "plugin_handler.h" #include "g_sv_shared.h" #include "cvar.h" #include "server.h" #include <string.h> #include <stdlib.h> __cdecl void ClientSpawn(gentity_t* ent, vec3_t* px, vec3_t* py) { // ent->client->ps.gravity = 800;//(int)g_gravity->value; __asm__ __volatile__( " push %%ebp\n" " mov %%esp,%%ebp\n" " push %%edi\n" " push %%esi\n" " push %%ebx\n" " sub $0x12c,%%esp\n" " mov %%eax, 0x8(%%ebp)\n" " mov %%edx, 0xc(%%ebp)\n" " mov %%ecx, 0x10(%%ebp)\n" " sub $0x841ffe0,%%eax\n" " sar $0x2,%%eax\n" " imul $0x2c0685b5,%%eax,%%eax\n" " mov %%eax,-0x128(%%ebp)\n" " mov 0x8(%%ebp),%%eax\n" " mov 0x15c(%%eax),%%edi\n" " testb $0x4,0x14(%%edi)\n" " je ClientSpawn_loc1\n" " testl $0x300,0xb0(%%edi)\n" " jne ClientSpawn_loc2\n" "ClientSpawn_loc1:\n" " mov 0x8(%%ebp),%%ecx\n" " mov %%ecx,(%%esp)\n" " mov $0x80cb6fa, %%eax\n" " call *%%eax\n" " mov 0x8(%%ebp),%%eax\n" " cmpb $0x0,0xf4(%%eax)\n" " je ClientSpawn_loc3\n" " mov %%eax,(%%esp)\n" " mov $0x817d5e0, %%eax\n" " call *%%eax\n" "ClientSpawn_loc3:\n" " mov 0x8(%%ebp),%%ecx\n" " movl $0x3ff,0x7c(%%ecx)\n" " movzwl 0x836fe7c,%%eax\n" " mov %%eax,0x4(%%esp)\n" " mov %%ecx,%%eax\n" " add $0x170,%%eax\n" " mov %%eax,(%%esp)\n" " mov $0x81512fc, %%eax\n" " call *%%eax\n" " mov 0x8(%%ebp),%%eax\n" " movl $0x2810011,0x190(%%eax)\n" " orb $0x1,0xf6(%%eax)\n" " movb $0x0,0x16b(%%eax)\n" " mov %%eax,(%%esp)\n" " mov $0x80a4754, %%eax\n" " call *%%eax\n" " mov 0x8(%%ebp),%%ecx\n" " movb $0xb,0x16e(%%ecx)\n" " movl $0x1000,0x180(%%ecx)\n" " mov %%ecx,%%edx\n" " add $0x108,%%edx\n" " mov 0x820e804,%%eax\n" " mov %%eax,0x108(%%ecx)\n" " mov 0x820e808,%%eax\n" " mov %%eax,0x4(%%edx)\n" " mov 0x820e80c,%%eax\n" " mov %%eax,0x8(%%edx)\n" " add $0xc,%%edx\n" " mov 0x820e810,%%eax\n" " mov %%eax,0x114(%%ecx)\n" " mov 0x820e814,%%eax\n" " mov %%eax,0x4(%%edx)\n" " mov 0x820e818,%%eax\n" " mov %%eax,0x8(%%edx)\n" " mov 0xb0(%%edi),%%eax\n" " and $0x100002,%%eax\n" " mov %%eax,-0x124(%%ebp)\n" " lea 0x2f64(%%edi),%%esi\n" " movl $0x110,0x8(%%esp)\n" " mov %%esi,0x4(%%esp)\n" " lea -0x11c(%%ebp),%%ecx\n" " mov %%ecx,(%%esp)\n" " call memcpy\n" " mov 0x158(%%edi),%%eax\n" " mov %%eax,-0x120(%%ebp)\n" " mov 0x3168(%%edi),%%ebx\n" " movl $0x0,0x4(%%esp)\n" " lea 0x30f8(%%edi),%%eax\n" " mov %%eax,(%%esp)\n" " mov $0x808af6e, %%eax\n" " call *%%eax\n" //Memset gclient_s " movl $0x3184,0x8(%%esp)\n" " movl $0x0,0x4(%%esp)\n" " mov %%edi,(%%esp)\n" " mov $0x804a42c, %%eax\n" " call memset\n" //Set gravity to g_gravity /* " mov 0x84bcff4, %%eax\n" " cvttss2si 0xc(%%eax), %%eax\n" " mov %%eax, 0x58(%%edi)\n" */ " movl $0x110,0x8(%%esp)\n" " lea -0x11c(%%ebp),%%ecx\n" " mov %%ecx,0x4(%%esp)\n" " mov %%esi,(%%esp)\n" " mov $0x804a6bc, %%eax\n" " call *%%eax\n" " mov %%ebx,0x3168(%%edi)\n" " movl $0xffffffff,0x3074(%%edi)\n" " mov -0x120(%%ebp),%%eax\n" " add $0x1,%%eax\n" " mov %%eax,0x158(%%edi)\n" " mov 0x2fe8(%%edi),%%eax\n" " mov %%eax,0x150(%%edi)\n" " mov -0x124(%%ebp),%%ecx\n" " mov %%ecx,0xb0(%%edi)\n" " mov -0x128(%%ebp),%%eax\n" " mov %%eax,0x300c(%%edi)\n" " movl $0x3ff,0x3068(%%edi)\n" " mov %%eax,0xdc(%%edi)\n" " movl $0x3ff,0x59c(%%edi)\n" " lea 0x2f90(%%edi),%%esi\n" " mov %%esi,0x4(%%esp)\n" //Set jumpHeight to jump_height /* " mov %%edi,(%%esp)\n" " call Jump_SetDefaultHeight\n" */ " mov %%edi,%%eax\n" " sub 0x8370440,%%eax\n" " sar $0x2,%%eax\n" " imul $0x408b97a1,%%eax,%%eax\n" " mov %%eax,(%%esp)\n" " mov $0x817c5e0, %%eax\n" " call *%%eax\n" " xorl $0x2,0xb0(%%edi)\n" " movl $0x3c,0x114(%%edi)\n" " movl $0x42700000,0x118(%%edi)\n" " movl $0x0,0x11c(%%edi)\n" " movl $0x40c00000,0x648(%%edi)\n" " movl $0x3fe66666,0x64c(%%edi)\n" " movl $0x0,0xfc(%%edi)\n" " movl $0x0,0x100(%%edi)\n" " movl $0x0,0x4c(%%edi)\n" " movl $0x3ff,0x48(%%edi)\n" " mov 0xc(%%ebp),%%ecx\n" " mov %%ecx,0x4(%%esp)\n" " mov 0x8(%%ebp),%%eax\n" " mov %%eax,(%%esp)\n" " mov $0x80ca218, %%eax\n" " call *%%eax\n" " lea 0x1c(%%edi),%%edx\n" " mov 0xc(%%ebp),%%ecx\n" " mov (%%ecx),%%eax\n" " mov %%eax,0x1c(%%edi)\n" " mov 0x4(%%ecx),%%eax\n" " mov %%eax,0x4(%%edx)\n" " mov 0x8(%%ecx),%%eax\n" " mov %%eax,0x8(%%edx)\n" " orl $0x400,0xc(%%edi)\n" " mov 0x10(%%ebp),%%eax\n" " mov %%eax,0x4(%%esp)\n" " mov 0x8(%%ebp),%%eax\n" " mov %%eax,(%%esp)\n" " mov $0x80a77f6, %%eax\n" " call *%%eax\n" " mov 0x84bd008,%%eax\n" " mov 0xc(%%eax),%%ecx\n" " lea (%%ecx,%%ecx,1),%%edx\n" " add %%edx,%%edx\n" " mov %%ecx,%%eax\n" " shl $0x7,%%eax\n" " sub %%edx,%%eax\n" " add %%ecx,%%eax\n" " shl $0x3,%%eax\n" " add 0x837062c,%%eax\n" " mov %%eax,0x30cc(%%edi)\n" " mov 0x2f94(%%edi),%%eax\n" " mov %%eax,0x3088(%%edi)\n" " movl $0x1,0x8370460\n" " mov 0x837062c,%%eax\n" " mov %%eax,0x316c(%%edi)\n" " mov 0x837062c,%%eax\n" " mov %%eax,0x2f90(%%edi)\n" " mov 0x837062c,%%eax\n" " sub $0x64,%%eax\n" " mov %%eax,(%%edi)\n" " mov 0x8(%%ebp),%%ecx\n" " mov %%ecx,(%%esp)\n" " mov $0x80a68b8, %%eax\n" " call *%%eax\n" " mov %%esi,0x4(%%esp)\n" " mov 0x8(%%ebp),%%eax\n" " mov %%eax,(%%esp)\n" " mov $0x80a5c1a, %%eax\n" " call *%%eax\n" " movl $0x0,0x8370460\n" " movl $0x1,0xc(%%esp)\n" " movl $0x1,0x8(%%esp)\n" " mov 0x8(%%ebp),%%ecx\n" " mov %%ecx,0x4(%%esp)\n" " mov %%edi,(%%esp)\n" " mov $0x8052940, %%eax\n" " call *%%eax\n" " jmp ClientSpawn_Exit\n" "ClientSpawn_loc2:\n" " mov 0x59c(%%edi),%%eax\n" " lea (%%eax,%%eax,4),%%edx\n" " add %%edx,%%edx\n" " add %%edx,%%edx\n" " sub %%eax,%%edx\n" " mov %%edx,%%ecx\n" " shl $0x5,%%ecx\n" " add %%ecx,%%edx\n" " add %%eax,%%edx\n" " add 0x8370444,%%edx\n" " mov %%edx,(%%esp)\n" " mov $0x80b7866, %%eax\n" " call *%%eax\n" " jmp ClientSpawn_loc1\n" "ClientSpawn_Exit:\n" " add $0x12c,%%esp\n" " pop %%ebx\n" " pop %%esi\n" " pop %%edi\n" " pop %%ebp\n" ::"a"(ent), "d"(px), "c"(py)); // ent->client->ps.gravity = 800; client_t *cl = &svs.clients[ent->s.number]; ent->client->sess.lastFollowedClient = -1; //remove the last followed player number if we self have respawned if(svs.time - cl->enteredWorldTime > 800){ //First spawn after map reloading PHandler_Event(PLUGINS_ONCLIENTSPAWN, ent); if(!cl->firstSpawn){ //First spawn after connecting to server G_ShowMotd( ent->s.number ); } cl->firstSpawn = qtrue; } int i; gentity_t* followers; for(i = 0, followers = g_entities; i < g_maxclients->integer; i++, followers++)//let refollow all spectors me who have prior followed me { if(followers->client->sess.lastFollowedClient == ent->s.number) { Cmd_FollowClient_f(followers, ent->s.number); } } //InsertPluginEvent /* if(cl->needPassword){ ent->client->freezeControls = qtrue; if(!cl->needPasswordNotified){ PlayerAuthByPassword(cl, ent, ""); } }*/ } static void ClientCleanName( const char *in, char *out, int outSize, qboolean allowcolor ); /* =========== ClientUserInfoChanged Called from ClientConnect when the player first connects and directly by the server system when the player updates a userinfo variable. The game can override any of the settings and call trap_SetUserinfo if desired. ============ */ __cdecl void ClientUserinfoChanged( int clientNum ) { gentity_t *ent; char *s; gclient_t *client; char userinfo[MAX_INFO_STRING]; ent = g_entities + clientNum; client = ent->client; client->ps.clientNum = clientNum; SV_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) ); // check for malformed or illegal info strings if ( !Info_Validate( userinfo ) ) { strcpy( userinfo, "\\name\\badinfo" ); } // check for local client /* s = Info_ValueForKey( userinfo, "ip" ); if ( s && !strcmp( s, "localhost" ) ) { client->pers.localClient = qtrue; } */ // check the item prediction s = Info_ValueForKey( userinfo, "cg_predictItems" ); if ( !atoi( s ) ) { client->pers.predictItemPickup = qfalse; } else { client->pers.predictItemPickup = qtrue; } // set name s = Info_ValueForKey( userinfo, "name" ); if(client->sess.sessionTeam == TEAM_RED || client->sess.sessionTeam == TEAM_BLUE) ClientCleanName( s, client->pers.netname, sizeof( client->pers.netname ) , qfalse); else ClientCleanName( s, client->pers.netname, sizeof( client->pers.netname ) , qtrue); Q_strncpyz(client->sess.netname, client->pers.netname, sizeof( client->sess.netname )); /* [840cccc] = clientNum; [840ccd0] = name; [840cce0] = sess.team; */ /* if ( client->pers.connected == CON_CONNECTED ) { if ( strcmp( oldname, client->pers.netname ) ) { trap_SendServerCommand( -1, va( "print \"[lof]%s" S_COLOR_WHITE " [lon]renamed to[lof] %s\n\"", oldname, client->pers.netname ) ); } } */ } /* =========== ClientCheckName ============ */ static void ClientCleanName( const char *in, char *out, int outSize, qboolean allowColor ) { int len, colorlessLen; char ch; char *p; int spaces; //save room for trailing null byte outSize--; len = 0; colorlessLen = 0; p = out; *p = 0; spaces = 0; while ( 1 ) { ch = *in++; if ( !ch ) { break; } // don't allow leading spaces if ( !*p && ch == ' ' ) { continue; } // check colors if ( ch == Q_COLOR_ESCAPE ) { // solo trailing carat is not a color prefix if ( !*in ) { break; } if(allowColor) { // don't allow black in a name, period if ( ColorIndex( *in ) == 0 ) { in++; continue; } }else{ if ( ColorIndex( *in ) >= 0 && ColorIndex( *in ) <= 9) { in++; continue; } } // make sure room in dest for both chars if ( len > outSize - 2 ) { break; } *out++ = ch; *out++ = *in++; len += 2; continue; } // don't allow too many consecutive spaces if ( ch == ' ' ) { spaces++; if ( spaces > 3 ) { continue; } } else { spaces = 0; } if ( len > outSize - 1 ) { break; } *out++ = ch; colorlessLen++; len++; } *out = 0; // don't allow empty names if ( *p == 0 || colorlessLen == 0 ) { Q_strncpyz( p, "UnnamedPlayer", outSize ); } }
11,567
C
.c
413
26.021792
137
0.577176
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,892
net_game.c
haithun_CoD4X17a_testing/net_game.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "q_shared.h" #include "qcommon.h" #include "qcommon_io.h" #include "msg.h" #include "sys_net.h" #include "server.h" #include "net_game.h" #include "net_game_conf.h" void NET_UDPPacketEvent(netadr_t* from, void* data, int len) { msg_t msg; msg.data = data; msg.cursize = len; msg.maxsize = len; msg.readcount = 0; msg.bit = 0; msg.readonly = qtrue; msg.overflowed = qfalse; SV_PacketEvent(from, &msg); } unsigned int NET_TimeGetTime() { return (unsigned int)com_frameTime; } /* ================= NET_ReadTcpPackets ================= */ #define MAX_TCPEVENTS 4 typedef struct { int serviceId; tcpclientstate_t (*tcpauthevent)(netadr_t* from, msg_t* msg, int socketfd, int *connectionId); qboolean (*tcpevent)(netadr_t* from, msg_t* msg, int socketfd, int connectionId); void (*tcpconncloseevent)(netadr_t* from, int socketfd, int connectionId); }tcpevent_t; tcpevent_t tcpevents[MAX_TCPEVENTS]; void NET_TCPConnectionClosed(netadr_t* adr, int socketfd, int connectionId, int serviceId) { int i; for(i = 0; i < MAX_TCPEVENTS; i++) { if(tcpevents[i].serviceId == serviceId) { if(tcpevents[i].tcpconncloseevent != NULL) tcpevents[i].tcpconncloseevent(adr, socketfd, connectionId); return; } } } tcpclientstate_t NET_TCPAuthPacketEvent(netadr_t* from, byte* bufData, int len, int socketfd, int* connectionId, int *serviceId) { int i; msg_t msg; tcpclientstate_t ret; msg.data = bufData; msg.cursize = len; msg.maxsize = len; msg.readcount = 0; msg.bit = 0; msg.readonly = qtrue; msg.overflowed = qfalse; Com_DPrintf("Packet event from: %s\n", NET_AdrToString(from)); for(i = 0; i < MAX_TCPEVENTS; i++) { ret = tcpevents[i].tcpauthevent(from, &msg, socketfd, connectionId); if(ret != TCP_AUTHNOTME) { *serviceId = tcpevents[i].serviceId; return ret; } } Com_DPrintf("^5Bad TCP-Packet from: %s\n", NET_AdrToString(from)); return TCP_AUTHBAD; //Close connection } void NET_TCPPacketEvent(netadr_t* from, byte* bufData, int len, int socketfd, int connectionId, int serviceId) { int i; msg_t msg; for(i = 0; i < MAX_TCPEVENTS; i++) { if(tcpevents[i].serviceId == serviceId) { msg.data = bufData; msg.cursize = len; msg.maxsize = len; msg.readcount = 0; msg.bit = 0; msg.readonly = qtrue; msg.overflowed = qfalse; if(tcpevents[i].tcpevent(from, &msg, socketfd, connectionId)) { NET_TcpCloseSocket(socketfd); } return; } } Com_PrintError("NET_TCPPacketEvent: Bad serviceId: %d\n", serviceId); NET_TcpCloseSocket(socketfd); return; //Close connection } void NET_TCPAddEventType( qboolean (*tcpevent)(netadr_t* from, msg_t* msg, int socketfd, int connectionId), tcpclientstate_t (*tcpauthevent)(netadr_t* from, msg_t* msg, int socketfd, int *connectionId), void (*tcpconncloseevent)(netadr_t* from, int socketfd, int connectionId), int serviceId ){ int i; if(tcpevent == NULL || tcpauthevent == NULL) { Com_Error(ERR_FATAL, "NET_TCPAddEventType: NULL tcpevent handler or NULL tcpauthevent handler"); return; } for(i = 0; i < MAX_TCPEVENTS; i++) { if(tcpevents[i].tcpevent == tcpevent) { Com_Error(ERR_FATAL, "NET_TCPAddEventType: Attempt to add an already defined redirect function twice."); return; } if(tcpevents[i].tcpevent == NULL) { tcpevents[i].tcpevent = tcpevent; tcpevents[i].tcpauthevent = tcpauthevent; tcpevents[i].tcpconncloseevent = tcpconncloseevent; tcpevents[i].serviceId = serviceId; return; } } Com_Error(ERR_FATAL, "NET_TCPAddEventType: Out of redirect handles. Increase MAX_TCPEVENTS to add more redirect destinations"); }
5,389
C
.c
148
28.52027
131
0.595462
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,896
scr_vm_callbacks.c
haithun_CoD4X17a_testing/scr_vm_callbacks.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "q_shared.h" #include "entity.h" #include "scr_vm.h" //Only CoD4 gamescript callback functions here qboolean Scr_PlayerSay(gentity_t* from, int mode, const char* text){ int callback; int threadId; callback = script_CallBacks_new[SCR_CB_NEW_SAY]; if(!callback){ return qfalse; } if(!say_forwardAll) { if(*text != '/' && *text != '.' && *text != '&') return qfalse; Scr_AddString(&text[1]); }else{ Scr_AddString(text); } if(mode == 0) Scr_AddBool( qfalse ); else Scr_AddBool( qtrue ); threadId = Scr_ExecEntThread(from, callback, 1); Scr_FreeThread(threadId); return qtrue; }
1,695
C
.c
43
34.186047
87
0.624847
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,900
sys_cod4loader.h
haithun_CoD4X17a_testing/sys_cod4loader.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef __SYS_COD4LOADER_H__ #define __SYS_COD4LOADER_H__ void Sys_LoadImage(void); #endif
1,077
C
.c
20
50.05
87
0.651096
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,901
scr_vm_functions.c
haithun_CoD4X17a_testing/scr_vm_functions.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include "q_shared.h" #include "qcommon_io.h" #include "qcommon.h" #include "g_hud.h" #include "scr_vm.h" #include "cmd.h" #include "server.h" #include "maxmind_geoip.h" #include "q_platform.h" #include "g_sv_shared.h" #include "cvar.h" #include "misc.h" #include "sha256.h" #include <string.h> #include <time.h> /* ============ PlayerCmd_GetUid Returns the players Uid. Will only work with valid defined authserver or if another cod4-plugin is loaded with uid support. If server supports no UIDs this function will return -1 Usage: int = self getUid(); ============ */ void PlayerCmd_GetUid(scr_entref_t arg){ gentity_t* gentity; int entityNum = 0; int uid; if(HIWORD(arg)){ Scr_ObjectError("Not an entity"); }else{ entityNum = LOWORD(arg); gentity = &g_entities[entityNum]; if(!gentity->client){ Scr_ObjectError(va("Entity: %i is not a player", entityNum)); } } if(Scr_GetNumParam()){ Scr_Error("Usage: self getUid()\n"); } if(!SV_UseUids()){ Scr_AddInt(-1); return; } uid = SV_GetUid(entityNum); Scr_AddInt(uid); } /* ============ PlayerCmd_GetUserinfo Returns the requested players userinfo value. Example: name = self getuserinfo("name"); Example: myucvar = self getuserinfo("myucvar"); myucvar has to be set onto the players computer prior with setu myucvar "" so it can be queried in userinfo The userinfo will automatically update if myucvar changes onto the client computer. This can be used to transfer text from client to server. Usage: string = self getUserinfo(userinfo key <string>); ============ */ void PlayerCmd_GetUserinfo(scr_entref_t arg){ gentity_t* gentity; int entityNum = 0; client_t *cl; if(HIWORD(arg)){ Scr_ObjectError("Not an entity"); }else{ entityNum = LOWORD(arg); gentity = &g_entities[entityNum]; if(!gentity->client){ Scr_ObjectError(va("Entity: %i is not a player", entityNum)); } } if(Scr_GetNumParam() != 1){ Scr_Error("Usage: self getUserinfo( <string> )\n"); } char* u_key = Scr_GetString(0); cl = &svs.clients[entityNum]; char* value = Info_ValueForKey(cl->userinfo, u_key); Scr_AddString(value); } /* ============ PlayerCmd_GetPing Returns the current measured scoreboard ping of this player. Usage: int = self getPing(); ============ */ void PlayerCmd_GetPing(scr_entref_t arg){ gentity_t* gentity; int entityNum = 0; client_t *cl; if(HIWORD(arg)){ Scr_ObjectError("Not an entity"); }else{ entityNum = LOWORD(arg); gentity = &g_entities[entityNum]; if(!gentity->client){ Scr_ObjectError(va("Entity: %i is not a player", entityNum)); } } if(Scr_GetNumParam()){ Scr_Error("Usage: self getPing()\n"); } cl = &svs.clients[entityNum]; Scr_AddInt(cl->ping); } /* ============ PlayerCmd_SetGravity Changes the value of gravity for this player. Usage: self setgravity( <int> ); ============ */ void PlayerCmd_SetGravity(scr_entref_t arg){ gentity_t* gentity; int entityNum = 0; int gravity; if(HIWORD(arg)){ Scr_ObjectError("Not an entity"); return; }else{ entityNum = LOWORD(arg); gentity = &g_entities[entityNum]; if(!gentity->client){ Scr_ObjectError(va("Entity: %i is not a player", entityNum)); return; } } if(Scr_GetNumParam() != 1){ Scr_Error("Usage: self setgravity( <integer> )\n"); } gravity = Scr_GetInt(0); if(gravity < 1 || gravity > 50000){ Scr_Error("setgravity range is between 1 and 50000\n"); return; } Pmove_ExtendedTurnOn(); svs.clients[entityNum].gravity = gravity; } /* ============ PlayerCmd_SetJumpHeight Changes the value of jump_height for this player. Usage: self setjumpheight( <int> ); ============ */ void PlayerCmd_SetJumpHeight(scr_entref_t arg){ gentity_t* gentity; int entityNum = 0; int height; if(HIWORD(arg)){ Scr_ObjectError("Not an entity"); return; }else{ entityNum = LOWORD(arg); gentity = &g_entities[entityNum]; if(!gentity->client){ Scr_ObjectError(va("Entity: %i is not a player", entityNum)); return; } } if(Scr_GetNumParam() != 1){ Scr_Error("Usage: self setjumpheight( <integer> )\n"); } height = Scr_GetInt(0); if(height < 0 || height > 50000){ Scr_Error("setjumpheight range is between 1 and 50000\n"); return; } Pmove_ExtendedTurnOn(); svs.clients[entityNum].jumpHeight = height; } /* ============ PlayerCmd_SetMoveSpeed Changes the value of movement speed for this player. Usage: self setmovespeed( <int> ); ============ */ void PlayerCmd_SetMoveSpeed(scr_entref_t arg){ gentity_t* gentity; int entityNum = 0; int speed; if(HIWORD(arg)){ Scr_ObjectError("Not an entity"); return; }else{ entityNum = LOWORD(arg); gentity = &g_entities[entityNum]; if(!gentity->client){ Scr_ObjectError(va("Entity: %i is not a player", entityNum)); return; } } if(Scr_GetNumParam() != 1){ Scr_Error("Usage: self setmovespeed( <integer> )\n"); } speed = Scr_GetInt(0); if(speed < 0 || speed > 50000){ Scr_Error("setmovespeed range is between 0 and 50000\n"); return; } Pmove_ExtendedTurnOn(); svs.clients[entityNum].playerMoveSpeed = speed; } /* ============ PlayerCmd_GetGeoLocation resolves country from IP address ============ */ typedef enum{ SCR_GEOIP_CODE, SCR_GEOIP_CODE3, SCR_GEOIP_COUNTRYNAME, SCR_GEOIP_CONTINENT, SCR_GEOIP_INDEX }scr_geoip_type_t; void PlayerCmd_GetGeoLocation(scr_entref_t arg){ gentity_t* gentity; int entityNum = 0; int rettype; int locIndex; const char* countryname; if(HIWORD(arg)){ Scr_ObjectError("Not an entity"); return; }else{ entityNum = LOWORD(arg); gentity = &g_entities[entityNum]; if(!gentity->client){ Scr_ObjectError(va("Entity: %i is not a player", entityNum)); return; } } if(Scr_GetNumParam() != 1){ Scr_Error("Usage: self getgeolocation( <integer> )\n"); } rettype = Scr_GetInt(0); locIndex = _GeoIP_seek_record(BigLong(*(unsigned long*)&svs.clients[entityNum].netchan.remoteAddress.ip)); switch(rettype){ case SCR_GEOIP_CODE: countryname = _GeoIP_country_code(locIndex); break; case SCR_GEOIP_CODE3: countryname = _GeoIP_country_code3(locIndex); break; case SCR_GEOIP_COUNTRYNAME: countryname = _GeoIP_country_name(locIndex); break; case SCR_GEOIP_CONTINENT: countryname = _GeoIP_continent_name(locIndex); break; default: Scr_AddInt(locIndex); return; } Scr_AddString(countryname); } /* ============ GScr_StrTokByPixLen Returns an array of the string that got sperated in tokens. It will count the width of given string and will tokenize it so that it will never exceed the given limit. This function tries to separate the string so that words remains complete Usage: array = StrTokByPixLen(string <string>, codPixelCount <float>); ============ */ #define MAX_LINEBREAKS 32 void GScr_StrTokByPixLen(){ char buffer[2048]; char *string = buffer; if(Scr_GetNumParam() != 2){ Scr_Error("Usage: StrTokByPixLen(<string>, <float>)"); } char* src = Scr_GetString(0); if(!src) return; else Q_strncpyz(buffer, src, sizeof(buffer)); char* countstring = string; char* lastWordSpace = string; int lineBreakIndex = 0; int lWSHalfPixelCounter = 0; int halfPixelCounter = 0; int maxHalfPixel = 2.0 * Scr_GetFloat(1); Scr_MakeArray(); while( *countstring ){ switch(*countstring){ case '\'': halfPixelCounter += 2; break; case 'i': case 'j': case 'l': case '.': case ',': case ':': case ';': case '_': case '%': halfPixelCounter += 4; break; case 'f': case 'I': case '-': case '|': halfPixelCounter += 5; break; case 't': case 'r': case '!': case '/': case '\\': case '"': halfPixelCounter += 6; break; case '(': case ')': case '[': case ']': halfPixelCounter += 7; break; case 'T': case '{': case '}': case '*': halfPixelCounter += 8; break; case 'a': case 'c': case 'g': case 'k': case 's': case 'v': case 'x': case 'z': case 'F': case 'J': case 'L': case 'Y': case 'Z': halfPixelCounter += 9; break; case ' ': /*Save the positions of the last recent wordspacer*/ lWSHalfPixelCounter = halfPixelCounter; lastWordSpace = countstring; case 'd': case 'h': case 'n': case 'A': case 'P': case 'S': case 'V': case 'X': case '?': halfPixelCounter += 10; break; case 'B': case 'D': case 'G': case 'K': case 'O': case 'Q': case 'R': case 'U': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '$': case '<': case '>': case '=': case '+': case '^': case '~': halfPixelCounter += 11; break; case 'H': case 'N': case '#': halfPixelCounter += 12; break; case 'w': case '&': halfPixelCounter += 13; break; case 'W': case 'M': case '@': halfPixelCounter += 14; break; case 'm': halfPixelCounter += 15; default: halfPixelCounter += 12; } if(halfPixelCounter >= maxHalfPixel){ if(lineBreakIndex >= MAX_LINEBREAKS){ break; //Cut here - no overrun } if(lWSHalfPixelCounter >= maxHalfPixel / 3){ //we have a space between words inside the upper half string length *lastWordSpace = 0; //terminate it Scr_AddString(string); //setting the beginning of string in our array Scr_AddArray(); string = &lastWordSpace[1]; countstring = &lastWordSpace[1]; lWSHalfPixelCounter = 0; halfPixelCounter = 0; }else{ //we couln't find a space inside the upper half string length *countstring = 0; //Mhh it is complicated to seperate the complete string here. We will just thrash one character Scr_AddString(string); Scr_AddArray(); string = &countstring[1]; countstring = &countstring[1]; lWSHalfPixelCounter = 0; halfPixelCounter = 0; } lineBreakIndex++; }else{ countstring++; } } if(*string){ Scr_AddString(string); Scr_AddArray(); } } /* ============ GScr_StrTokByLen Returns an array of the string that got sperated in tokens. It will count the number of characters of given string and will tokenize it so that it will never exceed the given limit. This function tries to separate the string so that words remains complete Usage: array = StrTokByLen(string <string>, maxcharacter count <int>); ============ */ void GScr_StrTokByLen(){ char buffer[2048]; unsigned char lastColor = '7'; char *outputstr = buffer; if(Scr_GetNumParam() != 2){ Scr_Error("Usage: StrTokByLen(<string>, <int>)"); } char* src = Scr_GetString(0); char* inputstr = src; int lineBreakIndex = 0; int i = 0; int j = 0; int overflowcnt = 2; int lSCounter = 0; int lSCounterReal = 0; int limit = Scr_GetInt(1); Scr_MakeArray(); outputstr[0] = '^'; outputstr[1] = lastColor; outputstr[2] = 0; while( inputstr[i]){ if(overflowcnt >= (sizeof(buffer) -4)){ outputstr[i] = 0; outputstr[i+1] = 0; outputstr[i+2] = 0; break; } if( inputstr[i] == ' '){ /*Save the positions of the last recent wordspacer*/ lSCounter = i; lSCounterReal = j; } if(inputstr[i] == '^' && inputstr[i+1] >= '0' && inputstr[i+1] <= '9'){ outputstr[i+2] = inputstr[i]; i++; lastColor = inputstr[i]; outputstr[i+2] = inputstr[i]; i++; overflowcnt += 2; continue; } if( j >= limit){ if(lineBreakIndex >= MAX_LINEBREAKS){ break; //Cut here - no overrun } if(lSCounterReal >= (limit / 2)){ //we have a space between words inside the upper half string length outputstr[lSCounter+2] = 0; Scr_AddString(outputstr); //setting the beginning of string in our array Scr_AddArray(); inputstr = &inputstr[lSCounter+1]; outputstr = &outputstr[i+3]; outputstr[0] = '^'; outputstr[1] = lastColor; outputstr[2] = 0; overflowcnt += 3; lSCounter = 0; lSCounterReal = 0; i = 0; j = 0; }else{ //we couln't find a space inside the upper half string length outputstr[i+2] = 0; //Exception if broken inside colorcode is needed Scr_AddString(outputstr); Scr_AddArray(); inputstr = &inputstr[i]; outputstr = &outputstr[i+3]; outputstr[0] = '^'; outputstr[1] = lastColor; outputstr[2] = 0; overflowcnt += 3; lSCounter = 0; lSCounterReal = 0; i = 0; j = 0; } lineBreakIndex++; }else{ j++; outputstr[i+2] = inputstr[i]; i++; overflowcnt++; } } if( outputstr[2] ){ outputstr[i+2] = 0; Scr_AddString(outputstr); Scr_AddArray(); } } /* ============ GScr_StrPixLen This function measures the average length of a given string if it would getting printed Usage: float = StrPixLen(string <string>); ============ */ void GScr_StrPixLen(){ if(Scr_GetNumParam() != 1){ Scr_Error("Usage: StrPixLen(<string>)"); } char* string = Scr_GetString(0); int halfPixelCounter = 0; while( *string ){ switch(*string){ case '\'': halfPixelCounter += 2; break; case 'i': case 'j': case 'l': case '.': case ',': case ':': case ';': case '_': case '%': halfPixelCounter += 4; break; case 'f': case 'I': case '-': case '|': halfPixelCounter += 5; break; case 't': case 'r': case '!': case '/': case '\\': case '"': halfPixelCounter += 6; break; case '(': case ')': case '[': case ']': halfPixelCounter += 7; break; case 'T': case '{': case '}': case '*': halfPixelCounter += 8; break; case 'a': case 'c': case 'g': case 'k': case 's': case 'v': case 'x': case 'z': case 'F': case 'J': case 'L': case 'Y': case 'Z': halfPixelCounter += 9; break; case ' ': /*Save the positions of the last recent wordspacer*/ case 'd': case 'h': case 'n': case 'A': case 'P': case 'S': case 'V': case 'X': case '?': halfPixelCounter += 10; break; case 'B': case 'D': case 'G': case 'K': case 'O': case 'Q': case 'R': case 'U': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '$': case '<': case '>': case '=': case '+': case '^': case '~': halfPixelCounter += 11; break; case 'H': case 'N': case '#': halfPixelCounter += 12; break; case 'w': case '&': halfPixelCounter += 13; break; case 'W': case 'M': case '@': halfPixelCounter += 14; break; case 'm': halfPixelCounter += 15; default: halfPixelCounter += 12; } string++; } float result = (float)halfPixelCounter / 2.0; Scr_AddFloat(result); } /* ============ GScr_StrColorStrip Directly cleans the given string from all colorscodes. The original string will be modified! If it is required that the original string remains you need to create a copy of string prior with copystr() Usage: void = StrColorStrip(string <string>); ============ */ void GScr_StrColorStrip(){ char buffer[2048]; if(Scr_GetNumParam() != 1){ Scr_Error("Usage: StrColorStrip(<string>)\n"); } char* string = Scr_GetString(0); int i; Q_strncpyz(buffer, string, sizeof(buffer)); for(i=0; buffer[i]; i++){ if(buffer[i] == '^' && buffer[i+1] >= '0' && buffer[i+1] <= '9'){ buffer[i+1] = '7'; } } Scr_AddString(buffer); } /* ============ GScr_StrRepl This functions finds in a given mainstring all occurrences of a given searchstring and replace those with a given replacementstring This function returns the resulting string. The mainstring will stay unaffected. Usage: string = GScr_StrRepl(mainstring <string>, search <string>, replacement <string>); ============ */ void GScr_StrRepl(){ char buffer[2048]; if(Scr_GetNumParam() != 3){ Scr_Error("Usage: StrReplace(<string>, <string>, <string>)\n"); } char* string = Scr_GetString(0); char* find = Scr_GetString(1); char* replacement = Scr_GetString(2); Q_strnrepl(buffer, sizeof(buffer), string, find, replacement); buffer[sizeof(buffer) -1] = 0; Scr_AddString(buffer); } /* ============ GScr_CopyString Creates a real copy of the given string and returns the location of the newly created copy Usage: string = CopyStr(string <string>); ============ */ void GScr_CopyString(){ if(Scr_GetNumParam() != 1){ Scr_Error("Usage: CopyStr(<string>)\n"); } Scr_AddString(Scr_GetString(0)); } /* ============ GScr_GetRealTime Returns the current time in seconds since 01/01/2012 UTC Usage: int = getRealTime(); ============ */ void GScr_GetRealTime(){ if(Scr_GetNumParam()){ Scr_Error("Usage: getRealTime()\n"); } Scr_AddInt(Com_GetRealtime() - 1325376000); } /* ============ GScr_TimeToString Returns the current unix style time Usage: string = TimeToString(int <realtime>, int <UTC/Local>, string <format>) ============ realtime is the value you can retrive with getRealTime() UTC/Local: a value of 0 means the time will be displayed in UTC timezone UTC/Local: a value of 1 means the time will be displayed in Local timezone format: this is a string to describe how the time will be displayed. For more informations see for the C function: strftime() For example here: http://cplusplus.com/reference/ctime/strftime */ void GScr_TimeToString(){ char timestring[128]; char* format; struct tm *time_s; int zone; if(Scr_GetNumParam() != 3){ Scr_Error("Usage: TimeToString(<realtime>, <UTC/Local>, <format>)\n"); } time_t time = Scr_GetInt(0) + 1325376000; zone = Scr_GetInt(1); format = Scr_GetString(2); if(zone) time_s = gmtime( &time ); else time_s = localtime( &time ); strftime( timestring, sizeof(timestring), format, time_s ); Scr_AddString(timestring); } /* ============ GScr_SHA256 This function calculates the SHA256 sum of the given input textstring Usage: string = sha256(string <input>); ============ */ void GScr_SHA256(){ const char *hash; if(Scr_GetNumParam() != 1){ Scr_Error("Usage: sha256(<input text>)\n"); } char* input = Scr_GetString(0); hash = Com_SHA256(input); Scr_AddString(hash); } /* ============ GScr_CbufAddText Execute the given command on server as console command Usage: void = exec(string <string>); ============ */ void GScr_CbufAddText(){ char string[1024]; if(Scr_GetNumParam() != 1){ Scr_Error("Usage: exec(<string>)\n"); } Com_sprintf(string, sizeof(string), "%s\n",Scr_GetString(0)); Cbuf_AddText(EXEC_NOW, string); } /* ============ GScr_FS_FOpen Opens a file(name) inside current FS_GameDir. Mode is selectable. It can be either "read", "write", "append". It returns on success an integer greater 0. This is the filehandle. Usage: int = FS_FOpen(string <filename>, string <mode>) ============ */ void GScr_FS_FOpen(){ fileHandle_t fh = 0; if(Scr_GetNumParam() != 2) Scr_Error("Usage: FS_FOpen(<filename>, <mode>)\n"); char* filename = Scr_GetString(0); char* mode = Scr_GetString(1); if(!Q_stricmp(mode, "read")){ fh = Scr_OpenScriptFile( filename, SCR_FH_FILE, FS_READ); }else if(!Q_stricmp(mode, "write")){ fh = Scr_OpenScriptFile( filename, SCR_FH_FILE, FS_WRITE); }else if(!Q_stricmp(mode, "append")){ fh = Scr_OpenScriptFile( filename, SCR_FH_FILE, FS_APPEND); }else{ Scr_Error("FS_FOpen(): invalid mode. Valid modes are: read, write, append\n"); } if(!fh){ Com_DPrintf("Scr_FS_FOpen() failed\n"); } Scr_AddInt(fh); } /* ============ GScr_FS_FClose Closes an already opened file. Opened files need to be closed after usage This function returns nothing. It needs a filehandle as argument Usage: FS_FClose(int <filehandle>) ============ */ void GScr_FS_FClose(){ if(Scr_GetNumParam() != 1) Scr_Error("Usage: FS_FClose(<filehandle>)\n"); fileHandle_t fh = Scr_GetInt(0); Scr_CloseScriptFile(fh); } /* ============ GScr_FS_FCloseAll Closes all opened files with one call. Opened files need to be closed after usage This function returns nothing. It needs no arguments Usage: FS_FCloseAll() ============ */ void GScr_FS_FCloseAll(){ int i; for(i=0; i < MAX_SCRIPT_FILEHANDLES; i++) { Scr_CloseScriptFile(i); } } /* ============ GScr_FS_TestFile This function only test whether a filename exists. It must be a file inside the FS_GameDir. This function returns true if file exists otherwise false. Usage: FS_TestFile(string <filename>) ============ */ void GScr_FS_TestFile(){ int fileExists; if(Scr_GetNumParam() != 1) Scr_Error("Usage: FS_TestFile(<filename>)\n"); char* filename = Scr_GetString(0); fileExists = FS_FOpenFileRead(filename, NULL); if(fileExists == qtrue) Scr_AddBool(qtrue); else Scr_AddBool(qfalse); } /* ============ GScr_FS_ReadLine This function reads a line from opened file and return a string. This function returns undefined if file can not be read or is at end of file. Otherwise it just returns the line as string without the terminating \n character Usage: FS_ReadFile(int <filehandle>) ============ */ void GScr_FS_ReadLine(){ char buffer[2048]; int ret; if(Scr_GetNumParam() != 1) Scr_Error("Usage: FS_ReadLine(<filehandle>)\n"); fileHandle_t fh = Scr_GetInt(0); *buffer = 0; ret = Scr_FS_ReadLine(buffer, sizeof(buffer), fh); if(ret < 1 ) Scr_AddUndefined(); else if(*buffer == 0) Scr_AddString(""); else{ int len = strlen(buffer); if(buffer[len -1] == '\n') buffer[len -1] = 0; Scr_AddString(buffer); } } /* ============ GScr_FS_WriteLine This function writes/append a line to an opened file. This function returns "" if file can not be read or is already at end of file. It returns " " if an empty line got read. Otherwise it just returns the line Usage: FS_WriteLine(int <filehandle>, string <data>) ============ */ void GScr_FS_WriteLine(){ int ret; char buffer[2048]; if(Scr_GetNumParam() != 2) Scr_Error("Usage: FS_WriteLine(<filehandle>, <data>)\n"); fileHandle_t fh = Scr_GetInt(0); char* data = Scr_GetString(1); Com_sprintf(buffer, sizeof(buffer), "%s\n", data); ret = Scr_FS_Write(buffer, strlen(buffer), fh); if(!ret) { Com_DPrintf("^2Scr_FS_WriteLine() failed\n"); Scr_AddBool(qfalse); }else{ Scr_AddBool(qtrue); } } /* ============ GScr_FS_Remove This function deletes a file. This function returns true on success otherwise it returns false. Usage: FS_Remove(string <filename>) ============ */ void GScr_FS_Remove(){ char filename[MAX_QPATH]; if(Scr_GetNumParam() != 1) Scr_Error("Usage: FS_Delete(<filename>)\n"); char* qpath = Scr_GetString(0); if(!Scr_FS_AlreadyOpened(qpath, filename, sizeof(filename))) { Scr_Error("FS_Remove: Tried to delete an opened file!\n"); Scr_AddBool(qfalse); return; } if(FS_HomeRemove(qpath)) { Scr_AddBool(qtrue); }else{ Scr_AddBool(qfalse); } } /* ============ GScr_FS_InitParamList Returns a handle to the Parameter list Usage: int = FS_InitParamList(string <filename>, bool indexed_list) ============ */ /* #define MAX_PARAMLISTS 4 void GScr_FS_InitParamList(){ char* filename; qboolean type; int i; if(Scr_GetNumParam() != 2) Scr_Error("FS_InitParamList(string <filename>, bool <indexed_list>)\n"); filename = Scr_GetString(0); type = Scr_GetBool(1); //See if we have this list maybe already loaded if(scr_fopencount == MAX_SCRIPT_FILEHANDLES -1){ Scr_Error(va("FS_FOpen(): Exceeded limit of %i opened files\n", MAX_SCRIPT_FILEHANDLES)); } if(Q_stricmp(mode, "read")){ ret = FS_FOpenFileRead(filename, &fh); if(ret == -1){ Scr_AddInt(0); }else{ Scr_AddScriptFileHandle(fh); Scr_AddInt(ret); } }else if(Q_stricmp(mode, "write")){ fh = FS_FOpenFileWrite(filename); if(fh > 0) Scr_AddScriptFileHandle(fh); Scr_AddInt(fh); }else if(Q_stricmp(mode, "append")){ fh = FS_FOpenFileAppend(filename); if(fh > 0) Scr_AddScriptFileHandle(fh); Scr_AddInt(fh); }else{ Scr_Error("FS_FOpen(): invalid mode. Valid modes are: read, write, append\n"); } Com_sprintf(buffer, sizeof(buffer), "%s\n", data); ret = FS_Write(buffer, strlen(buffer), fh); if(!ret) Scr_AddBool(qfalse); else{ Scr_AddBool(qtrue); } } */ //static int scr_fopencount; //static int scr_fileHandles[MAX_SCRIPT_FILEHANDLES]; typedef union{ int step; byte cbyte; }paramlist_index_t; /* ============ GScr_FS_WriteParamList Usage: FS_WriteParamList(string <filename>) ============ */ /* void GScr_FS_WriteParamList(){ int ret; char buffer[2048]; if(Scr_GetNumParam() != 2) Scr_Error("Usage: FS_WriteLine(<filehandle>, <data>)\n"); fileHandle_t fh = Scr_GetInt(0); char* data = Scr_GetString(1); if(fh >= MAX_FILE_HANDLES || fh < 1){ Scr_Error("FS_ReadLine: Bad filehandle\n"); return; } Com_sprintf(buffer, sizeof(buffer), "%s\n", data); ret = FS_Write(buffer, strlen(buffer), fh); if(!ret) Scr_AddBool(qfalse); else{ Scr_AddBool(qtrue); } } */ /* ============ GScr_FS_ReadParamList Usage: FS_ReadParamList(string <filename>) ============ */ /* ============ GScr_FS_UnloadParamList Usage: FS_UnloadParamList(string <filename>) ============ */ /* ============ GScr_SpawnBot Usage: entity = AddTestClient() ============ */ void GScr_SpawnBot(){ gentity_t *clEnt; clEnt = (gentity_t*)SV_AddBotClient(); if(clEnt) Scr_AddEntity(clEnt); } /* ============ GScr_RemoveAllBots Usage: removeAllTestClients() ============ */ void GScr_RemoveAllBots(){ SV_RemoveAllBots(); } /* ============ GScr_RemoveBot Usage: entity = removeTestClient() ============ */ void GScr_RemoveBot(){ gentity_t *clEnt; clEnt = (gentity_t*)SV_RemoveBot(); if(clEnt) Scr_AddEntity(clEnt); } void GScr_KickClient() { client_t *cl; if(Scr_GetNumParam() != 1) Scr_Error("Usage: kick(<clientid>)\n"); int clnum = Scr_GetInt(0); if(clnum < 0 || clnum >= g_maxclients->integer) Scr_Error("kick(): Out of range client id\n"); cl = &svs.clients[clnum]; SV_DropClient(cl, va("Player kicked by scriptadmin\n")); } void GScr_BanClient() { client_t *cl; if(Scr_GetNumParam() != 1) Scr_Error("Usage: ban(<clientid>)\n"); int clnum = Scr_GetInt(0); if(clnum < 0 || clnum >= g_maxclients->integer) Scr_Error("ban(): Out of range client id\n"); cl = &svs.clients[clnum]; if(!SV_UseUids()){ SV_AddBan(0, 0, &cl->pbguid[24], cl->name, (time_t)-1, "Banned by scriptadmin"); SV_DropClient(cl, va("Banned by scriptadmin\n")); }else{ if(cl->uid > 0) { SV_AddBan(cl->uid, 0, cl->pbguid, cl->name, (time_t)-1, "Banned by scriptadmin"); SV_DropClient(cl, va("Banned by scriptadmin\n")); }else{ SV_DropClient(cl, va("Player kicked by scriptadmin\n")); } } } void PlayerCmd_spawn(scr_entref_t arg){ gentity_t* gentity = NULL; vec3_t position; vec3_t direction; int entityNum = 0; if(HIWORD(arg)){ Scr_ObjectError("Not an entity"); }else{ entityNum = LOWORD(arg); gentity = &g_entities[entityNum]; if(!gentity->client){ Scr_ObjectError(va("Entity: %i is not a player", entityNum)); } } Scr_GetVector(0, &position); Scr_GetVector(1, &direction); ClientSpawn(gentity, &position, &direction); } void GScr_NewHudElem(){ int i; game_hudelem_t* element = g_hudelems; for(i = 0; i < MAX_HUDELEMS; i++, element++) { if(element->inuse) continue; element->inuse = qtrue; element->x = 0; element->y = 0; element->var_03 = 0; element->var_04 = 1023; element->fonttype = 0; element->align = 0; element->screenalign = 0; element->color.red = 255; element->color.green = 255; element->color.blue = 255; element->color.alpha = 255; element->glowcolor.red = 0; element->glowcolor.green = 0; element->glowcolor.blue = 0; element->glowcolor.alpha = 0; element->fadecolor.red = 0; element->fadecolor.green = 0; element->fadecolor.blue = 0; element->fadecolor.alpha = 0; element->fadestarttime = 0; element->fadetime = 0; element->var_13 = 0; element->sort = 0; element->displayoption = 0; element->var_34 = 0; element->var_35 = 0; element->var_36 = 0; element->var_37 = 0; element->var_38 = 0; element->movestarttime = 0; element->movingtime = 0; element->fontscale = 0; element->archived = 0; element->var_14 = 0; element->var_15 = 0; element->var_16 = 0; element->movex = 0; element->movey = 0; element->movealign = 0; element->movescralign = 0; element->var_18 = 0; element->var_19 = 0; element->var_20 = 0; element->var_21 = 0; element->var_28 = 0; element->var_29 = 0; element->var_30 = 0; element->hudTextConfigStringIndex = 0; element->entitynum = 1023; element->teamnum = 0; Scr_AddHudElem(element); return; } Scr_Error("GScr_NewHudElem: Exceeded limit of Hudelems"); } void GScr_NewClientHudElem(){ int i; gentity_t *ent = Scr_GetEntity(0); game_hudelem_t* element = g_hudelems; if(ent->client == NULL){ Scr_ParamError(0, "GScr_NewClientHudElem: Entity is not a client"); } for(i = 0; i < MAX_HUDELEMS; i++, element++) { if(element->inuse) continue; element->inuse = qtrue; element->x = 0; element->y = 0; element->var_03 = 0; element->var_04 = 1023; element->fonttype = 0; element->align = 0; element->screenalign = 0; element->color.red = 255; element->color.green = 255; element->color.blue = 255; element->color.alpha = 255; element->glowcolor.red = 0; element->glowcolor.green = 0; element->glowcolor.blue = 0; element->glowcolor.alpha = 0; element->fadecolor.red = 0; element->fadecolor.green = 0; element->fadecolor.blue = 0; element->fadecolor.alpha = 0; element->fadestarttime = 0; element->fadetime = 0; element->var_13 = 0; element->sort = 0; element->displayoption = 0; element->var_34 = 0; element->var_35 = 0; element->var_36 = 0; element->var_37 = 0; element->var_38 = 0; element->movestarttime = 0; element->movingtime = 0; element->fontscale = 0; element->archived = 0; element->var_14 = 0; element->var_15 = 0; element->var_16 = 0; element->movex = 0; element->movey = 0; element->movealign = 0; element->movescralign = 0; element->var_18 = 0; element->var_19 = 0; element->var_20 = 0; element->var_21 = 0; element->var_28 = 0; element->var_29 = 0; element->var_30 = 0; element->hudTextConfigStringIndex = 0; element->entitynum = ent->s.number; element->teamnum = 0; Scr_AddHudElem(element); return; } Scr_Error("GScr_NewHudElem: Exceeded limit of Hudelems"); } void HECmd_SetText(scr_entref_t entnum){ char buffer[1024]; if(HIWORD(entnum) != 1) { Scr_ObjectError("G_HudSetText: Not a hud element"); return; } game_hudelem_t* element = &g_hudelems[LOWORD(entnum)]; element->var_14 = 0; element->var_15 = 0; element->var_16 = 0; element->movex = 0; element->movey = 0; element->movealign = 0; element->movescralign = 0; element->var_18 = 0; element->var_19 = 0; element->var_20 = 0; element->var_21 = 0; element->var_28 = 0; element->var_29 = 0; element->var_30 = 0; element->hudTextConfigStringIndex = 0; Scr_ConstructMessageString(0,0, "Hud Elem String", buffer, sizeof(buffer)); element->inuse = qtrue; element->hudTextConfigStringIndex = G_LocalizedStringIndex(buffer); } /* void ScrCmd_SetStance(scr_entref_t arg){ gentity_t* gentity; int entityNum = 0; short strindex; if(HIWORD(arg)){ Scr_ObjectError("Not an entity"); return; }else{ entityNum = LOWORD(arg); gentity = &g_entities[entityNum]; if(!gentity->client){ Scr_ObjectError(va("Entity: %i is not a player", entityNum)); return; } } if(Scr_GetNumParam() != 1){ Scr_Error("Usage: self setstance( <\"crouch\" | \"prone\" | \"stand\"> )\n"); } strindex = Scr_GetConstString(0); if(strindex == stringIndex.prone){ gentity->client->ps.stance = 1; }else if(strindex == stringIndex.crouch){ gentity->client->ps.stance = 2; }else if(strindex == stringIndex.stand){ gentity->client->ps.stance = 3; }else{ Scr_Error(va("Illegal stance string: '%s'." ,SL_ConvertToString(strindex))); } } */
38,099
C
.c
1,333
21.88072
140
0.568845
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,904
msg.c
haithun_CoD4X17a_testing/msg.c
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #include <string.h> #include <stdint.h> #include <math.h> #include "msg.h" #include "entity.h" #include "player.h" #include "qcommon_io.h" #include "net_game_conf.h" #include "huffman.h" #ifndef MAX_MSGLEN #define MAX_MSGLEN 0x20000 // max length of a message, which may #endif #ifndef __HUFFMAN_H__ #pragma message "Function MSG_initHuffman() is undefined" void MSG_initHuffman(){} #endif /* This part makes msg.c undepended in case no proper qcommon_io.h is included */ int pcount[256]; static char bigstring[MAX_MSGLEN]; /* ============================================================================== MESSAGE IO FUNCTIONS Handles byte ordering and avoids alignment errors ============================================================================== */ int oldsize = 0; void MSG_Init( msg_t *buf, byte *data, int length ) { static qboolean msgInit = qfalse; if (!msgInit) { MSG_initHuffman(); msgInit = qtrue; } Com_Memset (buf, 0, sizeof(*buf)); buf->data = data; buf->maxsize = length; } void MSG_Clear( msg_t *buf ) { buf->cursize = 0; buf->overflowed = qfalse; buf->bit = 0; //<- in bits } void MSG_BeginReading( msg_t *msg ) { msg->overflowed = qfalse; msg->readcount = 0; msg->bit = 0; } void MSG_Copy(msg_t *buf, byte *data, int length, msg_t *src) { if (length < src->cursize) { Com_Error( ERR_DROP, "MSG_Copy: can't copy into a smaller msg_t buffer"); } Com_Memcpy(buf, src, sizeof(msg_t)); buf->data = data; Com_Memcpy(buf->data, src->data, src->cursize); } //================================================================================ // // writing functions // void MSG_WriteByte( msg_t *msg, int c ) { #ifdef PARANOID if (c < 0 || c > 255) Com_Error (ERR_FATAL, "MSG_WriteByte: range error"); #endif byte* dst; if ( msg->maxsize - msg->cursize < 1 ) { msg->overflowed = qtrue; return; } dst = (byte*)&msg->data[msg->cursize]; *dst = c; msg->cursize += sizeof(byte); } void MSG_WriteShort( msg_t *msg, int c ) { #ifdef PARANOID if (c < ((short)0x8000) || c > (short)0x7fff) Com_Error (ERR_FATAL, "MSG_WriteShort: range error"); #endif signed short* dst; if ( msg->maxsize - msg->cursize < 2 ) { msg->overflowed = qtrue; return; } dst = (short*)&msg->data[msg->cursize]; *dst = c; msg->cursize += sizeof(short); } void MSG_WriteLong( msg_t *msg, int c ) { int32_t *dst; if ( msg->maxsize - msg->cursize < 4 ) { msg->overflowed = qtrue; return; } dst = (int32_t*)&msg->data[msg->cursize]; *dst = c; msg->cursize += sizeof(int32_t); } void MSG_WriteData( msg_t *buf, const void *data, int length ) { int i; for(i=0; i < length; i++){ MSG_WriteByte(buf, ((byte*)data)[i]); } } void MSG_WriteString( msg_t *sb, const char *s ) { if ( !s ) { MSG_WriteData( sb, "", 1 ); } else { int l; char string[MAX_STRING_CHARS]; l = strlen( s ); if ( l >= MAX_STRING_CHARS ) { Com_Printf( "MSG_WriteString: MAX_STRING_CHARS" ); MSG_WriteData( sb, "", 1 ); return; } Q_strncpyz( string, s, sizeof( string ) ); MSG_WriteData( sb, string, l + 1 ); } } void MSG_WriteBigString( msg_t *sb, const char *s ) { if ( !s ) { MSG_WriteData( sb, "", 1 ); } else { int l; char string[BIG_INFO_STRING]; l = strlen( s ); if ( l >= BIG_INFO_STRING ) { Com_Printf( "MSG_WriteString: BIG_INFO_STRING" ); MSG_WriteData( sb, "", 1 ); return; } Q_strncpyz( string, s, sizeof( string ) ); MSG_WriteData( sb, string, l + 1 ); } } void MSG_WriteVector( msg_t *msg, vec3_t c ) { vec_t *dst; if ( msg->maxsize - msg->cursize < 12 ) { msg->overflowed = qtrue; return; } dst = (vec_t*)&msg->data[msg->cursize]; dst[0] = c[0]; dst[1] = c[1]; dst[2] = c[2]; msg->cursize += sizeof(vec3_t); } void MSG_WriteBit0( msg_t* msg ) { if(!((byte)msg->bit & 7)){ if(msg->maxsize <= msg->cursize){ msg->overflowed = qtrue; return; } msg->bit = msg->cursize*8; msg->data[msg->cursize] = 0; msg->cursize ++; } msg->bit++; return; } /* void MSG_WriteBits(msg_t* msg, int value, int numBits ) { int put; int fraction; // check if the number of bits is valid if ( numBits == 0 || numBits < -31 || numBits > 32 ) { Com_Error( ERR_FATAL, "MSG_WriteBits: bad numBits %i", numBits ); } // check for value overflows // this should be an error really, as it can go unnoticed and cause either bandwidth or corrupted data transmitted if ( numBits != 32 ) { if ( numBits > 0 ) { if ( value > ( 1 << numBits ) - 1 ) { Com_PrintWarning( "MSG_WriteBits: value overflow %d %d", value, numBits ); } else if ( value < 0 ) { Com_PrintWarning( "MSG_WriteBits: value overflow %d %d", value, numBits ); } } else { int r = 1 << ( - 1 - numBits ); if ( value > r - 1 ) { Com_PrintWarning( "MSG_WriteBits: value overflow %d %d", value, numBits ); } else if ( value < -r ) { Com_PrintWarning( "MSG_WriteBits: value overflow %d %d", value, numBits ); } } } if ( numBits < 0 ) { numBits = -numBits; } // check for msg overflow if ( msg->maxsize - msg->cursize < 4 ) { msg->overflowed = qtrue; return; } // write the bits while( numBits ) { // if ( msg->bit == 0 ) { if ((msg->bit & 7) == 0 ) { msg->data[msg->cursize] = 0; msg->cursize++; } put = 8 - (msg->bit & 7); if ( put > numBits ) { put = numBits; } fraction = value & ( ( 1 << put ) - 1 ); msg->data[msg->cursize - 1] |= fraction << (msg->bit & 7); numBits -= put; value >>= put; msg->bit = ( msg->bit + put )*//* & 7*/; /*} }*/ //============================================================ // // reading functions // // returns -1 if no more characters are available int MSG_ReadByte( msg_t *msg ) { byte *c; if ( msg->readcount+sizeof(byte) > msg->cursize ) { msg->readcount += sizeof(byte); return -1; } c = &msg->data[msg->readcount]; msg->readcount += sizeof(byte); return *c; } int MSG_ReadShort( msg_t *msg ) { signed short *c; if ( msg->readcount+sizeof(short) > msg->cursize ) { msg->readcount += sizeof(short); return -1; } c = (short*)&msg->data[msg->readcount]; msg->readcount += sizeof(short); return *c; } int MSG_ReadLong( msg_t *msg ) { int32_t *c; if ( msg->readcount+sizeof(int32_t) > msg->cursize ) { msg->readcount += sizeof(int32_t); return -1; } c = (int32_t*)&msg->data[msg->readcount]; msg->readcount += sizeof(int32_t); return *c; } char *MSG_ReadString( msg_t *msg ) { int l,c; l = 0; do { c = MSG_ReadByte( msg ); // use ReadByte so -1 is out of bounds if ( c == -1 || c == 0 ) { break; } // translate all fmt spec to avoid crash bugs if ( c == '%' ) { c = '.'; } bigstring[l] = c; l++; } while ( l < sizeof( bigstring ) - 1 ); bigstring[l] = 0; return bigstring; } char *MSG_ReadStringLine( msg_t *msg ) { int l,c; l = 0; do { c = MSG_ReadByte(msg); // use ReadByte so -1 is out of bounds if (c == -1 || c == 0 || c == '\n') { break; } // translate all fmt spec to avoid crash bugs if ( c == '%' ) { c = '.'; } bigstring[l] = c; l++; } while (l < sizeof(bigstring)-1); bigstring[l] = 0; return bigstring; } void MSG_ReadData( msg_t *msg, void *data, int len ) { int i; for (i=0 ; i<len ; i++) { ((byte *)data)[i] = MSG_ReadByte (msg); } } void MSG_ClearLastReferencedEntity( msg_t *msg ) { msg->lastRefEntity = -1; } int MSG_GetUsedBitCount( msg_t *msg ) { return ((msg->cursize + msg->var_02) * 8) - ((8 - msg->bit) & 7); } /* void MSG_NUinitHuffman() { byte *data; int size, i, ch; int array[256]; msgInit = qtrue; Huff_Init(&msgHuff); // load it in size = FS_ReadFile( "netchan/netchan.bin", (void **)&data ); for(i=0;i<256;i++) { array[i] = 0; } for(i=0;i<size;i++) { ch = data[i]; Huff_addRef(&msgHuff.compressor, ch); // Do update Huff_addRef(&msgHuff.decompressor, ch); // Do update array[ch]++; } Com_Printf("msg_hData {\n"); for(i=0;i<256;i++) { if (array[i] == 0) { Huff_addRef(&msgHuff.compressor, i); // Do update Huff_addRef(&msgHuff.decompressor, i); // Do update } Com_Printf("%d, // %d\n", array[i], i); } Com_Printf("};\n"); FS_FreeFile( data ); Cbuf_AddText( "condump dump.txt\n" ); } */ //=========================================================================== typedef struct{ const char* name; int a; int b; }subNetEntlist_t; typedef struct{ subNetEntlist_t *sub; int z; }netEntlist_t; typedef struct { char *name; int offset; int bits; // 0 = float int var_04; } netField_t; // using the stringizing operator to save typing... #define NETF( x ) # x,(int)&( (entityState_t*)0 )->x netField_t entityStateFields_0[] = { { NETF( eType ), 8, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( events[0] ), -94, 0}, { NETF( eventSequence ), 8, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( surfType ), 8, 0}, { NETF( lerp.u.anonymous.data[0] ), 32, 0}, { NETF( time2 ), -97, 0}, { NETF( index ), 10, 0}, { NETF( solid ), 24, 0}, { NETF( un2 ), 32, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( clientNum ), 7, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( events[3] ), -94, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( legsAnim ), 10, 0}, { NETF( loopSound ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( lerp.u.anonymous.data[3] ), 32, 0}, { NETF( lerp.u.anonymous.data[4] ), 32, 0}, { NETF( lerp.u.anonymous.data[5] ), 32, 0}, { NETF( partBits[0] ), 32, 0}, { NETF( partBits[1] ), 32, 0}, { NETF( partBits[2] ), 32, 0}, { NETF( partBits[3] ), 32, 0}, }; netField_t entityStateFields_1[] = { { NETF( eType ), 8, 1}, { NETF( lerp.pos.trBase[0] ), -92, 2}, { NETF( lerp.pos.trBase[1] ), -91, 2}, { NETF( lerp.u.player.movementDir ), -8, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( eventSequence ), 8, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( legsAnim ), 10, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( events[0] ), -94, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( events[3] ), -94, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( solid ), 24, 0}, { NETF( weapon ), 7, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( clientNum ), 7, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( weaponModel ), 4, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( lerp.u.player.leanf ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 1}, { NETF( lerp.pos.trDelta[0] ), 0, 1}, { NETF( lerp.pos.trDuration ), 32, 1}, { NETF( lerp.pos.trTime ), -97, 1}, { NETF( lerp.pos.trDelta[2] ), 0, 1}, { NETF( surfType ), 8, 1}, { NETF( un1 ), 8, 1}, { NETF( index ), 10, 1}, { NETF( lerp.apos.trDelta[0] ), 0, 1}, { NETF( lerp.apos.trDelta[1] ), 0, 1}, { NETF( lerp.apos.trDelta[2] ), 0, 1}, { NETF( time2 ), -97, 1}, { NETF( loopSound ), 8, 1}, { NETF( attackerEntityNum ), 10, 1}, { NETF( lerp.apos.trTime ), 32, 1}, { NETF( lerp.apos.trDuration ), 32, 1}, { NETF( lerp.u.anonymous.data[2] ), 32, 1}, { NETF( lerp.u.anonymous.data[3] ), 32, 1}, { NETF( lerp.u.anonymous.data[4] ), 32, 1}, { NETF( lerp.u.anonymous.data[5] ), 32, 1}, { NETF( un2 ), 32, 1}, { NETF( partBits[0] ), 32, 1}, { NETF( partBits[1] ), 32, 1}, { NETF( partBits[2] ), 32, 1}, { NETF( partBits[3] ), 32, 1}, }; netField_t entityStateFields_2[] = { { NETF( eType ), 8, 1}, { NETF( lerp.eFlags ), -98, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( clientNum ), 7, 0}, { NETF( legsAnim ), 10, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( lerp.u.player.movementDir ), -8, 1}, { NETF( eventSequence ), 8, 1}, { NETF( events[0] ), -94, 1}, { NETF( events[1] ), -94, 1}, { NETF( events[2] ), -94, 1}, { NETF( events[3] ), -94, 1}, { NETF( fTorsoPitch ), 0, 1}, { NETF( eventParms[1] ), -93, 1}, { NETF( eventParms[0] ), -93, 1}, { NETF( eventParms[2] ), -93, 1}, { NETF( weapon ), 7, 1}, { NETF( weaponModel ), 4, 1}, { NETF( eventParms[3] ), -93, 1}, { NETF( solid ), 24, 1}, { NETF( lerp.pos.trDuration ), 32, 1}, { NETF( fWaistPitch ), 0, 1}, { NETF( eventParm ), -93, 1}, { NETF( iHeadIcon ), 4, 1}, { NETF( iHeadIconTeam ), 2, 1}, { NETF( surfType ), 8, 1}, { NETF( un1 ), 8, 1}, { NETF( otherEntityNum ), 10, 1}, { NETF( index ), 10, 1}, { NETF( lerp.apos.trDelta[0] ), 0, 1}, { NETF( lerp.apos.trDelta[1] ), 0, 1}, { NETF( lerp.apos.trDelta[2] ), 0, 1}, { NETF( time2 ), -97, 1}, { NETF( loopSound ), 8, 1}, { NETF( attackerEntityNum ), 10, 1}, { NETF( lerp.apos.trTime ), 32, 1}, { NETF( lerp.u.player.leanf ), 0, 1}, { NETF( lerp.apos.trDuration ), 32, 1}, { NETF( un2 ), 32, 1}, { NETF( lerp.u.anonymous.data[2] ), 32, 1}, { NETF( lerp.u.anonymous.data[3] ), 32, 1}, { NETF( lerp.u.anonymous.data[4] ), 32, 1}, { NETF( lerp.u.anonymous.data[5] ), 32, 1}, { NETF( partBits[0] ), 32, 1}, { NETF( partBits[1] ), 32, 1}, { NETF( partBits[2] ), 32, 1}, { NETF( partBits[3] ), 32, 1}, }; netField_t entityStateFields_3[] = { { NETF( eType ), 8, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trType ), 8, 2}, { NETF( lerp.pos.trDelta[2] ), 0, 2}, { NETF( lerp.pos.trDelta[0] ), 0, 2}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( clientNum ), 7, 2}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.apos.trType ), 8, 2}, { NETF( lerp.apos.trTime ), -97, 2}, { NETF( lerp.apos.trDelta[0] ), 0, 2}, { NETF( lerp.apos.trDelta[1] ), 0, 2}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( index ), 10, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( solid ), 24, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( eventSequence ), 8, 0}, { NETF( events[0] ), -94, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( surfType ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.u.anonymous.data[0] ), 32, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( events[3] ), -94, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( un1 ), 8, 0}, { NETF( time2 ), -97, 0}, { NETF( loopSound ), 8, 0}, { NETF( un2 ), 32, 0}, { NETF( legsAnim ), 10, 1}, { NETF( torsoAnim ), 10, 1}, { NETF( fTorsoPitch ), 0, 1}, { NETF( fWaistPitch ), 0, 1}, { NETF( iHeadIcon ), 4, 1}, { NETF( iHeadIconTeam ), 2, 1}, { NETF( lerp.apos.trDuration ), 32, 1}, { NETF( lerp.u.anonymous.data[3] ), 32, 1}, { NETF( lerp.u.anonymous.data[4] ), 32, 1}, { NETF( lerp.u.anonymous.data[5] ), 32, 1}, { NETF( partBits[0] ), 32, 1}, { NETF( partBits[1] ), 32, 1}, { NETF( partBits[2] ), 32, 1}, { NETF( partBits[3] ), 32, 1}, }; netField_t entityStateFields_4[] = { { NETF( eType ), 8, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.apos.trTime ), -97, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( eventSequence ), 8, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( surfType ), 8, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( lerp.u.missile.launchTime ), -97, 0}, { NETF( weapon ), 7, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( events[0] ), -94, 0}, { NETF( events[1] ), -94, 0}, { NETF( index ), 10, 0}, { NETF( clientNum ), 7, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( events[2] ), -94, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( un2 ), 1, 0}, { NETF( events[3] ), -94, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( weaponModel ), 4, 0}, { NETF( eventParm ), -93, 0}, { NETF( un1 ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( loopSound ), 8, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( solid ), 24, 0}, { NETF( time2 ), -97, 0}, { NETF( legsAnim ), 10, 1}, { NETF( torsoAnim ), 10, 1}, { NETF( fTorsoPitch ), 0, 1}, { NETF( fWaistPitch ), 0, 1}, { NETF( iHeadIcon ), 4, 1}, { NETF( iHeadIconTeam ), 2, 1}, { NETF( lerp.apos.trDuration ), 32, 1}, { NETF( lerp.u.anonymous.data[3] ), 32, 1}, { NETF( lerp.u.anonymous.data[4] ), 32, 1}, { NETF( lerp.u.anonymous.data[5] ), 32, 1}, { NETF( partBits[0] ), 32, 1}, { NETF( partBits[1] ), 32, 1}, { NETF( partBits[2] ), 32, 1}, { NETF( partBits[3] ), 32, 1}, }; netField_t entityStateFields_5[] = { { NETF( eType ), 8, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( events[0] ), -94, 0}, { NETF( eventSequence ), 8, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( surfType ), 8, 0}, { NETF( lerp.u.anonymous.data[0] ), 32, 0}, { NETF( time2 ), -97, 0}, { NETF( index ), 10, 0}, { NETF( solid ), 24, 0}, { NETF( un2 ), 32, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( clientNum ), 7, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( events[3] ), -94, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( legsAnim ), 10, 0}, { NETF( loopSound ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( lerp.u.anonymous.data[3] ), 32, 0}, { NETF( lerp.u.anonymous.data[4] ), 32, 0}, { NETF( lerp.u.anonymous.data[5] ), 32, 0}, { NETF( partBits[0] ), 32, 0}, { NETF( partBits[1] ), 32, 0}, { NETF( partBits[2] ), 32, 0}, { NETF( partBits[3] ), 32, 0}, }; netField_t entityStateFields_6[] = { { NETF( eType ), 8, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( eventSequence ), 8, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( index ), 10, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( partBits[0] ), 32, 0}, { NETF( events[0] ), -94, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( partBits[1] ), 32, 0}, { NETF( events[1] ), -94, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( events[2] ), -94, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( events[3] ), -94, 0}, { NETF( loopSound ), 8, 0}, { NETF( solid ), 24, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( clientNum ), 7, 0}, { NETF( eventParm ), -93, 0}, { NETF( weapon ), 7, 0}, { NETF( surfType ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.u.anonymous.data[0] ), 32, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( weaponModel ), 4, 0}, { NETF( time2 ), -97, 0}, { NETF( un2 ), 32, 0}, { NETF( un1 ), 8, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( legsAnim ), 10, 0}, { NETF( lerp.u.anonymous.data[3] ), 32, 0}, { NETF( lerp.u.anonymous.data[4] ), 32, 0}, { NETF( lerp.u.anonymous.data[5] ), 32, 0}, { NETF( partBits[2] ), 32, 0}, { NETF( partBits[3] ), 32, 0}, }; netField_t entityStateFields_7[] = { { NETF( eType ), 8, 1}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( eventSequence ), 8, 0}, { NETF( legsAnim ), 10, 0}, { NETF( surfType ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( clientNum ), 7, 0}, { NETF( events[0] ), -94, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( index ), 10, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( events[3] ), -94, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( solid ), 24, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( un2 ), 32, 0}, { NETF( time2 ), -97, 0}, { NETF( loopSound ), 8, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.u.soundBlend.lerp ), 0, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 1}, { NETF( lerp.u.anonymous.data[2] ), 32, 1}, { NETF( lerp.u.anonymous.data[3] ), 32, 1}, { NETF( lerp.u.anonymous.data[4] ), 32, 1}, { NETF( lerp.u.anonymous.data[5] ), 32, 1}, { NETF( partBits[0] ), 32, 1}, { NETF( partBits[1] ), 32, 1}, { NETF( partBits[2] ), 32, 1}, { NETF( partBits[3] ), 32, 1}, }; netField_t entityStateFields_8[] = { { NETF( eType ), 8, 0}, { NETF( time2 ), -97, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( clientNum ), 7, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( lerp.apos.trTime ), -97, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( index ), 10, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( solid ), 24, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( eventSequence ), 8, 0}, { NETF( events[0] ), -94, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( surfType ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.u.anonymous.data[0] ), 32, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( events[3] ), -94, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( loopSound ), 8, 0}, { NETF( un2 ), 32, 0}, { NETF( legsAnim ), 10, 1}, { NETF( torsoAnim ), 10, 1}, { NETF( fTorsoPitch ), 0, 1}, { NETF( fWaistPitch ), 0, 1}, { NETF( iHeadIcon ), 4, 1}, { NETF( iHeadIconTeam ), 2, 1}, { NETF( lerp.apos.trDuration ), 32, 1}, { NETF( lerp.u.anonymous.data[3] ), 32, 1}, { NETF( lerp.u.anonymous.data[4] ), 32, 1}, { NETF( lerp.u.anonymous.data[5] ), 32, 1}, { NETF( partBits[0] ), 32, 1}, { NETF( partBits[1] ), 32, 1}, { NETF( partBits[2] ), 32, 1}, { NETF( partBits[3] ), 32, 1}, }; netField_t entityStateFields_9[] = { { NETF( eType ), 8, 1}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( lerp.u.loopFx.cullDist ), 0, 0}, { NETF( lerp.u.loopFx.period ), 32, 0}, { NETF( eventSequence ), 8, 0}, { NETF( legsAnim ), 10, 0}, { NETF( surfType ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( clientNum ), 7, 0}, { NETF( events[0] ), -94, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( index ), 10, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( events[3] ), -94, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( solid ), 24, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( un2 ), 32, 0}, { NETF( time2 ), -97, 0}, { NETF( loopSound ), 8, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 1}, { NETF( lerp.u.anonymous.data[3] ), 32, 1}, { NETF( lerp.u.anonymous.data[4] ), 32, 1}, { NETF( lerp.u.anonymous.data[5] ), 32, 1}, { NETF( partBits[0] ), 32, 1}, { NETF( partBits[1] ), 32, 1}, { NETF( partBits[2] ), 32, 1}, { NETF( partBits[3] ), 32, 1}, }; netField_t entityStateFields_10[] = { { NETF( eType ), 8, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( events[0] ), -94, 0}, { NETF( eventSequence ), 8, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( surfType ), 8, 0}, { NETF( lerp.u.anonymous.data[0] ), 32, 0}, { NETF( time2 ), -97, 0}, { NETF( index ), 10, 0}, { NETF( solid ), 24, 0}, { NETF( un2 ), 32, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( clientNum ), 7, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( events[3] ), -94, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( legsAnim ), 10, 0}, { NETF( loopSound ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( lerp.u.anonymous.data[3] ), 32, 0}, { NETF( lerp.u.anonymous.data[4] ), 32, 0}, { NETF( lerp.u.anonymous.data[5] ), 32, 0}, { NETF( partBits[0] ), 32, 0}, { NETF( partBits[1] ), 32, 0}, { NETF( partBits[2] ), 32, 0}, { NETF( partBits[3] ), 32, 0}, }; netField_t entityStateFields_11[] = { { NETF( eType ), 8, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( events[0] ), -94, 0}, { NETF( eventSequence ), 8, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( surfType ), 8, 0}, { NETF( lerp.u.anonymous.data[0] ), 32, 0}, { NETF( time2 ), -97, 0}, { NETF( index ), 10, 0}, { NETF( solid ), 24, 0}, { NETF( un2 ), 32, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( clientNum ), 7, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( events[3] ), -94, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( legsAnim ), 10, 0}, { NETF( loopSound ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( lerp.u.anonymous.data[3] ), 32, 0}, { NETF( lerp.u.anonymous.data[4] ), 32, 0}, { NETF( lerp.u.anonymous.data[5] ), 32, 0}, { NETF( partBits[0] ), 32, 0}, { NETF( partBits[1] ), 32, 0}, { NETF( partBits[2] ), 32, 0}, { NETF( partBits[3] ), 32, 0}, }; netField_t entityStateFields_12[] = { { NETF( eType ), 8, 1}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.u.vehicle.gunPitch ), 0, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( lerp.u.vehicle.gunYaw ), 0, 0}, { NETF( eventSequence ), 8, 0}, { NETF( un1.helicopterStage ), 3, 0}, { NETF( time2 ), -97, 0}, { NETF( events[0] ), -94, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( events[3] ), -94, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( loopSound ), 8, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( un2 ), 32, 0}, { NETF( weapon ), 7, 0}, { NETF( lerp.u.vehicle.teamAndOwnerIndex ), 8, 0}, { NETF( weaponModel ), 4, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( legsAnim ), 10, 0}, { NETF( surfType ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( index ), 10, 0}, { NETF( lerp.u.vehicle.materialTime ), -97, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( solid ), 24, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( lerp.u.vehicle.bodyPitch ), -100, 0}, { NETF( lerp.u.vehicle.bodyRoll ), -100, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( partBits[0] ), 32, 1}, { NETF( partBits[1] ), 32, 1}, { NETF( partBits[2] ), 32, 1}, { NETF( partBits[3] ), 32, 1}, }; netField_t entityStateFields_13[] = { { NETF( eType ), 8, 1}, { NETF( lerp.pos.trBase[0] ), 0, 2}, { NETF( lerp.pos.trBase[1] ), 0, 2}, { NETF( lerp.pos.trBase[2] ), 0, 2}, { NETF( index ), 10, 2}, { NETF( lerp.pos.trDelta[0] ), 0, 2}, { NETF( lerp.pos.trDelta[1] ), 0, 2}, { NETF( lerp.pos.trTime ), -97, 2}, { NETF( lerp.pos.trType ), 8, 2}, { NETF( lerp.pos.trDuration ), 32, 2}, { NETF( lerp.u.vehicle.teamAndOwnerIndex ), 8, 2}, { NETF( lerp.apos.trBase[1] ), -100, 2}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( events[0] ), -94, 0}, { NETF( eventSequence ), 8, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( events[1] ), -94, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( loopSound ), 8, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( eventParm ), -93, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( surfType ), 8, 0}, { NETF( lerp.u.anonymous.data[0] ), 32, 0}, { NETF( time2 ), -97, 0}, { NETF( solid ), 24, 0}, { NETF( un2 ), 32, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( clientNum ), 7, 0}, { NETF( events[2] ), -94, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( events[3] ), -94, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( legsAnim ), 10, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( lerp.u.anonymous.data[3] ), 32, 1}, { NETF( lerp.u.anonymous.data[4] ), 32, 1}, { NETF( lerp.u.anonymous.data[5] ), 32, 1}, { NETF( partBits[0] ), 32, 1}, { NETF( partBits[1] ), 32, 1}, { NETF( partBits[2] ), 32, 1}, { NETF( partBits[3] ), 32, 1}, }; netField_t entityStateFields_14[] = { { NETF( eType ), 8, 1}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.u.vehicle.gunYaw ), 0, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( eventSequence ), 8, 0}, { NETF( legsAnim ), 10, 0}, { NETF( surfType ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( clientNum ), 7, 0}, { NETF( events[0] ), -94, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( index ), 10, 0}, { NETF( lerp.u.vehicle.materialTime ), -97, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( events[3] ), -94, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( lerp.u.vehicle.gunPitch ), 0, 0}, { NETF( solid ), 24, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( un2 ), 32, 0}, { NETF( time2 ), -97, 0}, { NETF( loopSound ), 8, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( lerp.u.vehicle.bodyPitch ), -100, 0}, { NETF( lerp.u.vehicle.bodyRoll ), -100, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.u.vehicle.steerYaw ), 0, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( partBits[0] ), 32, 1}, { NETF( partBits[1] ), 32, 1}, { NETF( partBits[2] ), 32, 1}, { NETF( partBits[3] ), 32, 1}, }; netField_t entityStateFields_15[] = { { NETF( eType ), 8, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( events[0] ), -94, 0}, { NETF( eventSequence ), 8, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( surfType ), 8, 0}, { NETF( lerp.u.anonymous.data[0] ), 32, 0}, { NETF( time2 ), -97, 0}, { NETF( index ), 10, 0}, { NETF( solid ), 24, 0}, { NETF( un2 ), 32, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( clientNum ), 7, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( events[3] ), -94, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( legsAnim ), 10, 0}, { NETF( loopSound ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( lerp.u.anonymous.data[3] ), 32, 0}, { NETF( lerp.u.anonymous.data[4] ), 32, 0}, { NETF( lerp.u.anonymous.data[5] ), 32, 0}, { NETF( partBits[0] ), 32, 0}, { NETF( partBits[1] ), 32, 0}, { NETF( partBits[2] ), 32, 0}, { NETF( partBits[3] ), 32, 0}, }; netField_t entityStateFields_16[] = { { NETF( eType ), 8, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( events[0] ), -94, 0}, { NETF( eventSequence ), 8, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( surfType ), 8, 0}, { NETF( lerp.u.anonymous.data[0] ), 32, 0}, { NETF( time2 ), -97, 0}, { NETF( index ), 10, 0}, { NETF( solid ), 24, 0}, { NETF( un2 ), 32, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( clientNum ), 7, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( eventParm ), -93, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( events[3] ), -94, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( fWaistPitch ), 0, 0}, { NETF( fTorsoPitch ), 0, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( lerp.apos.trDuration ), 32, 0}, { NETF( torsoAnim ), 10, 0}, { NETF( legsAnim ), 10, 0}, { NETF( loopSound ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( lerp.u.anonymous.data[3] ), 32, 0}, { NETF( lerp.u.anonymous.data[4] ), 32, 0}, { NETF( lerp.u.anonymous.data[5] ), 32, 0}, { NETF( partBits[0] ), 32, 0}, { NETF( partBits[1] ), 32, 0}, { NETF( partBits[2] ), 32, 0}, { NETF( partBits[3] ), 32, 0}, }; netField_t entityStateFields_17[] = { { NETF( eType ), 8, 0}, { NETF( lerp.pos.trBase[0] ), -92, 0}, { NETF( lerp.pos.trBase[1] ), -91, 0}, { NETF( lerp.pos.trBase[2] ), -90, 0}, { NETF( eventParm ), -93, 0}, { NETF( surfType ), 8, 0}, { NETF( otherEntityNum ), 10, 0}, { NETF( un1 ), 8, 0}, { NETF( lerp.u.anonymous.data[0] ), 32, 0}, { NETF( lerp.u.anonymous.data[1] ), 32, 0}, { NETF( attackerEntityNum ), 10, 0}, { NETF( lerp.apos.trBase[0] ), -100, 0}, { NETF( clientNum ), 7, 0}, { NETF( weapon ), 7, 0}, { NETF( weaponModel ), 4, 0}, { NETF( lerp.u.anonymous.data[2] ), 32, 0}, { NETF( index ), 10, 0}, { NETF( solid ), 24, 0}, { NETF( lerp.apos.trBase[1] ), -100, 0}, { NETF( lerp.apos.trBase[2] ), -100, 0}, { NETF( groundEntityNum ), -96, 0}, { NETF( lerp.u.anonymous.data[4] ), 32, 0}, { NETF( lerp.u.anonymous.data[5] ), 32, 0}, { NETF( iHeadIcon ), 4, 0}, { NETF( iHeadIconTeam ), 2, 0}, { NETF( events[0] ), -94, 0}, { NETF( eventParms[0] ), -93, 0}, { NETF( lerp.pos.trType ), 8, 0}, { NETF( lerp.apos.trType ), 8, 0}, { NETF( lerp.apos.trTime ), 32, 0}, { NETF( lerp.apos.trDelta[0] ), 0, 0}, { NETF( lerp.apos.trDelta[2] ), 0, 0}, { NETF( lerp.pos.trDelta[0] ), 0, 0}, { NETF( lerp.pos.trDelta[1] ), 0, 0}, { NETF( lerp.pos.trDelta[2] ), 0, 0}, { NETF( eventSequence ), 8, 0}, { NETF( lerp.pos.trTime ), -97, 0}, { NETF( events[1] ), -94, 0}, { NETF( events[2] ), -94, 0}, { NETF( eventParms[1] ), -93, 0}, { NETF( eventParms[2] ), -93, 0}, { NETF( events[3] ), -94, 0}, { NETF( eventParms[3] ), -93, 0}, { NETF( lerp.eFlags ), -98, 0}, { NETF( lerp.pos.trDuration ), 32, 0}, { NETF( lerp.apos.trDelta[1] ), 0, 0}, { NETF( time2 ), -97, 0}, { NETF( loopSound ), 8, 0}, { NETF( un2 ), 32, 0}, { NETF( torsoAnim ), 10, 1}, { NETF( legsAnim ), 10, 1}, { NETF( fWaistPitch ), 0, 1}, { NETF( fTorsoPitch ), 0, 1}, { NETF( lerp.u.anonymous.data[3] ), 32, 1}, { NETF( lerp.apos.trDuration ), 32, 1}, { NETF( partBits[0] ), 32, 1}, { NETF( partBits[1] ), 32, 1}, { NETF( partBits[2] ), 32, 1}, { NETF( partBits[3] ), 32, 1}, }; typedef struct { netField_t *field; int numFields; } netFieldList_t; //#define NETF( x ) # x,(int)&( (entityState_t*)0 )->x #define NETFE( x ) entityStateFields_##x , sizeof(entityStateFields_##x) / sizeof(netField_t) netFieldList_t netFieldList[] = { {NETFE(0)}, {NETFE(1)}, {NETFE(2)}, {NETFE(3)}, {NETFE(4)}, {NETFE(5)}, {NETFE(6)}, {NETFE(7)}, {NETFE(8)}, {NETFE(9)}, {NETFE(10)}, {NETFE(11)}, {NETFE(12)}, {NETFE(13)}, {NETFE(14)}, {NETFE(15)}, {NETFE(16)}, {NETFE(17)} }; // if (int)f == f and (int)f + ( 1<<(FLOAT_INT_BITS-1) ) < ( 1 << FLOAT_INT_BITS ) // the float will be sent with FLOAT_INT_BITS, otherwise all 32 bits will be sent #define FLOAT_INT_BITS 13 #define FLOAT_INT_BIAS ( 1 << ( FLOAT_INT_BITS - 1 ) ) void MSG_WriteDeltaEntity(snapshotInfo_t* snap, msg_t* msg, int time, entityState_t* from, entityState_t* to, int arg_6){ // all fields should be 32 bits to avoid any compiler packing issues // the "number" field is not part of the field list // if this assert fails, someone added a field to the entityState_t // struct without updating the message fields // assert( numFields + 1 == sizeof( *from ) / 4 ); netFieldList_t* fieldtype; netField_t* field; int i, lc; int *fromF, *toF; int var_01, var_02; if(!to){ MSG_WriteEntityIndex(snap, msg, from->number, 0x0a); MSG_WriteBit1(msg); return; } if( to->number < 64){ if(g_entities[snap->clnum].client->sess.sessionTeam == TEAM_FREE){ if(!SV_FFAPlayerCanBlock()){ Com_Printf("Solid: %s\n", Q_BitConv(to->solid)); to->solid &= ~PLAYER_SOLIDMASK; } }else if(!SV_FriendlyPlayerCanBlock() && OnSameTeam( &g_entities[to->number], &g_entities[snap->clnum])) to->solid &= ~PLAYER_SOLIDMASK; } if ( to->number < 0 || to->number >= MAX_GENTITIES ) { Com_Error( ERR_FATAL, "MSG_WriteDeltaEntity: Bad entity number: %i", to->number ); } unsigned int index = 17; if(to->eType <= 17) index = to->eType; // MSG_GetUsedBitCount(msg); fieldtype = &netFieldList[index]; if(fieldtype->numFields <= 0){ MSG_WriteDeltaEntity_EXIT2: if(arg_6){ MSG_WriteEntityIndex(snap, msg, to->number, 10); MSG_WriteBit0(msg); MSG_WriteBit0(msg); // MSG_GetUsedBitCount(msg); } return; } for(i = 0, lc = 0, field = fieldtype->field; i < fieldtype->numFields; i++, field++){ fromF = ( int * )( (byte *)from + field->offset ); toF = ( int * )( (byte *)to + field->offset ); if ( *fromF == *toF ) { continue; } int swbits = field->bits +100; switch(swbits){ case 8: case 9: case 10: var_01 = (int)floorf(0.5f + *(float*)fromF); var_02 = (int)floorf(0.5f + *(float*)toF); if(var_01 != var_02) { lc = i +1; } continue; case 0: case 13: var_01 = (int)(182.044449f * (*(float*)fromF) + 0.5f); var_02 = (int)(182.044449f * (*(float*)toF) + 0.5f); if((short)var_01 != (short)var_02) { lc = i +1; } continue; case 5: //(*toF)(*fromF) * 0x51eb851f; This makes no sense var_01 = swbits >> 5; var_01 -= *fromF >> 31; var_02 = swbits >> 5; var_02 -= *toF >> 31; if(var_01 != var_02) { lc = i +1; } continue; default: lc = i +1; } } if(!lc) goto MSG_WriteDeltaEntity_EXIT2; MSG_WriteEntityIndex(snap, msg, to->number, 10); MSG_WriteBit0(msg); MSG_WriteBit1(msg); MSG_WriteBits(msg, lc, GetMinBitCount(fieldtype->numFields)); if(lc > 0) { for(i = 0, field = fieldtype->field; i != lc; i++, field++) { MSG_WriteDeltaField(snap, msg, time, (unsigned const char*)from, (unsigned const char*)to, field, i, 0); } } // MSG_GetUsedBitCount(msg); } // using the stringizing operator to save typing... #define PSF( x ) # x,(int)&( (playerState_t*)0 )->x netField_t playerStateFields[] = { { PSF( commandTime ), -97, 0}, { PSF( viewangles[1] ), -87, 0}, { PSF( viewangles[0] ), -87, 0}, { PSF( viewangles[2] ), -87, 0}, { PSF( origin[0] ), -88, 3}, { PSF( origin[1] ), -88, 3}, { PSF( bobCycle ), 8, 3}, { PSF( velocity[1] ), -88, 3}, { PSF( velocity[0] ), -88, 3}, { PSF( movementDir ), -8, 3}, { PSF( eventSequence ), 8, 0}, { PSF( legsAnim ), 10, 0}, { PSF( origin[2] ), -88, 3}, { PSF( weaponTime ), -16, 0}, { PSF( aimSpreadScale ), -88, 0}, { PSF( torsoTimer ), 16, 0}, { PSF( pm_flags ), 21, 0}, { PSF( weapAnim ), 10, 0}, { PSF( weaponstate ), 5, 0}, { PSF( velocity[2] ), -88, 3}, { PSF( events[0] ), 8, 0}, { PSF( events[1] ), 8, 0}, { PSF( events[2] ), 8, 0}, { PSF( events[3] ), 8, 0}, { PSF( eventParms[0] ), 8, 0}, { PSF( eventParms[1] ), 8, 0}, { PSF( eventParms[2] ), 8, 0}, { PSF( eventParms[3] ), 8, 0}, { PSF( torsoAnim ), 10, 0}, { PSF( holdBreathScale ), -88, 0}, { PSF( eFlags ), -98, 0}, { PSF( viewHeightCurrent ), -88, 0}, { PSF( fWeaponPosFrac ), -88, 0}, { PSF( legsTimer ), 16, 0}, { PSF( viewHeightTarget ), -8, 0}, { PSF( sprintState.lastSprintStart ), -97, 0}, { PSF( sprintState.lastSprintEnd ), -97, 0}, { PSF( weapon ), 7, 0}, { PSF( weaponDelay ), -16, 0}, { PSF( sprintState.sprintStartMaxLength ), 14, 0}, { PSF( weapFlags ), 9, 0}, { PSF( groundEntityNum ), 10, 0}, { PSF( damageTimer ), 10, 0}, { PSF( weapons[0] ), 32, 0}, { PSF( weapons[1] ), 32, 0}, { PSF( weaponold[0] ), 32, 0}, { PSF( delta_angles[1] ), -100, 0}, { PSF( offHandIndex ), 7, 0}, { PSF( pm_time ), -16, 0}, { PSF( otherFlags ), 5, 0}, { PSF( moveSpeedScaleMultiplier ), 0, 0}, { PSF( perks ), 32, 0}, { PSF( killCamEntity ), 10, 0}, { PSF( throwBackGrenadeOwner ), 10, 0}, { PSF( actionSlotType[2] ), 2, 0}, { PSF( delta_angles[0] ), -100, 0}, { PSF( speed ), 16, 0}, { PSF( viewlocked_entNum ), 16, 0}, { PSF( gravity ), 16, 0}, { PSF( actionSlotType[0] ), 2, 0}, { PSF( dofNearBlur ), 0, 0}, { PSF( dofFarBlur ), 0, 0}, { PSF( clientNum ), 8, 0}, { PSF( damageEvent ), 8, 0}, { PSF( viewHeightLerpTarget ), -8, 0}, { PSF( damageYaw ), 8, 0}, { PSF( viewmodelIndex ), 9, 0}, { PSF( damageDuration ), 16, 0}, { PSF( damagePitch ), 8, 0}, { PSF( flinchYawAnim ), 2, 0}, { PSF( weaponShotCount ), 3, 0}, { PSF( viewHeightLerpDown ), 1, 2}, { PSF( cursorHint ), 8, 0}, { PSF( cursorHintString ), -8, 0}, { PSF( cursorHintEntIndex ), 10, 0}, { PSF( viewHeightLerpTime ), 32, 0}, { PSF( offhandSecondary ), 1, 2}, { PSF( radarEnabled ), 1, 2}, { PSF( pm_type ), 8, 0}, { PSF( fTorsoPitch ), 0, 0}, { PSF( holdBreathTimer ), 16, 0}, { PSF( actionSlotParam[2] ), 7, 0}, { PSF( jumpTime ), 32, 0}, { PSF( mantleState.flags ), 5, 0}, { PSF( fWaistPitch ), 0, 0}, { PSF( grenadeTimeLeft ), -16, 0}, { PSF( proneDirection ), 0, 0}, { PSF( mantleState.timer ), 32, 0}, { PSF( damageCount ), 7, 0}, { PSF( shellshockTime ), -97, 0}, { PSF( shellshockDuration ), 16, 2}, { PSF( sprintState.sprintButtonUpRequired ), 1, 2}, { PSF( shellshockIndex ), 4, 0}, { PSF( proneTorsoPitch ), 0, 0}, { PSF( sprintState.sprintDelay ), 1, 2}, { PSF( actionSlotParam[3] ), 7, 0}, { PSF( weapons[3] ), 32, 0}, { PSF( actionSlotType[3] ), 2, 0}, { PSF( proneDirectionPitch ), 0, 0}, { PSF( jumpOriginZ ), 0, 0}, { PSF( mantleState.yaw ), 0, 0}, { PSF( mantleState.transIndex ), 4, 0}, { PSF( weaponrechamber[0] ), 32, 0}, { PSF( throwBackGrenadeTimeLeft ), -16, 0}, { PSF( weaponold[3] ), 32, 0}, { PSF( weaponold[1] ), 32, 0}, { PSF( foliageSoundTime ), -97, 0}, { PSF( vLadderVec[0] ), 0, 0}, { PSF( viewlocked ), 2, 0}, { PSF( deltaTime ), 32, 0}, { PSF( viewAngleClampRange[1] ), 0, 0}, { PSF( viewAngleClampBase[1] ), 0, 0}, { PSF( viewAngleClampRange[0] ), 0, 0}, { PSF( vLadderVec[1] ), 0, 0}, { PSF( locationSelectionInfo ), 8, 0}, { PSF( meleeChargeTime ), -97, 0}, { PSF( meleeChargeYaw ), -100, 0}, { PSF( meleeChargeDist ), 8, 0}, { PSF( iCompassPlayerInfo ), 32, 0}, { PSF( weapons[2] ), 32, 0}, { PSF( actionSlotType[1] ), 2, 0}, { PSF( weaponold[2] ), 32, 0}, { PSF( vLadderVec[2] ), 0, 0}, { PSF( weaponRestrictKickTime ), -16, 0}, { PSF( delta_angles[2] ), -100, 0}, { PSF( spreadOverride ), 6, 0}, { PSF( spreadOverrideState ), 2, 0}, { PSF( actionSlotParam[0] ), 7, 0}, { PSF( actionSlotParam[1] ), 7, 0}, { PSF( dofNearStart ), 0, 0}, { PSF( dofNearEnd ), 0, 0}, { PSF( dofFarStart ), 0, 0}, { PSF( dofFarEnd ), 0, 0}, { PSF( dofViewmodelStart ), 0, 0}, { PSF( dofViewmodelEnd ), 0, 0}, { PSF( viewAngleClampBase[0] ), 0, 0}, { PSF( weaponrechamber[1] ), 32, 0}, { PSF( weaponrechamber[2] ), 32, 0}, { PSF( weaponrechamber[3] ), 32, 0}, { PSF( leanf ), 0, 0}, { PSF( adsDelayTime ), 32, 1}, }; int MSG_WriteBitsNoCompress( int d, byte* src, byte* dst , int size){ Com_Memcpy(dst, src, size); return size; }
56,173
C
.c
1,762
29.671396
121
0.566796
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,915
plugin_com.h
haithun_CoD4X17a_testing/dis/plugin_com.h
qboolean Plugin_ExportFunction_p(char *name, void *(*function)()); void *Plugin_ImportFunction_p(char *pluginName, char *name); qboolean Plugin_IsLoaded_p(char *name);
167
C
.c
3
55
66
0.769697
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,922
declarations.h
haithun_CoD4X17a_testing/plugins/declarations.h
#ifndef PLUGIN_INCLUDES #error Please include pinc.h instead! #endif /*PLUGIN_INCLUDES*/ #include <string.h> //Types and structs typedef int fileHandle_t; typedef enum {qfalse, qtrue} qboolean; typedef void *xcommand_t; typedef void *client_t_ptr; typedef unsigned char byte; // Used for internet communication typedef enum { NA_BAD = 0, // an address lookup failed NA_BOT = 0, NA_LOOPBACK = 2, NA_BROADCAST = 3, NA_IP = 4, NA_IP6 = 5, NA_TCP = 6, NA_TCP6 = 7, NA_MULTICAST6 = 8, NA_UNSPEC = 9, NA_DOWN = 10 } netadrtype_t; typedef struct { byte type; byte scope_id; unsigned short port; short sock; union{ byte ip[4]; byte ipx[10]; byte ip6[16]; }; }netadr_t; typedef float vec_t; typedef vec_t vec2_t[2]; typedef vec_t vec3_t[3]; typedef vec_t vec4_t[4]; typedef vec_t vec5_t[5]; typedef void convariable_t; typedef struct{ // A structure representing a player's scoreboard int score; int deaths; int kills; int assists; }clientScoreboard_t; #include "plugin_declarations.h" #include "function_declarations.h" // Function descriptions are available in this file typedef enum{ CVAR_BOOL, CVAR_FLOAT, CVAR_VEC2, CVAR_VEC3, CVAR_VEC4, CVAR_INT, CVAR_ENUM, CVAR_STRING, CVAR_COLOR }cvarType_t; typedef struct{ char *name; char *description; short int flags; byte type; byte modified; union{ float floatval; float value; int integer; char* string; byte boolean; }; union{ float latchedfloatval; float latchedvalue; int latchedinteger; char* latchedstring; byte latchedboolean; }; } cvar_t; #define cvardeclarations
1,656
C
.c
82
17.5
86
0.717949
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,923
plugin_declarations.h
haithun_CoD4X17a_testing/plugins/plugin_declarations.h
#define PLUGIN_HANDLER_VERSION_MAJOR 1 #define PLUGIN_HANDLER_VERSION_MINOR 900 //PHandler v. 1.8 enum Plugin_Err{ // To be used as the code argument for Plugin_Error() P_ERROR_WARNING, // Save the error string to serverlog - for minor errors P_ERROR_DISABLE, // Save the error string to serverlog and disable the plugin - for serious errors P_ERROR_TERMINATE // Save the error string to serverlog and close the server - for critical errors }; typedef struct{ int major; int minor; }version_t; typedef struct{ // To be used in OnInfoRequest version_t handlerVersion; // Requested plugin handler version - mandatory field version_t pluginVersion; // Version of your plugin - optional char fullName[64]; // Full plugin name, short name is the filename without extension - optional char shortDescription[128]; // Describe in a few words what this plugin does - optional char longDescription[1024]; // Full description - optional }pluginInfo_t;
1,000
C
.c
19
49.315789
104
0.742068
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,925
censor.c
haithun_CoD4X17a_testing/plugins/censor/censor.c
#include <stdlib.h> #include <string.h> #include "censor.h" #include "../pinc.h" typedef struct badwordsList_s { struct badwordsList_s *next; qboolean exactmatch; char word[24]; }badwordsList_t; badwordsList_t *badwords; /* ============= Q_strncpyz Safe strncpy that ensures a trailing zero ============= */ void Q_strncpyz( char *dest, const char *src, int destsize ) { if (!dest ) { Plugin_Error( P_ERROR_DISABLE, "Q_strncpyz: NULL dest" ); } if ( !src ) { Plugin_Error( P_ERROR_DISABLE, "Q_strncpyz: NULL src" ); } if ( destsize < 1 ) { Plugin_Error(P_ERROR_DISABLE,"Q_strncpyz: destsize < 1" ); } strncpy( dest, src, destsize-1 ); dest[destsize-1] = 0; } int Q_stricmpn (const char *s1, const char *s2, int n) { int c1, c2; if ( s1 == NULL ) { if ( s2 == NULL ) return 0; else return -1; } else if ( s2==NULL ) return 1; do { c1 = *s1++; c2 = *s2++; if (!n--) { return 0; // strings are equal until end point } if (c1 != c2) { if (c1 >= 'a' && c1 <= 'z') { c1 -= ('a' - 'A'); } if (c2 >= 'a' && c2 <= 'z') { c2 -= ('a' - 'A'); } if (c1 != c2) { return c1 < c2 ? -1 : 1; } } } while (c1); return 0; // strings are equal } int Q_stricmp (const char *s1, const char *s2) { return (s1 && s2) ? Q_stricmpn (s1, s2, 99999) : -1; } char* removeColors(char *output,char *string,size_t size) { register int j=0; register int i; if(!output || !string) return NULL; if(size < strlen(string)){ Plugin_Error(P_ERROR_TERMINATE,"Censor plugin: removeColors: buffer overflow"); return NULL; } for(i=0;string[i]!=0;i++){ if(string[i]=='^' && (string[i+1] >= '0' && string[i+1] <= '9')){ i++; } else{ output[j]=string[i]; j++; } } output[j]=0; return output; } char* CharConv(char *output, char *string,int size) { char *ret = output; if(!output || !string) return NULL; if(size < strlen(string)){ Plugin_Error(P_ERROR_TERMINATE,"Censor plugin: CharConv: buffer overflow"); return NULL; } for( ; *string != 0; string++){ switch(*string){ case 'A': case '4': case '@': *output='a'; break; case 'B': *output='b'; break; case 'C': case '(': *output='c'; break; case 'D': case ')': *output='d'; break; case 'E': case '3': *output='e'; break; case 'F': *output='f'; break; case 'G': *output='g'; break; case 'H': *output='h'; break; case 'I': case '1': case '|': case '!': *output='i'; break; case 'J': *output='j'; break; case 'K': *output='k'; break; case 'L': *output='l'; break; case 'M': *output='m'; break; case 'N': *output='n'; break; case 'O': case '0': *output='o'; break; case 'P': *output='p'; break; case 'Q': *output='q'; break; case 'R': *output='r'; break; case 'S': case '5': case '$': *output='s'; break; case 'T': *output='t'; break; case 'U': *output='u'; break; case 'V': *output='v'; break; case 'W': *output='w'; break; case 'X': *output='x'; break; case 'Y': *output='y'; break; case 'Z': *output='z'; break; case '.': case ',': case '\\': case '/': case '-': case '_': continue; default: *output=*string; break; } output++; } *output=0; return ret; } void G_SayCensor_Init() { fileHandle_t file; int read; badwordsList_t *this; qboolean exactmatch; char buff[24]; char line[24]; char* linept; register int i=0; FS_SV_FOpenFileRead("badwords.txt",&file); if(!file){ Com_Printf("Censor_Plugin: Can not open badwords.txt for reading\n"); return; } for(i = 0; ;i++){ read = FS_ReadLine(buff,sizeof(buff),file); if(read == 0){ Com_Printf("%i lines parsed from badwords.txt\n",i); FS_FCloseFile(file); return; } if(read == -1){ Com_Printf("Can not read from badwords.txt\n"); FS_FCloseFile(file); return; } Q_strncpyz(line,buff,sizeof(line)); linept = line; if(*linept == '#'){ exactmatch = qtrue; linept++; }else{ exactmatch = qfalse; } this = Plugin_Malloc(sizeof(badwordsList_t)); if(this){ this->next = badwords; this->exactmatch = exactmatch; Q_strncpyz(this->word,linept,strlen(linept)); badwords = this; } } Com_Printf("Censor: init complete.\n"); } char* censor_ignoreMultiple(char *output, char *string, size_t size) { if(!output || !string) return NULL; if(size < strlen(string)){ Plugin_Error(P_ERROR_TERMINATE,"Censor plugin: censor_ignoreMultiple: buffer overflow"); return NULL; } char *ret = output; for(; *string; output++){ *output = *string; do{ string++; }while(*output == *string && *string); } *output=0; return ret; } char* G_SayCensor(char *msg) { char token2[1024]; char token[1024]; badwordsList_t *this; char* ret = msg; while(1){ msg = Com_ParseGetToken(msg); if(msg==NULL) break; int size = Com_ParseTokenLength(msg); Q_strncpyz(token,msg,size+1); removeColors(token2,token,sizeof(token2)); CharConv(token,token2,sizeof(token));// 'clear' token censor_ignoreMultiple(token2,token,sizeof(token2)); for(this = badwords ; this ; this = this->next){ if(this->exactmatch){ if(!Q_stricmp(token,this->word)){ memset(msg,'*',size); break; } }else{ if(strstr(token2,this->word)!=NULL){ memset(msg,'*',size); break; } } } } return ret; }
6,016
C
.c
291
15.697595
93
0.540698
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,934
cod4_keycode.c
haithun_CoD4X17a_testing/cdkey/cod4_keycode.c
//This code has no use at all. #include <stdio.h> typedef enum{qfalse, qtrue}qboolean; qboolean CL_CDKeyValidate(char* key1234, char* key5){ int testkey = 0; int j; int i; char key5t[5]; for(j=0; j < 16; j++) { testkey ^= (signed char)key1234[j]; for(i = 8; i > 0; i--){ if(testkey & 1){ testkey >>= 1; testkey ^= 0xa001; }else{ testkey >>= 1; } } } sprintf(key5t, "%04x", testkey); if(!key5) return 1; printf("Testkey: %s\n", key5t); if(Q_stricmpn(key5t, key5, 4)) return 1; return 0; } int Q_stricmpn (const char *s1, const char *s2, int n) { int c1, c2; if ( s1 == NULL ) { if ( s2 == NULL ) return 0; else return -1; } else if ( s2==NULL ) return 1; do { c1 = *s1++; c2 = *s2++; if (!n--) { return 0; // strings are equal until end point } if (c1 != c2) { if (c1 >= 'a' && c1 <= 'z') { c1 -= ('a' - 'A'); } if (c2 >= 'a' && c2 <= 'z') { c2 -= ('a' - 'A'); } if (c1 != c2) { return c1 < c2 ? -1 : 1; } } } while (c1); return 0; // strings are equal } int main(void){ if(CL_CDKeyValidate("ICENINJAMENRULES","08FF")){ printf("Key is bad\n"); }else{ printf("Key is good\n"); } return 0; }
1,296
C
.c
66
15.545455
56
0.515728
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,381,945
xassets.h
haithun_CoD4X17a_testing/xassets.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef __XASSETS_H__ #define __XASSETS_H__ #include "q_shared.h" typedef struct{ const char* fastfile; int loadpriority; int notknown; }XZoneInfo; void R_Init(); void __cdecl DB_SetInitializing(qboolean); byte __cdecl DB_FileExists(const char* filename, int mode); qboolean __cdecl DB_ModFileExists(void); void __cdecl DB_LoadXAssets(XZoneInfo*, unsigned int assetscount, int); int __cdecl DB_GetXAssetTypeSize(int type); void __cdecl XAnimInit(void); void XAssets_PatchLimits(void); #endif
1,498
C
.h
33
42.242424
87
0.680193
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,947
g_hud.h
haithun_CoD4X17a_testing/g_hud.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef __G_HUD_H__ #define __G_HUD_H__ #include "q_shared.h" #include "entity.h" #define HUDELEM_ADDR 0x8335620 #define MAX_HUDELEMS 1024 typedef struct { byte red; byte green; byte blue; byte alpha; }ucolor_t; typedef enum{ HUDFONT_DEFAULT, HUDFONT_BIGFIXED, HUDFONT_SMALLFIXED, HUDFONT_OBJECTIVE }fonttype_t; typedef enum{ HUDALIGN_TOP = 0, HUDALIGN_LEFT = 0, HUDALIGN_MIDDLE = 1, HUDALIGN_BOTTOM = 2, HUDALIGN_CENTER = 4, HUDALIGN_RIGHT = 8 }hudalign_t; typedef enum{ HUDSCRNALIGN_TOP = 0, HUDSCRNALIGN_MIDDLE = 1, HUDSCRNALIGN_BOTTOM = 2, HUDSCRNALIGN_LEFT = 9, HUDSCRNALIGN_CENTER = 17, HUDSCRNALIGN_RIGHT = 25 }hudscrnalign_t; typedef enum{ HUDDISPLAY_FOREGROUND = 1, HUDDISPLAY_HIDEINMENU = 4 }huddisplayoptions_t; typedef struct { qboolean inuse; float x; float y; int var_03; int var_04; float fontscale; fonttype_t fonttype; hudalign_t align; hudscrnalign_t screenalign; ucolor_t color; ucolor_t fadecolor; int fadestarttime; int fadetime; int var_13; int var_14; int var_15; int var_16; int var_17; int var_18; int var_19; int var_20; int var_21; float movex; float movey; int movealign; int movescralign; int movestarttime; int movingtime; int var_28; int var_29; int var_30; int hudTextConfigStringIndex; float sort; ucolor_t glowcolor; int var_34; int var_35; int var_36; int var_37; int var_38; huddisplayoptions_t displayoption; unsigned int entitynum; unsigned int teamnum; qboolean archived; }game_hudelem_t; //Size: 0xac extern game_hudelem_t* g_hudelems; qboolean OnSameTeam( gentity_t *ent1, gentity_t *ent2 ); qboolean Cmd_FollowClient_f(gentity_t *ent, int clientnum); game_hudelem_t* G_GetNewHudElem(unsigned int clnum); void G_HudSetText(game_hudelem_t*, const char*); void G_HudSetPosition(game_hudelem_t*, float x, float y, hudscrnalign_t, hudscrnalign_t, hudalign_t alignx, hudalign_t aligny); void G_HudSetColor(game_hudelem_t*, ucolor_t, ucolor_t); void G_HudSetMovingOverTime(game_hudelem_t*, int, float newx, float newy); void G_HudSetFont(game_hudelem_t*, float fontscale, fonttype_t ft); void G_HudSetFadingOverTime(game_hudelem_t* element ,int time, ucolor_t newcolor); void G_HudDestroy(game_hudelem_t* element); #endif
3,294
C
.h
113
26.318584
127
0.715826
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,949
plugin_events.h
haithun_CoD4X17a_testing/plugin_events.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ //typedef char[32] plugin_event_t; enum PluginEvents{ // plugin handling events //PLUGINS_ONINIT, PLUGINS_ONINFOREQUEST, // runtime events: PLUGINS_ONPLAYERDC, PLUGINS_ONPLAYERCONNECT, PLUGINS_ONEXITLEVEL, PLUGINS_ONMESSAGESENT, PLUGINS_ONFRAME, //new PLUGINS_ONONESECOND, // new PLUGINS_ONTENSECONDS, PLUGINS_ONCLIENTAUTHORIZED, // new PLUGINS_ONCLIENTSPAWN, PLUGINS_ONCLIENTENTERWORLD, PLUGINS_ONTCPSERVERPACKET, // new PLUGINS_ONUDPNETEVENT, PLUGINS_ONUDPNETSEND, PLUGINS_ONSPAWNSERVER, PLUGINS_ONPREFASTRESTART, PLUGINS_ONPOSTFASTRESTART, PLUGINS_ITEMCOUNT }; extern char PHandler_Events[PLUGINS_ITEMCOUNT][32]; // defined in plugin_handler.c
1,733
C
.h
41
37.487805
87
0.686639
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,381,955
common_adrdefs.h
haithun_CoD4X17a_testing/common_adrdefs.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #define com_errorEntered_ADDR 0x88a61f4 #define com_lastError_ADDR 0x88a6220 #define cvar_modifiedFlags_ADDR 0x1402c060 #define com_codeTimeScale_ADDR 0x88a7238 #define com_errorEntered *((qboolean*)(com_errorEntered_ADDR)) #define com_lastError ((char*)com_lastError_ADDR) #define cvar_modifiedFlags *((int*)(cvar_modifiedFlags_ADDR)) #define com_codeTimeScale *((int*)(com_codeTimeScale_ADDR))
1,382
C
.h
24
54.25
87
0.691111
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,966
elf32_parser.h
haithun_CoD4X17a_testing/elf32_parser.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ typedef struct{ long size; long offset; }elf_data_t; int ELF32_GetStrTable(char *fname, char **output,elf_data_t *text);
1,115
C
.h
21
49.047619
87
0.651013
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,381,972
plugin_handler.h
haithun_CoD4X17a_testing/plugin_handler.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef PLUGIN_HANDLER_H #define PLUGIN_HANDLER_H /*==========================================* * * * Plugin Handler's header * * * * Contains all necessary prototypes * * and types for using the Plugin Handler. * * * *==========================================*/ #define MAX_PLUGINS 25 // Maximum number of loaded plugins, hardcoded for better performance typedef void convariable_t; //For plugins #define P_P_F __attribute__((__noinline__)) __attribute__((__cdecl__)) #include <stdarg.h> #include <stdlib.h> #include <string.h> #include <dlfcn.h> #include <execinfo.h> #include "cmd.h" // xcommand_t #include "sys_net.h" // netadr #include "msg.h" // msg_t #include "g_shared.h" // level #include "qcommon_io.h" // Com_Printf #include "server.h" // client_t #include "sys_net.h" // Tcp stuff #include "plugins/plugin_declarations.h" #include "plugin_events.h" #define PLUGIN_MAX_MALLOCS 50 #define PLUGIN_MAX_SOCKETS 4 // plugins com #define PLUGIN_COM_MAXNAMELEN 28 // Max 27 chars + \0 #define PLUGIN_MAX_EXPORTS 50 // Maximum count of exported functions, each takes 32B of mem = 1kB per plugin // ----------------------------// // Plugin Handler's own types // // ----------------------------// enum { PLUGIN_UNKNOWN = -1 }; typedef struct{ char name[32]; xcommand_t xcommand; }pluginCmd_t; typedef struct{ size_t size; void *ptr; }pluginMem_t; typedef struct{ char name[PLUGIN_COM_MAXNAMELEN]; void *(*function)(); }pluginExport_t; typedef struct{ int sock; netadr_t remote; qboolean (*packetEventHandler)(netadr_t *from, msg_t* msg); }pluginTcpClientSocket_t; typedef struct{ int (*OnInit)(); // Initialization function void (*OnInfoRequest)(); // Info gathering function void (*OnEvent[PLUGINS_ITEMCOUNT])(); void (*OnUnload)(); // De-initialization function pluginCmd_t cmd[20]; pluginCmd_t scriptFunction[32]; pluginCmd_t scriptMethod[32]; int cmds; int scriptfunctions; int scriptmethods; char name[20]; pluginMem_t memory[PLUGIN_MAX_MALLOCS]; pluginTcpClientSocket_t sockets[PLUGIN_MAX_SOCKETS]; pluginExport_t exportedFunctions[PLUGIN_MAX_EXPORTS]; int exports; size_t usedMem; int mallocs; qboolean loaded; qboolean enabled; void *lib_handle; void *lib_start; long lib_size; }plugin_t; typedef struct{ plugin_t plugins[MAX_PLUGINS]; int loadedPlugins; qboolean enabled; qboolean initializing_plugin; }pluginWrapper_t; extern pluginWrapper_t pluginFunctions; // defined in plugin_handler.c // --------------------------------// // Plugin Handler's own functions // // --------------------------------// void PHandler_Load(char*,size_t); void PHandler_Unload(int id); void PHandler_Event(int, ...); void PHandler_Init(); void *PHandler_Malloc(int,size_t); void PHandler_Free(int,void *); void PHandler_FreeAll(int); void PHandler_Error(int,int, char *); qboolean PHandler_TcpConnect(int,const char *,int); int PHandler_TcpGetData(int, int, void*, int); qboolean PHandler_TcpSendData(int,int, void*, int); void PHandler_TcpCloseConnection(int,int); int PHandler_CallerID(); void PHandler_ChatPrintf(int,char *,...); void PHandler_CmdExecute_f( void ); // fake server command for use in plugin commands // --------------------------------------// // Plugin Handler's own server commands // // --------------------------------------// void PHandler_LoadPlugin_f( void ); void PHandler_UnLoadPlugin_f( void ); void PHandler_PluginList_f( void ); void PHandler_PluginInfo_f( void ); #endif /*PLUGIN_HANDLER_H*/
4,809
C
.h
128
34.554688
114
0.630679
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,382,010
net_game.h
haithun_CoD4X17a_testing/net_game.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef __NET_GAME_H__ #define __NET_GAME_H__ #include "q_shared.h" #include "sys_net.h" #include "msg.h" void NET_UDPPacketEvent(netadr_t* from, void* data, int len); unsigned int NET_TimeGetTime(); void NET_TCPConnectionClosed(netadr_t* adr, int sock, int connectionId, int serviceId); tcpclientstate_t NET_TCPAuthPacketEvent(netadr_t* remote, byte* bufData, int cursize, int sock, int* connectionId, int *serviceId); void NET_TCPPacketEvent(netadr_t* remote, byte* bufData, int cursize, int sock, int connectionId, int serviceId); void NET_TCPAddEventType( qboolean (*tcpevent)(netadr_t* from, msg_t* msg, int socketfd, int connectionId), tcpclientstate_t (*tcpauthevent)(netadr_t* from, msg_t* msg, int socketfd, int *connectionId), void (*tcpconncloseevent)(netadr_t* from, int socketfd, int connectionId), int serviceId ); #endif
1,859
C
.h
33
52.515152
131
0.688362
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,382,012
cmd.h
haithun_CoD4X17a_testing/cmd.h
/* =========================================================================== Copyright (C) 2010-2013 Ninja and TheKelm of the IceOps-Team Copyright (C) 1999-2005 Id Software, Inc. This file is part of CoD4X17a-Server source code. CoD4X17a-Server source code is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CoD4X17a-Server source code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/> =========================================================================== */ #ifndef __CMD_H__ #define __CMD_H__ #include "q_shared.h" // paramters for command buffer stuffing typedef enum { EXEC_NOW, // don't return until completed, a VM should NEVER use this, // because some commands might cause the VM to be unloaded... EXEC_INSERT, // insert at current position, but don't run yet EXEC_APPEND // add to end of the command buffer (normal case) } cbufExec_t; #define MAX_CMD_BUFFER 16384 #define MAX_CMD_LINE 1024 /* typedef struct { byte *data; int maxsize; int cursize; } cmd_t; int cmd_wait; cmd_t cmd_text; byte cmd_text_buf[MAX_CMD_BUFFER]; */ typedef void *xcommand_t; typedef void (*completionFunc_t)( char *args, int argNum ); typedef struct cmd_function_s { struct cmd_function_s *next; char *name; int minPower; completionFunc_t complete; xcommand_t function; } cmd_function_t; //static int cmd_argc; //static char *cmd_argv[MAX_STRING_TOKENS]; // points into cmd_tokenized //static char cmd_tokenized[BIG_INFO_STRING + MAX_STRING_TOKENS]; // will have 0 bytes inserted //static char cmd_cmd[BIG_INFO_STRING]; // the original command we received (no token processing) #define MAX_POWERLIST 256 void __cdecl Cmd_Init(void); void __cdecl Cmd_TokenizeString(const char* string); void __cdecl SV_Cmd_TokenizeString(const char* string); void __cdecl Cmd_EndTokenizeString(); void __cdecl SV_Cmd_EndTokenizeString(); void __cdecl Cmd_ExecuteSingleCommand(int unk, int unk2, const char *cmd ); void __cdecl Cbuf_Init(void); void __cdecl Cbuf_Execute(int, int); void __cdecl Cbuf_ExecuteBuffer(int, int, char* buf); void __cdecl Cbuf_AddText(int dummy, const char* text); qboolean Cmd_AddCommand( const char *cmd_name, xcommand_t function ); qboolean Cmd_RemoveCommand( const char *cmd_name ); qboolean Cmd_SetPower(const char *cmd_name, int power); int Cmd_GetPower(const char *cmd_name); void Cmd_ResetPower(); int SV_Cmd_Argc( void ); int Cmd_Argc( void ); char *SV_Cmd_Argv( int arg ); void SV_Cmd_ArgvBuffer( int arg, char *buffer, int bufferLength ); char *Cmd_Argv( int arg ); char *Cmd_Args( char* buff, int bufsize ); char *Cmd_Argsv( int arg, char* buff, int bufsize ); void Cmd_CommandCompletion( void(*callback)(const char *s) ); void Cmd_CompleteArgument( const char *command, char *args, int argNum ); void Cmd_SetCommandCompletionFunc( const char *command, completionFunc_t complete ); void Cmd_AddCommands(void); void Cmd_WritePowerConfig(char* buffer, int size); qboolean Cmd_InfoSetPower( const char *infostring ); void Cmd_Vstr_f(void); void Cmd_Wait_f(void); void Cmd_Exec_f(void); #endif
3,665
C
.h
86
40.55814
105
0.709024
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,382,024
cvar.h
haithun_CoD4X17a_testing/plugins/cvar.h
typedef enum{ CVAR_BOOL, CVAR_FLOAT, CVAR_VEC2, CVAR_VEC3, CVAR_VEC4, CVAR_INT, CVAR_ENUM, CVAR_STRING, CVAR_COLOR }cvarType_t; typedef struct{ char *name; char *description; short int flags; byte type; byte modified; union{ float floatval; float value; int integer; char* string; byte boolean; }; } cvar_t;
362
C
.h
25
11.32
19
0.678571
haithun/CoD4X17a_testing
3
29
0
AGPL-3.0
9/7/2024, 2:05:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,438,774
htmlpost.c
kb1isz_linDmrMaster/htmlpost.c
/* * Linux DMR Master server Copyright (C) 2014 Wim Hofman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "master_server.h" #include "webserv.h" char page[50]; void handleParameter(); sqlite3 *openDatabase(); void closeDatabase(); int handlePost(int conn, struct ReqInfo *reqinfo){ char buffer[MAX_REQ_LINE] = {0}; fd_set fds; struct timeval tv; int rval; tv.tv_sec = 1; tv.tv_usec = 0; for (;;){ FD_ZERO(&fds); FD_SET (conn, &fds); rval = select(conn + 1, &fds, NULL, NULL, &tv); if ( rval < 0 ) { syslog(LOG_NOTICE,"Error calling select() in get_request()"); } else if ( rval == 0 ) { break; } else { Readline(conn, buffer, MAX_REQ_LINE - 1); Trim(buffer); handleParameter(buffer); } } restart = 1; } void handleParameter(char buffer[MAX_REQ_LINE]){ char *param; char *value; char *listValue; char SQLQUERY[300]; db = openDatabase(); if(param = strtok(buffer,"=")){ if (strstr(param,"page")){ value = strtok(NULL,"="); sprintf(page,"%s",value); } else if(strstr(param,"addedList")){ value = strtok(NULL,"="); if (value != NULL){ listValue = strtok(value,";"); if (listValue != NULL){ sprintf(SQLQUERY,"INSERT INTO %s (repeaterId) VALUES (%s)",page,listValue); syslog(LOG_NOTICE,"Updating database '%s'",SQLQUERY); if (sqlite3_exec(db,SQLQUERY,0,0,0) != 0){ syslog(LOG_NOTICE,"Database error: %s",sqlite3_errmsg(db)); } } while (listValue = strtok(NULL,";")){ sprintf(SQLQUERY,"INSERT INTO %s (repeaterId) VALUES (%s)",page,listValue); syslog(LOG_NOTICE,"Updating database '%s'",SQLQUERY); if (sqlite3_exec(db,SQLQUERY,0,0,0) != 0){ syslog(LOG_NOTICE,"Database error: %s",sqlite3_errmsg(db)); } } } } else if(strstr(param,"removedList")){ value = strtok(NULL,"="); if (value != NULL){ listValue = strtok(value,";"); if (listValue != NULL){ sprintf(SQLQUERY,"DELETE FROM %s WHERE repeaterId = %s",page,listValue); syslog(LOG_NOTICE,"Updating database '%s'",SQLQUERY); if (sqlite3_exec(db,SQLQUERY,0,0,0) != 0){ syslog(LOG_NOTICE,"Database error: %s",sqlite3_errmsg(db)); } } while (listValue = strtok(NULL,";")){ sprintf(SQLQUERY,"DELETE FROM %s WHERE repeaterId = %s",page,listValue); syslog(LOG_NOTICE,"Updating database '%s'",SQLQUERY); if (sqlite3_exec(db,SQLQUERY,0,0,0) != 0){ syslog(LOG_NOTICE,"Database error: %s",sqlite3_errmsg(db)); } } } } else{ value = strtok(NULL,"="); if (value != NULL){ sprintf(SQLQUERY,"UPDATE %s SET %s = '%s'",page,param,value); syslog(LOG_NOTICE,"Updating database '%s'",SQLQUERY); if (sqlite3_exec(db,SQLQUERY,0,0,0) != 0){ syslog(LOG_NOTICE,"Database error: %s",sqlite3_errmsg(db)); } } } } closeDatabase(db); }
3,533
C
.c
110
28.054545
80
0.657084
kb1isz/linDmrMaster
3
26
0
GPL-2.0
9/7/2024, 2:06:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,438,775
webserv.c
kb1isz_linDmrMaster/webserv.c
/* * Linux DMR Master server Copyright (C) 2014 Wim Hofman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /*Source code inspired on the work of Paul Griffiths www.paulgriffiths.net */ #include "master_server.h" #include "webserv.h" void *Service_Request(); int Parse_HTTP_Header(char * buffer, struct ReqInfo * reqinfo); int Get_Request (int conn, struct ReqInfo * reqinfo); void InitReqInfo (struct ReqInfo * reqinfo); void FreeReqInfo (struct ReqInfo * reqinfo); int Output_HTTP_Headers(int conn, struct ReqInfo * reqinfo); int Return_Resource (int conn, FILE *resource, struct ReqInfo * reqinfo); FILE *Check_Resource (struct ReqInfo * reqinfo); int Return_Error_Msg(int conn, struct ReqInfo * reqinfo); int Trim (char * buffer); int StrUpper (char * buffer); void CleanURL (char * buffer); ssize_t Readline (int sockd, void *vptr, size_t maxlen); ssize_t Writeline (int sockd, const void *vptr, size_t n); #define SERVER_PORT (8080) char *htmlReplace(); void *webServerListener(){ int listener, conn; pid_t pid; struct sockaddr_in servaddr; int yes=1; // for setsockopt() SO_REUSEADDR, below pthread_t thread; /* Create socket */ if ( (listener = socket(AF_INET, SOCK_STREAM, 0)) < 0 ){ syslog(LOG_NOTICE,"Couldn't create listening socket."); pthread_exit(NULL); } /* Populate socket address structure */ memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr = inet_addr("0.0.0.0"); servaddr.sin_port = htons(SERVER_PORT); setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)); /* Assign socket address to socket */ if ( bind(listener, (struct sockaddr *) &servaddr, sizeof(servaddr)) < 0 ){ syslog(LOG_NOTICE,"Couldn't bind listening socket."); pthread_exit(NULL); } /* Make socket a listening socket */ if ( listen(listener, LISTENQ) < 0 ){ syslog(LOG_NOTICE,"Call to listen failed."); pthread_exit(NULL); } syslog(LOG_NOTICE,"Web server started"); /* Loop infinitely to accept and service connections */ while ( 1 ) { /* Wait for connection */ if ( (conn = accept(listener, NULL, NULL)) < 0 ){ syslog(LOG_NOTICE,"Error calling accept()"); continue; } pthread_create(&thread, NULL, Service_Request,(void *)conn); } } void *Service_Request(void *f) { int conn = (intptr_t)f; FILE *resource; struct ReqInfo reqinfo; InitReqInfo(&reqinfo); /* Get HTTP request */ if ( Get_Request(conn, &reqinfo) < 0 ) printf("error"); //return -1; if (reqinfo.method == POST){ handlePost(conn,&reqinfo); } if (strlen(reqinfo.resource) == 1) sprintf(reqinfo.resource,"/index.html"); /* Check whether resource exists, whether we have permission to access it, and update status code accordingly. */ if ( reqinfo.status == 200 ){ if ( (resource = Check_Resource(&reqinfo)) < 0 ) { if ( errno == EACCES ) reqinfo.status = 401; else reqinfo.status = 404; } } /* Output HTTP response headers if we have a full request */ if ( reqinfo.type == FULL ) Output_HTTP_Headers(conn, &reqinfo); /* Service the HTTP request */ if ( reqinfo.status == 200 ) { if ( Return_Resource(conn, resource, &reqinfo) ) syslog(LOG_NOTICE,"Something wrong returning resource."); } else Return_Error_Msg(conn, &reqinfo); if ( resource > 0 ) if ( fclose(resource) < 0 ) syslog(LOG_NOTICE,"Error closing resource."); FreeReqInfo(&reqinfo); close(conn); } int Parse_HTTP_Header(char * buffer, struct ReqInfo * reqinfo) { //static int first_header = 1; char *temp; char *endptr; int len; int first = 0; //if ( first_header == 1 ) { /* If first_header is 0, this is the first line of the HTTP request, so this should be the request line. */ /* Get the request method, which is case-sensitive. */ if ( !strncmp(buffer, "GET ", 4) ) { reqinfo->method = GET; buffer += 4; first = 1; } else if ( !strncmp(buffer, "HEAD ", 5) ) { reqinfo->method = HEAD; buffer += 5; first = 1; } else if ( !strncmp(buffer, "POST ", 5) ) { reqinfo->method = POST; buffer += 5; first = 1; } /*else { reqinfo->method = UNSUPPORTED; reqinfo->status = 501; return -1; }*/ if (first == 1){ /* Skip to start of resource */ while ( *buffer && isspace(*buffer) ) buffer++; /* Calculate string length of resource... */ endptr = strchr(buffer, ' '); if ( endptr == NULL ) len = strlen(buffer); else len = endptr - buffer; if ( len == 0 ) { reqinfo->status = 400; return -1; } /* ...and store it in the request information structure. */ reqinfo->resource = calloc(len + 1, sizeof(char)); strncpy(reqinfo->resource, buffer, len); /* Test to see if we have any HTTP version information. If there isn't, this is a simple HTTP request, and we should not try to read any more headers. For simplicity, we don't bother checking the validity of the HTTP version information supplied - we just assume that if it is supplied, then it's a full request. */ if ( strstr(buffer, "HTTP/") ) reqinfo->type = FULL; else reqinfo->type = SIMPLE; //first_header = 0; return 0; } /* If we get here, we have further headers aside from the request line to parse, so this is a "full" HTTP request. */ /* HTTP field names are case-insensitive, so make an upper-case copy of the field name to aid comparison. We need to make a copy of the header up until the colon. If there is no colon, we return a status code of 400 (bad request) and terminate the connection. Note that HTTP/1.0 allows (but discourages) headers to span multiple lines if the following lines start with a space or a tab. For simplicity, we do not allow this here. */ endptr = strchr(buffer, ':'); if ( endptr == NULL ) { reqinfo->status = 400; return -1; } temp = calloc( (endptr - buffer) + 1, sizeof(char) ); strncpy(temp, buffer, (endptr - buffer)); StrUpper(temp); /* Increment buffer so that it now points to the value. If there is no value, just return. */ buffer = endptr + 1; while ( *buffer && isspace(*buffer) ) ++buffer; if ( *buffer == '\0' ) return 0; /* Now update the request information structure with the appropriate field value. This version only supports the "Referer:" and "User-Agent:" headers, ignoring all others. */ if ( !strcmp(temp, "USER-AGENT") ) { reqinfo->useragent = malloc( strlen(buffer) + 1 ); strcpy(reqinfo->useragent, buffer); } else if ( !strcmp(temp, "REFERER") ) { reqinfo->referer = malloc( strlen(buffer) + 1 ); strcpy(reqinfo->referer, buffer); } free(temp); return 0; } /* Gets request headers. A CRLF terminates a HTTP header line, but if one is never sent we would wait forever. Therefore, we use select() to set a maximum length of time we will wait for the next complete header. If we timeout before this is received, we terminate the connection. */ int Get_Request(int conn, struct ReqInfo * reqinfo) { char buffer[MAX_REQ_LINE] = {0}; int rval; fd_set fds; struct timeval tv; /* Set timeout to 5 seconds */ tv.tv_sec = 5; tv.tv_usec = 0; /* Loop through request headers. If we have a simple request, then we will loop only once. Otherwise, we will loop until we receive a blank line which signifies the end of the headers, or until select() times out, whichever is sooner. */ do { /* Reset file descriptor set */ FD_ZERO(&fds); FD_SET (conn, &fds); /* Wait until the timeout to see if input is ready */ rval = select(conn + 1, &fds, NULL, NULL, &tv); /* Take appropriate action based on return from select() */ if ( rval < 0 ) { syslog(LOG_NOTICE,"Error calling select() in get_request()"); } else if ( rval == 0 ) { /* input not ready after timeout */ return -1; } else { /* We have an input line waiting, so retrieve it */ Readline(conn, buffer, MAX_REQ_LINE - 1); Trim(buffer); if ( buffer[0] == '\0'){ break; } if ( Parse_HTTP_Header(buffer, reqinfo) ) break; } } while ( reqinfo->type != SIMPLE ); return 0; } /* Initialises a request information structure */ void InitReqInfo(struct ReqInfo * reqinfo) { reqinfo->useragent = NULL; reqinfo->referer = NULL; reqinfo->resource = NULL; reqinfo->method = UNSUPPORTED; reqinfo->status = 200; } /* Frees memory allocated for a request information structure */ void FreeReqInfo(struct ReqInfo * reqinfo) { if ( reqinfo->useragent ) free(reqinfo->useragent); if ( reqinfo->referer ) free(reqinfo->referer); if ( reqinfo->resource ) free(reqinfo->resource); } int Output_HTTP_Headers(int conn, struct ReqInfo * reqinfo) { char buffer[100]; sprintf(buffer, "HTTP/1.0 %d OK\r\n", reqinfo->status); Writeline(conn, buffer, strlen(buffer)); Writeline(conn, "Server: PGWebServ v0.1\r\n", 24); Writeline(conn, "Content-Type: text/html\r\n", 25); Writeline(conn, "\r\n", 2); return 0; } /* Returns a resource */ int Return_Resource(int conn, FILE *resource, struct ReqInfo * reqinfo) { char c; int i; char line[2000]; char sendLine[2000]; if (strstr(reqinfo->resource,".html")){ while(fgets(line,sizeof(line),resource)){ sprintf(sendLine,"%s",htmlReplace(line,reqinfo->resource)); if ( send(conn, sendLine, strlen(sendLine),MSG_NOSIGNAL) < 1 ){ syslog(LOG_NOTICE,"Error sending file."); break; } } } else{ while (!feof(resource)){ c = fgetc(resource); if ( send(conn, &c, 1,MSG_NOSIGNAL) < 1 ){ syslog(LOG_NOTICE,"Error sending file."); break; } } } return 0; } /* Tries to open a resource. The calling function can use the return value to check for success, and then examine errno to determine the cause of failure if neceesary. */ FILE *Check_Resource(struct ReqInfo * reqinfo) { /* Resource name can contain urlencoded data, so clean it up just in case. */ char server_root[1000] = "./html"; CleanURL(reqinfo->resource); /* Concatenate resource name to server root, and try to open */ strcat(server_root, reqinfo->resource); return fopen(server_root, "r"); } /* Returns an error message */ int Return_Error_Msg(int conn, struct ReqInfo * reqinfo) { char buffer[100]; sprintf(buffer, "<HTML>\n<HEAD>\n<TITLE>Server Error %d</TITLE>\n" "</HEAD>\n\n", reqinfo->status); Writeline(conn, buffer, strlen(buffer)); sprintf(buffer, "<BODY>\n<H1>Server Error %d</H1>\n", reqinfo->status); Writeline(conn, buffer, strlen(buffer)); sprintf(buffer, "<P>The request could not be completed.</P>\n" "</BODY>\n</HTML>\n"); Writeline(conn, buffer, strlen(buffer)); return 0; } /* Read a line from a socket */ ssize_t Readline(int sockd, void *vptr, size_t maxlen) { ssize_t n, rc; char c, *buffer; buffer = vptr; for ( n = 1; n < maxlen; n++ ) { if ( (rc = read(sockd, &c, 1)) == 1 ) { *buffer++ = c; if ( c == '\n' ) break; } else if ( rc == 0 ) { if ( n == 1 ) return 0; else break; } else { if ( errno == EINTR ) continue; syslog(LOG_NOTICE,"Error in Readline()"); } } *buffer = 0; return n; } /* Write a line to a socket */ ssize_t Writeline(int sockd, const void *vptr, size_t n) { size_t nleft; ssize_t nwritten; const char *buffer; buffer = vptr; nleft = n; while ( nleft > 0 ) { if ( (nwritten = write(sockd, buffer, nleft)) <= 0 ) { if ( errno == EINTR ) nwritten = 0; else syslog(LOG_NOTICE,"Error in Writeline()"); } nleft -= nwritten; buffer += nwritten; } return n; } /* Removes trailing whitespace from a string */ int Trim(char * buffer) { int n = strlen(buffer) - 1; while ( !isalnum(buffer[n]) && n >= 0 ) buffer[n--] = '\0'; return 0; } /* Converts a string to upper-case */ int StrUpper(char * buffer) { while ( *buffer ) { *buffer = toupper(*buffer); ++buffer; } return 0; } /* Cleans up url-encoded string */ void CleanURL(char * buffer) { char asciinum[3] = {0}; int i = 0, c; while ( buffer[i] ) { if ( buffer[i] == '+' ) buffer[i] = ' '; else if ( buffer[i] == '%' ) { asciinum[0] = buffer[i+1]; asciinum[1] = buffer[i+2]; buffer[i] = strtol(asciinum, NULL, 16); c = i+1; do { buffer[c] = buffer[c+2]; } while ( buffer[2+(c++)] ); } ++i; } }
13,606
C
.c
408
29.352941
108
0.643274
kb1isz/linDmrMaster
3
26
0
GPL-2.0
9/7/2024, 2:06:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,438,777
BPTC1969.c
kb1isz_linDmrMaster/BPTC1969.c
/* * Linux DMR Master server Copyright (C) 2014 Wim Hofman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /*Source code inspired on the work of Paul Griffiths www.paulgriffiths.net */ #include "master_server.h" struct BPTC1969{ bool responseRequested; int dataPacketFormat; int sapId; int appendBlocks; }; bool * extractInfo(bool bits[264]){ static bool info[196]; int bytePos=0; int i; //printf("Info bits: "); for(i=0;i<98;i++){ info[bytePos] = bits[i]; //printf("%i",info[bytePos]); bytePos++; } for(i=166;i<264;i++){ info[bytePos] = bits[i]; //printf("%i",info[bytePos]); bytePos++; } //printf("\n"); return info; } bool * deInterleave(bool * bits){ static bool deInterleavedBits[196]; int a,interleaveSequence; for (a=0;a<196;a++){ interleaveSequence=(a*181)%196; deInterleavedBits[a] = *(bits + interleaveSequence); } return deInterleavedBits; } bool * extractPayload(bool * deInterData){ int a,pos=0; static bool outData[96]; for (a=4;a<=11;a++) { outData[pos]=*(deInterData+a); pos++; } for (a=16;a<=26;a++) { outData[pos]=*(deInterData+a); pos++; } for (a=31;a<=41;a++) { outData[pos]=*(deInterData+a); pos++; } for (a=46;a<=56;a++) { outData[pos]=*(deInterData+a); pos++; } for (a=61;a<=71;a++) { outData[pos]=*(deInterData+a); pos++; } for (a=76;a<=86;a++) { outData[pos]=*(deInterData+a); pos++; } for (a=91;a<=101;a++) { outData[pos]=*(deInterData+a); pos++; } for (a=106;a<=116;a++) { outData[pos]=*(deInterData+a); pos++; } for (a=121;a<=131;a++) { outData[pos]=*(deInterData+a); pos++; } return outData; } struct BPTC1969 decodeBPTC1969(bool bits[264]){ bool *infoBits; //196 info bits bool *deInterleavedBits; //196 bits static bool *payloadBits; //96 bits int blocksToFollow=0,a; unsigned char dpf=0,sap=0,bitPadding=0; struct BPTC1969 BPTC1969decode; infoBits = extractInfo(bits); deInterleavedBits = deInterleave(infoBits); payloadBits = extractPayload(deInterleavedBits); /*printf("Payload bits\n"); for(a=0;a<96;a++){ printf("%i",*(payloadBits+a)); } printf("\n");*/ if(*(payloadBits+1) == 1){ BPTC1969decode.responseRequested = true; //syslog(LOG_NOTICE,"response requested"); } else{ BPTC1969decode.responseRequested = false; //syslog(LOG_NOTICE,"NO response requested"); } for(a=4;a<8;a++){ if(*(payloadBits + a) == true) dpf = dpf + (char)(8 / pow(2,a-4)); } //syslog(LOG_NOTICE,"Data Packet Format: "); BPTC1969decode.dataPacketFormat = dpf; switch (dpf){ case 0: //syslog(LOG_NOTICE,"Unified Data Transport\n"); break; case 1: //syslog(LOG_NOTICE,"Response packet\n"); break; case 2: //syslog(LOG_NOTICE,"Data packet with unconfirmed delivery\n"); break; case 3: //syslog(LOG_NOTICE,"Data packet with confirmed delivery\n"); break; case 13: //syslog(LOG_NOTICE,"Short Data: Defined\n"); break; case 14: //syslog(LOG_NOTICE,"Short Data: Raw or Status/Precoded\n"); break; case 15: //syslog(LOG_NOTICE,"Proprietary Data Packet\n"); break; } for(a=8;a<12;a++){ if(*(payloadBits + a) == true) sap = sap + (char)(8 / pow(2,a-8)); } //syslog(LOG_NOTICE,"SAP id: "); BPTC1969decode.sapId = sap; switch (sap){ case 0: //syslog(LOG_NOTICE,"Unified Data Transport\n"); break; case 2: //syslog(LOG_NOTICE,"TCP/IP header compression\n"); break; case 3: //syslog(LOG_NOTICE,"UDP/IP header compression\n"); break; case 4: //syslog(LOG_NOTICE,"IP based Packet data\n"); break; case 5: //syslog(LOG_NOTICE,"Address Resolution Protocol(ARP)\n"); break; case 9: //syslog(LOG_NOTICE,"Proprietary Packet data\n"); break; case 10: //syslog(LOG_NOTICE,"Short Data\n"); break; } if (dpf == 13){ for(a=12;a<16;a++){//only AB in 2nd octet if(*(payloadBits + a) == true) blocksToFollow = blocksToFollow + (char)(8 / pow(2,a-12)); } BPTC1969decode.appendBlocks = blocksToFollow; //syslog(LOG_NOTICE,"Appended blocks : %i\n",blocksToFollow); for(a=72;a<80;a++){ if(*(payloadBits + a) == true) bitPadding = bitPadding + (char)(128 / pow(2,a-12)); } } return BPTC1969decode; }
6,422
C
.c
184
23.63587
114
0.507744
kb1isz/linDmrMaster
3
26
0
GPL-2.0
9/7/2024, 2:06:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,438,779
smaster.c
kb1isz_linDmrMaster/smaster.c
/* * Linux DMR Master server Copyright (C) 2014 Wim Hofman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "master_server.h" #define NUMSLOTS 2 //DMR IS 2 SLOT #define SLOT1 4369 //HEX 1111 #define SLOT2 8738 //HEX 2222 #define VCALL 4369 //HEX 1111 #define DCALL 26214 //HEX 6666 #define ISSYNC 61166 //HEX EEEE #define VCALLEND 8738 //HEX 2222 //#define CALL 2 //#define CALLEND 3 #define PTYPE_ACTIVE1 2 #define PTYPE_END1 3 #define PTYPE_ACTIVE2 66 #define PTYPE_END2 67 #define VFRAMESIZE 103 //UDP PAYLOAD SIZE OF sMaster #define SYNC_OFFSET1 18 //UDP OFFSETS FOR VARIOUS BYTES IN THE DATA STREAM #define SYNC_OFFSET2 19 // //#define SYNC_OFFSET3 18 //Look for EEEE //#define SYNC_OFFSET4 19 //Look for EEEE #define SLOT_OFFSET1 16 // #define SLOT_OFFSET2 17 #define PTYPE_OFFSET 8 #define SRC_OFFSET1 68 #define SRC_OFFSET2 69 #define SRC_OFFSET3 70 #define DST_OFFSET1 64 #define DST_OFFSET2 65 #define DST_OFFSET3 66 #define TYP_OFFSET1 62 struct masterData sMaster = {0}; struct allow{ bool repeater; bool sMaster; bool isRange; }; struct allow checkTalkGroup(); void *sMasterThread(){ int sockfd = 0; char ping[50]; unsigned char buffer[VFRAMESIZE]; unsigned char repInfo[200]; int n,rc,i; fd_set fdMaster; struct timeval timeout; time_t timeNow,needPingTime,reportTime,pongTime; int packetType = 0; unsigned char slot = 0; int sync = 0; int srcId = 0; int dstId = 0; int callType = 0; unsigned char origC[5][3]; struct sockaddr_in servaddr,cliaddr; struct allow toSend = {0}; bool block[3]; syslog(LOG_NOTICE,"Starting sMaster thread"); block[1] = false; block[2] = false; sockfd=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP); bzero(&servaddr,sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr=INADDR_ANY; servaddr.sin_port=htons(atoi(master.sMasterPort)); bind(sockfd,(struct sockaddr *)&servaddr,sizeof(servaddr)); servaddr.sin_addr.s_addr=inet_addr(master.sMasterIp); sMaster.address = servaddr; sMaster.sockfd = sockfd; sMaster.online = true; sprintf(ping,"PING%s%s%s ",master.ownCountryCode,master.ownRegion,version); time(&needPingTime); sendto(sockfd,ping,strlen(ping),0,(struct sockaddr *)&servaddr,sizeof(servaddr)); time(&reportTime); FD_ZERO(&fdMaster); for(;;){ FD_SET(sockfd, &fdMaster); timeout.tv_sec = 1; timeout.tv_usec = 0; if (rc = select(sockfd+1, &fdMaster, NULL, NULL, &timeout) == -1) { syslog(LOG_NOTICE,"Select error in sMaster thread"); close(sockfd); //need to reconnect here !!!! } if (FD_ISSET(sockfd,&fdMaster)) { n = recv(sockfd,buffer,VFRAMESIZE,0); if (n<VFRAMESIZE){ if (strstr(buffer,"RREQ")){ syslog(LOG_NOTICE,"RREQ from sMaster"); char rreqResponse[200]; char myCCInfo[21]; sprintf(myCCInfo,"%s%s",master.ownCountryCode,master.ownRegion); sprintf(rreqResponse,"TS1R%-20s%-20s%s",myCCInfo,master.ownName,master.announcedCC1); syslog(LOG_NOTICE,"RREQ response %s",rreqResponse); sendto(sockfd,rreqResponse,strlen(rreqResponse),0,(struct sockaddr *)&servaddr,sizeof(servaddr)); sprintf(rreqResponse,"TS2R%-20s%-20s%s",myCCInfo,master.ownName,master.announcedCC2); syslog(LOG_NOTICE,"RREQ response %s",rreqResponse); sendto(sockfd,rreqResponse,strlen(rreqResponse),0,(struct sockaddr *)&servaddr,sizeof(servaddr)); unsigned char ip[INET_ADDRSTRLEN]; for (i=0;i<highestRepeater;i++){ if (repeaterList[i].address.sin_addr.s_addr !=0){ inet_ntop(AF_INET, &(repeaterList[i].address.sin_addr), ip, INET_ADDRSTRLEN); sprintf(repInfo,"RPT%02i%-15s%i%i%i%i%-4s%-16s%-9s%-6s0 0 %-10s%-12s%-3s",i,ip,repeaterList[i].id,baseDmrPort+i, master.ownCCInt,master.ownRegionInt,version,repeaterList[i].callsign,repeaterList[i].txFreq,repeaterList[i].shift, repeaterList[i].hardware,repeaterList[i].firmware,repeaterList[i].mode); sendto(sockfd,repInfo,strlen(repInfo),0,(struct sockaddr *)&servaddr,sizeof(servaddr)); syslog(LOG_NOTICE,"RREQ response %s",repInfo); usleep(60000); } } time(&reportTime); } if (strstr(buffer,"PONG")){ time(&pongTime); } } else{ slot = buffer[SLOT_OFFSET1] / 16; if (dmrState[slot] == IDLE || sMaster.sending[slot]){ packetType = buffer[PTYPE_OFFSET]; sync = buffer[SYNC_OFFSET1] << 8 | buffer[SYNC_OFFSET2]; switch (packetType){ case 0x01: if (sync == VCALL && dmrState[slot] != VOICE && block[slot] == false){ srcId = buffer[SRC_OFFSET3] << 16 | buffer[SRC_OFFSET2] << 8 | buffer[SRC_OFFSET1]; dstId = buffer[DST_OFFSET3] << 16 | buffer[DST_OFFSET2] << 8 | buffer[DST_OFFSET1]; callType = buffer[TYP_OFFSET1]; toSend = checkTalkGroup(dstId,slot,callType); if (toSend.repeater == false){ block[slot] = true; break; } sMaster.sending[slot] = true; dmrState[slot] = VOICE; syslog(LOG_NOTICE,"[sMaster]Voice call started on slot %i src %i dst %i type %i",slot,srcId,dstId,callType); if (buffer[90] !=0) { memcpy(origC[slot],buffer+90,4); syslog(LOG_NOTICE,"[sMaster]Replacing country code to %s",origC[slot]); } else{ memcpy(origC[slot],buffer+64,4); } break; } if (sync == DCALL && dmrState[slot] != DATA){ srcId = buffer[SRC_OFFSET3] << 16 | buffer[SRC_OFFSET2] << 8 | buffer[SRC_OFFSET1]; dstId = buffer[DST_OFFSET3] << 16 | buffer[DST_OFFSET2] << 8 | buffer[DST_OFFSET1]; callType = buffer[TYP_OFFSET1]; syslog(LOG_NOTICE,"[sMaster]Data on slot %i src %i dst %i type %i",slot,srcId,dstId,callType); break; } break; case 0x03: if (sync == VCALLEND){ dmrState[slot] = IDLE; sMaster.sending[slot] = false; block[slot] = false; syslog(LOG_NOTICE,"[sMaster]Voice call ended on slot %i",slot); } break; } memcpy(buffer+64,origC[slot],4); if (!block[slot]){ for (i=0;i<highestRepeater;i++){ if (repeaterList[i].address.sin_addr.s_addr !=0 && !repeaterList[i].sending[slot]){ sendto(repeaterList[i].sockfd,buffer,72,0,(struct sockaddr *)&repeaterList[i].address,sizeof(repeaterList[i].address)); } } } } else{ syslog(LOG_NOTICE,"[sMaster]Incomming traffic on slot %i, but DMR not IDLE",slot); } } } else{ if (restart){ syslog(LOG_NOTICE,"Exiting sMaster thread (restart)"); close(sockfd); pthread_exit(NULL); } time(&timeNow); if (sMaster.sending[1] && dmrState[1] != IDLE){ dmrState[1] = IDLE; sMaster.sending[1] = false; block[1] = false; syslog(LOG_NOTICE,"[sMaster]Slot 1 IDLE"); } if (sMaster.sending[2] && dmrState[2] != IDLE){ dmrState[2] = IDLE; sMaster.sending[2] = false; block[2] = false; syslog(LOG_NOTICE,"[sMaster]Slot 2 IDLE"); } if (difftime(timeNow,needPingTime) > 5){ time(&needPingTime); sendto(sockfd,ping,strlen(ping),0,(struct sockaddr *)&servaddr,sizeof(servaddr)); } if (difftime(timeNow,reportTime) > 320){ char rreqResponse[200]; char myCCInfo[21]; sprintf(myCCInfo,"%s%s",master.ownCountryCode,master.ownRegion); sprintf(rreqResponse,"TS1R%-20s%-20s%s",myCCInfo,master.ownName,master.announcedCC1); syslog(LOG_NOTICE,"Report to sMaster %s",rreqResponse); sendto(sockfd,rreqResponse,strlen(rreqResponse),0,(struct sockaddr *)&servaddr,sizeof(servaddr)); sprintf(rreqResponse,"TS2R%-20s%-20s%s",myCCInfo,master.ownName,master.announcedCC2); syslog(LOG_NOTICE,"Report to sMaster %s",rreqResponse); sendto(sockfd,rreqResponse,strlen(rreqResponse),0,(struct sockaddr *)&servaddr,sizeof(servaddr)); unsigned char ip[INET_ADDRSTRLEN]; for (i=0;i<highestRepeater;i++){ if (repeaterList[i].address.sin_addr.s_addr !=0){ inet_ntop(AF_INET, &(repeaterList[i].address.sin_addr), ip, INET_ADDRSTRLEN); sprintf(repInfo,"RPT%02i%-15s%i%i%i%i%-4s%-16s%-9s%-6s0 0 %-10s%-12s%-3s",i,ip,repeaterList[i].id,baseDmrPort+i, master.ownCCInt,master.ownRegionInt,version,repeaterList[i].callsign,repeaterList[i].txFreq,repeaterList[i].shift, repeaterList[i].hardware,repeaterList[i].firmware,repeaterList[i].mode); sendto(sockfd,repInfo,strlen(repInfo),0,(struct sockaddr *)&servaddr,sizeof(servaddr)); syslog(LOG_NOTICE,"Report to sMaster %s",repInfo); usleep(60000); } } time(&reportTime); } } } }
9,698
C
.c
238
35.878151
127
0.651321
kb1isz/linDmrMaster
3
26
0
GPL-2.0
9/7/2024, 2:06:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,438,784
convbin.c
kb1isz_linDmrMaster/convbin.c
/* * Linux DMR Master server Copyright (C) 2014 Wim Hofman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ /*Source code inspired on the work of Paul Griffiths www.paulgriffiths.net */ #include "master_server.h" bool * convertToBits(unsigned char packet[33]){ static bool bits[264]; unsigned char convPacket[33]; unsigned char dmrPacket[100]; int i,x; memset(dmrPacket,0,100); //bit invert for (i=0;i<33;i=i+2){ convPacket[i] = *(packet + i + 1); convPacket[i+1] = *(packet +i); //sprintf(dmrPacket,"%s%02x:%02x:",dmrPacket,convPacket[i],convPacket[i+1]); } //syslog(LOG_NOTICE,"DMR packet:%s",dmrPacket); //convert to bits for (i=0;i<33;i++){ for(x=0;x<8;x++){ bits[(7-x) + (8 * i)] = (convPacket[i] >> x) & 1; } } return bits; }
1,452
C
.c
40
33.1
78
0.71449
kb1isz/linDmrMaster
3
26
0
GPL-2.0
9/7/2024, 2:06:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,438,786
decode34Rate.c
kb1isz_linDmrMaster/decode34Rate.c
/* * Linux DMR Master server Copyright (C) 2014 Wim Hofman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "master_server.h" bool * extractInfo(); int INTERLEAVE[] ={ 0,1,8,9,16,17,24,25,32,33,40,41,48,49,56,57,64,65,72,73,80,81,88,89,96,97, 2,3,10,11,18,19,26,27,34,35,42,43,50,51,58,59,66,67,74,75,82,83,90,91, 4,5,12,13,20,21,28,29,36,37,44,45,52,53,60,61,68,69,76,77,84,85,92,93, 6,7,14,15,22,23,30,31,38,39,46,47,54,55,62,63,70,71,78,79,86,87,94,95}; unsigned char STATETABLE[]={ 0,8,4,12,2,10,6,14, 4,12,2,10,6,14,0,8, 1,9,5,13,3,11,7,15, 5,13,3,11,7,15,1,9, 3,11,7,15,1,9,5,13, 7,15,1,9,5,13,3,11, 2,10,6,14,0,8,4,12, 6,14,0,8,4,12,2,10}; char * extractDibits(bool * rawBits){ int a,index=0,deinterleave; char trellisDibit=0; static char encDibit[98]; for (a=0;a<196;a=a+2) { // Set the dibits // 01 = +3 // 00 = +1 // 10 = -1 // 11 = -3 if ((*(rawBits+a)==false)&&(*(rawBits+a+1)==true)) trellisDibit=+3; else if ((*(rawBits+a)==false)&&(*(rawBits+a+1)==false)) trellisDibit=+1; else if ((*(rawBits+a)==true)&&(*(rawBits+a+1)==false)) trellisDibit=-1; else if ((*(rawBits+a)==true)&&(*(rawBits+a+1)==true)) trellisDibit=-3; // Deinterleave deinterleave=INTERLEAVE[index]; encDibit[deinterleave]=trellisDibit; // Increase the index index++; } /*printf("Extracted dibits: "); for (a=0;a<98;a++){ printf("%i:",encDibit[a]); } printf("\n");*/ return encDibit; } char * constellationOut (char * encDibit){ static char constellationPoints[49]; int a,index=0; //printf("constellation: "); for (a=0;a<98;a=a+2) { if ((*(encDibit+a)==+1)&&(*(encDibit+a+1)==-1)) constellationPoints[index]=0; else if ((*(encDibit+a)==-1)&&(*(encDibit+a+1)==-1)) constellationPoints[index]=1; else if ((*(encDibit+a)==+3)&&(*(encDibit+a+1)==-3)) constellationPoints[index]=2; else if ((*(encDibit+a)==-3)&&(*(encDibit+a+1)==-3)) constellationPoints[index]=3; else if ((*(encDibit+a)==-3)&&(*(encDibit+a+1)==-1)) constellationPoints[index]=4; else if ((*(encDibit+a)==+3)&&(*(encDibit+a+1)==-1)) constellationPoints[index]=5; else if ((*(encDibit+a)==-1)&&(*(encDibit+a+1)==-3)) constellationPoints[index]=6; else if ((*(encDibit+a)==+1)&&(*(encDibit+a+1)==-3)) constellationPoints[index]=7; else if ((*(encDibit+a)==-3)&&(*(encDibit+a+1)==+3)) constellationPoints[index]=8; else if ((*(encDibit+a)==+3)&&(*(encDibit+a+1)==+3)) constellationPoints[index]=9; else if ((*(encDibit+a)==-1)&&(*(encDibit+a+1)==+1)) constellationPoints[index]=10; else if ((*(encDibit+a)==+1)&&(*(encDibit+a+1)==+1)) constellationPoints[index]=11; else if ((*(encDibit+a)==+1)&&(*(encDibit+a+1)==+3)) constellationPoints[index]=12; else if ((*(encDibit+a)==-1)&&(*(encDibit+a+1)==+3)) constellationPoints[index]=13; else if ((*(encDibit+a)==+3)&&(*(encDibit+a+1)==+1)) constellationPoints[index]=14; else if ((*(encDibit+a)==-3)&&(*(encDibit+a+1)==+1)) constellationPoints[index]=15; //printf("%i:",constellationPoints[index]); index++; } //printf("\n"); return constellationPoints; } int * tribitExtract (char * cons){ int a,b,rowStart,lastState=0; static int tribit[49]; bool match; //printf("tribits: "); for (a=0;a<49;a++) { // The lastState variable decides which row of STATETABLE we should use rowStart=lastState*8; match=false; for (b=rowStart;b<(rowStart+8);b++) { // Check if this constellation point matches an element of this row of STATETABLE if (*(cons+a)==STATETABLE[b]) { // Yes it does match=true; lastState=b-rowStart; tribit[a]=lastState; } } //printf("%i:",tribit[a]); // If no match found then we have a problem if (match==false){ //printf("no match %i !!!\n",a); return NULL; } } //printf("\n"); return tribit; } bool * binaryConvert (int * tribit){ int a,b=0; static bool out[144]; for (a=0;a<144;a=a+3) { // Convert three bits at a time if ((*(tribit+b)&4)>0) out[a]=true; else out[a]=false; if ((*(tribit+b)&2)>0) out[a+1]=true; else out[a+1]=false; if ((*(tribit+b)&1)>0) out[a+2]=true; else out[a+2]=false; // Increment the bit counter b++; } return out; } unsigned char * decodeThreeQuarterRate(bool bits[264]){ bool *infoBits; //196 info bits char *dibits; //98 info dibits char *constellationPoints; //49 constallation points int *tribits; //49 tribits bool *decodedBinary; //144 bits static unsigned char bb[18]; int x=0,a,i; infoBits = extractInfo(bits); dibits = extractDibits(infoBits); constellationPoints = constellationOut(dibits); tribits = tribitExtract(constellationPoints); decodedBinary = binaryConvert(tribits); for (a=0;a<144;a=a+8){ bb[x] = 0; for (i=0;i<8;i++){ if(decodedBinary[a+i] == true) bb[x] = bb[x] + (char)(128 / pow(2,i)); } printf("(%02X)%c",bb[x],bb[x]); x++; } printf("\n"); return bb; }
5,807
C
.c
153
33.366013
98
0.62378
kb1isz/linDmrMaster
3
26
0
GPL-2.0
9/7/2024, 2:06:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,438,798
master_server.h
kb1isz_linDmrMaster/master_server.h
/* * Linux DMR Master server Copyright (C) 2014 Wim Hofman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include <sys/socket.h> #include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <syslog.h> #include <pthread.h> #include <strings.h> #include <string.h> #include <time.h> #include <stdbool.h> #include <sqlite3.h> #include <iconv.h> #include <netdb.h> #include <arpa/inet.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <signal.h> #include <math.h> #include <regex.h> struct repeater{ struct sockaddr_in address; int sockfd; bool dmrOnline; bool rdacOnline; bool rdacUpdated; bool sending[3]; int id; time_t lastPTPPConnect; time_t lastDMRConnect; time_t lastRDACConnect; unsigned char callsign[17]; unsigned char txFreq[10]; unsigned char shift[7]; unsigned char hardware[11]; unsigned char firmware[14]; unsigned char mode[4]; unsigned char language[50]; unsigned char geoLocation[20]; unsigned char aprsPass[6]; unsigned char aprsBeacon[100]; unsigned char aprsPHG[7]; }; struct idInfo{ int radioId; char callsign[32]; char name[32]; long aprsTimeStamp; char aprsSuffix[4]; char aprsBeacon[100]; int aprsSymbol; int messageStore; }; struct masterData{ struct sockaddr_in address; int sockfd; bool online; bool sending[3]; }; struct masterInfo{ char ownName[20]; char ownCountryCode[5]; char ownRegion[2]; char sMasterIp[100]; char sMasterPort[6]; char announcedCC1[80]; char announcedCC2[80]; int ownCCInt; int ownRegionInt; int sMasterTS1GroupCount; int sMasterTS2GroupCount; int repTS1GroupCount; int repTS2GroupCount; }; struct ts{ unsigned char repTS1[100]; unsigned char repTS2[100]; unsigned char sMasterTS1[100]; unsigned char sMasterTS2[100]; }; struct sockInfo{ struct sockaddr_in address; int port; }; struct gpsCoordinates{ int radioId; unsigned char latitude[9]; unsigned char longitude[10]; unsigned char speed[4]; unsigned char heading[4]; }; typedef enum {VOICE, DATA, IDLE} state; extern struct repeater repeaterList[100]; extern struct repeater rdacList[100]; extern struct masterData sMaster; extern struct masterInfo master; extern struct ts tsInfo; extern char databaseServer[50]; extern char databaseUser[20]; extern char databasePassword[20]; extern char database[20]; extern struct sockaddr_in discardList[100]; extern int highestRepeater; extern int servicePort; extern int dmrPort; extern int baseDmrPort; extern int rdacPort; extern int baseRdacPort; extern int maxRepeaters; extern int echoId; extern int rrsGpsId; extern state dmrState[3]; extern int (*sMasterTS1List)[2]; extern int (*sMasterTS2List)[2]; extern int (*repTS1List)[2]; extern int (*repTS2List)[2]; extern int ownCCInt; extern int ownRegionInt; extern char version[5]; extern sqlite3 *db; extern int restart; extern char page[50]; extern char aprsUrl[100]; extern char aprsPort[7];
3,631
C
.h
139
23.856115
75
0.771133
kb1isz/linDmrMaster
3
26
0
GPL-2.0
9/7/2024, 2:06:41 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
true
13,507,965
EONmutex.c
robotology_icub-firmware-shared/eth/embobj/core/core/EONmutex.c
/* * Copyright (C) 2013 iCub Facility - Istituto Italiano di Tecnologia * Author: Marco Accame * email: [email protected] * website: www.robotcub.org * Permission is granted to copy, distribute, and/or modify this program * under the terms of the GNU General Public License, version 2 or any * later version published by the Free Software Foundation. * * A copy of the license can be found at * http://www.robotcub.org/icub/license/gpl.txt * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details */ // -------------------------------------------------------------------------------------------------------------------- // - external dependencies // -------------------------------------------------------------------------------------------------------------------- #include "stdlib.h" #include "EoCommon.h" #include "string.h" #include "EOtheMemoryPool.h" #include "EOVmutex_hid.h" // -------------------------------------------------------------------------------------------------------------------- // - declaration of extern public interface // -------------------------------------------------------------------------------------------------------------------- #include "EONmutex.h" // -------------------------------------------------------------------------------------------------------------------- // - declaration of extern hidden interface // -------------------------------------------------------------------------------------------------------------------- #include "EONmutex_hid.h" // -------------------------------------------------------------------------------------------------------------------- // - #define with internal scope // -------------------------------------------------------------------------------------------------------------------- // empty-section // -------------------------------------------------------------------------------------------------------------------- // - definition (and initialisation) of extern variables, but better using _get(), _set() // -------------------------------------------------------------------------------------------------------------------- // empty-section // -------------------------------------------------------------------------------------------------------------------- // - typedef with internal scope // -------------------------------------------------------------------------------------------------------------------- // empty-section // -------------------------------------------------------------------------------------------------------------------- // - declaration of static functions // -------------------------------------------------------------------------------------------------------------------- // virtual static eOresult_t s_eon_mutex_take(void *p, eOreltime_t tout); // virtual static eOresult_t s_eon_mutex_release(void *p); // virtual static eOresult_t s_eon_mutex_delete(void *p); // -------------------------------------------------------------------------------------------------------------------- // - definition (and initialisation) of static variables // -------------------------------------------------------------------------------------------------------------------- //static const char s_eobj_ownname[] = "EONmutex"; // -------------------------------------------------------------------------------------------------------------------- // - definition of extern public functions // -------------------------------------------------------------------------------------------------------------------- extern EONmutex* eon_mutex_New(void) { EONmutex *retptr = NULL; // i get the memory for the neutral mutex object retptr = eo_mempool_GetMemory(eo_mempool_GetHandle(), eo_mempool_align_32bit, sizeof(EONmutex), 1); // i get the base mutex retptr->mutex = eov_mutex_hid_New(); // init its vtable eov_mutex_hid_SetVTABLE(retptr->mutex, s_eon_mutex_take, s_eon_mutex_release, s_eon_mutex_delete); // i get a new none mutex retptr->none = NULL; return(retptr); } extern void eon_mutex_Delete(EONmutex *m) { if(NULL == m) { return; } eov_mutex_hid_Delete(m->mutex); memset(m, 0, sizeof(EONmutex)); eo_mempool_Delete(eo_mempool_GetHandle(), m); return; } // -------------------------------------------------------------------------------------------------------------------- // - definition of extern hidden functions // -------------------------------------------------------------------------------------------------------------------- // empty-section // -------------------------------------------------------------------------------------------------------------------- // - definition of static functions // -------------------------------------------------------------------------------------------------------------------- static eOresult_t s_eon_mutex_take(void *p, eOreltime_t tout) { EONmutex *m = (EONmutex *)p; m = m; // we dont use m->none ... return(eores_OK); } static eOresult_t s_eon_mutex_release(void *p) { EONmutex *m = (EONmutex *)p; m = m; // we dont use m->none ... return(eores_OK); } static eOresult_t s_eon_mutex_delete(void *p) { EONmutex *m = (EONmutex *)p; m = m; // we dont use m->none ... return(eores_OK); } // -------------------------------------------------------------------------------------------------------------------- // - end-of-file (leave a blank line after) // --------------------------------------------------------------------------------------------------------------------
6,039
C
.c
116
47.560345
120
0.342537
robotology/icub-firmware-shared
3
16
1
LGPL-2.1
9/7/2024, 2:06:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,507,986
EONtheCallbackManager.c
robotology_icub-firmware-shared/eth/embobj/core/core/EONtheCallbackManager.c
/* * Copyright (C) 2013 iCub Facility - Istituto Italiano di Tecnologia * Author: Marco Accame * email: [email protected] * website: www.robotcub.org * Permission is granted to copy, distribute, and/or modify this program * under the terms of the GNU General Public License, version 2 or any * later version published by the Free Software Foundation. * * A copy of the license can be found at * http://www.robotcub.org/icub/license/gpl.txt * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details */ // -------------------------------------------------------------------------------------------------------------------- // - external dependencies // -------------------------------------------------------------------------------------------------------------------- #include "stdlib.h" #include "EoCommon.h" #include "string.h" #include "EOtheMemoryPool.h" #include "EOtheErrorManager.h" #include "EONtask.h" #include "EOVtask.h" // -------------------------------------------------------------------------------------------------------------------- // - declaration of extern public interface // -------------------------------------------------------------------------------------------------------------------- #include "EONtheCallbackManager.h" // -------------------------------------------------------------------------------------------------------------------- // - declaration of extern hidden interface // -------------------------------------------------------------------------------------------------------------------- #include "EONtheCallbackManager_hid.h" // -------------------------------------------------------------------------------------------------------------------- // - #define with internal scope // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // - definition (and initialisation) of extern variables, but better using _get(), _set() // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // - typedef with internal scope // -------------------------------------------------------------------------------------------------------------------- // empty-section // -------------------------------------------------------------------------------------------------------------------- // - declaration of static functions // -------------------------------------------------------------------------------------------------------------------- static eOresult_t s_eon_callbackman_execute(EOVtheCallbackManager *v, eOcallback_t cbk, void *arg, eOreltime_t tout); // -------------------------------------------------------------------------------------------------------------------- // - definition (and initialisation) of static variables // -------------------------------------------------------------------------------------------------------------------- //static const char s_eobj_ownname[] = "EONtheCallbackManager"; static EONtheCallbackManager s_eon_callbackmanager = { .vcm = NULL, .tsk = NULL }; // -------------------------------------------------------------------------------------------------------------------- // - definition of extern public functions // -------------------------------------------------------------------------------------------------------------------- extern EONtheCallbackManager * eon_callbackman_Initialise(void) { if(NULL != s_eon_callbackmanager.tsk) { // already initialised return(&s_eon_callbackmanager); } // i prepare the task able to execute callbacks actions associated to expiry of the timers or on gpio s_eon_callbackmanager.tsk = eon_task_New(); // i initialise the base callback manager eov_callbackman_hid_Initialise(s_eon_callbackman_execute, s_eon_callbackmanager.tsk); return(&s_eon_callbackmanager); } extern EONtheCallbackManager* eon_callbackman_GetHandle(void) { if(NULL == s_eon_callbackmanager.tsk) { return(NULL); } return(&s_eon_callbackmanager); } extern eOresult_t eon_callbackman_Execute(EONtheCallbackManager *p, eOcallback_t cbk, void *arg, eOreltime_t tout) { if(NULL == p) { return(eores_NOK_nullpointer); } return(eores_NOK_generic); } extern EONtask * eon_callbackman_GetTask(EONtheCallbackManager *p) { if(NULL == p) { return(NULL); } return(s_eon_callbackmanager.tsk); } // -------------------------------------------------------------------------------------------------------------------- // - definition of extern hidden functions // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // - definition of static functions // -------------------------------------------------------------------------------------------------------------------- static eOresult_t s_eon_callbackman_execute(EOVtheCallbackManager *v, eOcallback_t cbk, void *arg, eOreltime_t tout) { return(eores_OK); } // -------------------------------------------------------------------------------------------------------------------- // - end-of-file (leave a blank line after) // --------------------------------------------------------------------------------------------------------------------
5,962
C
.c
111
50.567568
119
0.373204
robotology/icub-firmware-shared
3
16
1
LGPL-2.1
9/7/2024, 2:06:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,507,995
EoProtocolAS_overridden_fun.template.h
robotology_icub-firmware-shared/eth/embobj/plus/comm-v2/protocol/cfg/EoProtocolAS_overridden_fun.template.h
/* * Copyright (C) 2013 iCub Facility - Istituto Italiano di Tecnologia * Author: Marco Accame * email: [email protected] * website: www.robotcub.org * Permission is granted to copy, distribute, and/or modify this program * under the terms of the GNU General Public License, version 2 or any * later version published by the Free Software Foundation. * * A copy of the license can be found at * http://www.robotcub.org/icub/license/gpl.txt * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details */ // - include guard ---------------------------------------------------------------------------------------------------- #ifndef _EOPROTOCOLAS_OVERRIDDEN_FUN_H_ #define _EOPROTOCOLAS_OVERRIDDEN_FUN_H_ /** @file EoProtocolAS_overridden_fun.h @brief This header file specifies which functions are overridden in the analogsensor of analosensor @author [email protected] @date 06/06/2013 **/ /** @defgroup eo_asfdgr1231 Functions overridden in analog sensor endpoint edfefle. @{ **/ // - external dependencies -------------------------------------------------------------------------------------------- // empty-section // - public #define -------------------------------------------------------------------------------------------------- //#define OVERRIDE_eoprot_fun_INIT_as_strain_config // - declaration of public user-defined types ------------------------------------------------------------------------- // empty-section // - declaration of extern public variables, ... but better using use _get/_set instead ------------------------------- // empty-section // - declaration of extern public functions --------------------------------------------------------------------------- // empty-section /** @} end of group eo_asfdgr1231 **/ #endif // include-guard // - end-of-file (leave a blank line after)----------------------------------------------------------------------------
2,181
C
.c
44
46.590909
120
0.54381
robotology/icub-firmware-shared
3
16
1
LGPL-2.1
9/7/2024, 2:06:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,507,997
EoProtocolSK_overridden_fun.template.h
robotology_icub-firmware-shared/eth/embobj/plus/comm-v2/protocol/cfg/EoProtocolSK_overridden_fun.template.h
/* * Copyright (C) 2013 iCub Facility - Istituto Italiano di Tecnologia * Author: Marco Accame * email: [email protected] * website: www.robotcub.org * Permission is granted to copy, distribute, and/or modify this program * under the terms of the GNU General Public License, version 2 or any * later version published by the Free Software Foundation. * * A copy of the license can be found at * http://www.robotcub.org/icub/license/gpl.txt * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details */ // - include guard ---------------------------------------------------------------------------------------------------- #ifndef _EOPROTOCOLSK_OVERRIDDEN_FUN_H_ #define _EOPROTOCOLSK_OVERRIDDEN_FUN_H_ /** @file EoProtocolSK_overridden_fun.h @brief This header file specifies which functions are overridden in the skin of skin @author [email protected] @date 06/06/2013 **/ /** @defgroup eo_asfdgr1231 Functions overridden in skin endpoint edfefle. @{ **/ // - external dependencies -------------------------------------------------------------------------------------------- // empty-section // - public #define -------------------------------------------------------------------------------------------------- //#define OVERRIDE_eoprot_fun_INIT_sk_skin_status_arrayof10canframes // - declaration of public user-defined types ------------------------------------------------------------------------- // empty-section // - declaration of extern public variables, ... but better using use _get/_set instead ------------------------------- // empty-section // - declaration of extern public functions --------------------------------------------------------------------------- // empty-section /** @} end of group eo_asfdgr1231 **/ #endif // include-guard // - end-of-file (leave a blank line after)----------------------------------------------------------------------------
2,174
C
.c
44
46.431818
120
0.542284
robotology/icub-firmware-shared
3
16
1
LGPL-2.1
9/7/2024, 2:06:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,507,998
EoProtocolMC_overridden_fun.template.h
robotology_icub-firmware-shared/eth/embobj/plus/comm-v2/protocol/cfg/EoProtocolMC_overridden_fun.template.h
/* * Copyright (C) 2013 iCub Facility - Istituto Italiano di Tecnologia * Author: Marco Accame * email: [email protected] * website: www.robotcub.org * Permission is granted to copy, distribute, and/or modify this program * under the terms of the GNU General Public License, version 2 or any * later version published by the Free Software Foundation. * * A copy of the license can be found at * http://www.robotcub.org/icub/license/gpl.txt * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details */ // - include guard ---------------------------------------------------------------------------------------------------- #ifndef _EOPROTOCOLMC_OVERRIDDEN_FUN_H_ #define _EOPROTOCOLMC_OVERRIDDEN_FUN_H_ /** @file EoProtocolMC_overridden_fun.h @brief This header file specifies which functions are overridden in the management of motion control @author [email protected] @date 06/06/2013 **/ /** @defgroup eo_asfdgr1231 Functions overridden in motion control endpoint edfefle. @{ **/ // - external dependencies -------------------------------------------------------------------------------------------- // empty-section // - public #define -------------------------------------------------------------------------------------------------- //#define OVERRIDE_eoprot_fun_INIT_mc_joint_config // - declaration of public user-defined types ------------------------------------------------------------------------- // empty-section // - declaration of extern public variables, ... but better using use _get/_set instead ------------------------------- // empty-section // - declaration of extern public functions --------------------------------------------------------------------------- // empty-section /** @} end of group eo_asfdgr1231 **/ #endif // include-guard // - end-of-file (leave a blank line after)----------------------------------------------------------------------------
2,182
C
.c
44
46.613636
120
0.543551
robotology/icub-firmware-shared
3
16
1
LGPL-2.1
9/7/2024, 2:06:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,508,032
EOnvsetBRDbuilder.c
robotology_icub-firmware-shared/eth/embobj/plus/comm-v2/transport/EOnvsetBRDbuilder.c
/* * Copyright (C) 2013 iCub Facility - Istituto Italiano di Tecnologia * Author: Marco Accame * email: [email protected] * website: www.robotcub.org * Permission is granted to copy, distribute, and/or modify this program * under the terms of the GNU General Public License, version 2 or any * later version published by the Free Software Foundation. * * A copy of the license can be found at * http://www.robotcub.org/icub/license/gpl.txt * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * Public License for more details */ // -------------------------------------------------------------------------------------------------------------------- // - external dependencies // -------------------------------------------------------------------------------------------------------------------- #include "stdlib.h" #include "EoCommon.h" #include "string.h" #include "EOtheMemoryPool.h" #include "EOtheErrorManager.h" #include "EOvector.h" // -------------------------------------------------------------------------------------------------------------------- // - declaration of extern public interface // -------------------------------------------------------------------------------------------------------------------- #include "EOnvsetBRDbuilder.h" // -------------------------------------------------------------------------------------------------------------------- // - declaration of extern hidden interface // -------------------------------------------------------------------------------------------------------------------- #include "EOnvsetBRDbuilder_hid.h" // -------------------------------------------------------------------------------------------------------------------- // - #define with internal scope // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // - definition (and initialisation) of extern variables, but better using _get(), _set() // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // - typedef with internal scope // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // - declaration of static functions // -------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------- // - definition (and initialisation) of static variables // -------------------------------------------------------------------------------------------------------------------- //static const char s_eobj_ownname[] = "EOnvsetBRDbuilder"; // -------------------------------------------------------------------------------------------------------------------- // - definition of extern public functions // -------------------------------------------------------------------------------------------------------------------- extern EOnvsetBRDbuilder* eo_nvsetbrdbuilder_New(eOnvBRD_t board) { EOnvsetBRDbuilder *p = NULL; // uint8_t i = 0; // i get the memory for the object p = eo_mempool_New(eo_mempool_GetHandle(), 1*sizeof(EOnvsetBRDbuilder)); p->epcfg_vector = eo_vector_New(sizeof(eOprot_EPcfg_t), eo_vectorcapacity_dynamic, NULL, 0, NULL, NULL); p->brdcfg = eo_mempool_New(eo_mempool_GetHandle(), 1*sizeof(eOnvset_BRDcfg_t)); p->brdcfg->boardnum = board; p->brdcfg->epcfg_constvect = eo_constvector_Load(p->epcfg_vector); return(p); } extern void eo_nvsetbrdbuilder_Delete(EOnvsetBRDbuilder* p) { if(NULL == p) { return; } if(NULL == p->epcfg_vector) { return; } p->brdcfg->epcfg_constvect = NULL; eo_mempool_Delete(eo_mempool_GetHandle(), p->brdcfg); memset(p->brdcfg, 0, sizeof(eOnvset_BRDcfg_t)); eo_vector_Delete(p->epcfg_vector); p->epcfg_vector = NULL; eo_mempool_Delete(eo_mempool_GetHandle(), p); return; } extern eOresult_t eo_nvsetbrdbuilder_EP_Load(EOnvsetBRDbuilder* p, eOprot_EPcfg_t* epcfg) { EOvector *v = NULL; if((NULL == p) || (NULL == epcfg)) { return(eores_NOK_nullpointer); } if(eobool_false == eoprot_EPcfg_isvalid(epcfg)) { return(eores_NOK_generic); } // ok. now i put the item inside p->brdcfg->epcfg_constvect v = p->epcfg_vector; eo_vector_PushBack(v, epcfg); // and make sure that the constvector is udapted eo_constvector_Load(p->brdcfg->epcfg_constvect); return(eores_OK); } extern eOresult_t eo_nvsetbrdbuilder_EPs_Clear(EOnvsetBRDbuilder* p) { EOvector *v = NULL; if(NULL == p) { return(eores_NOK_nullpointer); } // ok. now i put the item inside p->brdcfg->epcfg_constvect v = p->epcfg_vector; eo_vector_Clear(v); // and make sure that the constvector is updated eo_constvector_Load(v); return(eores_OK); } extern eOnvset_BRDcfg_t* eo_nvsetbrdbuilder_BRDcfg_Get(EOnvsetBRDbuilder* p) { // eOresult_t res = eores_NOK_generic; if(NULL == p) { return(NULL); } return(p->brdcfg); } // -------------------------------------------------------------------------------------------------------------------- // - definition of extern hidden functions // -------------------------------------------------------------------------------------------------------------------- // empty-section // -------------------------------------------------------------------------------------------------------------------- // - definition of static functions // -------------------------------------------------------------------------------------------------------------------- // empty-section // -------------------------------------------------------------------------------------------------------------------- // - end-of-file (leave a blank line after) // --------------------------------------------------------------------------------------------------------------------
6,706
C
.c
135
45.696296
119
0.390966
robotology/icub-firmware-shared
3
16
1
LGPL-2.1
9/7/2024, 2:06:58 PM (Europe/Amsterdam)
false
false
false
false
false
false
false
false
13,524,405
ctp_platform_ops.h
jabjoe_sunxi-gslx680/ctp_platform_ops.h
// This is a cut down version of the ctp_platform_ops.h in sunxi. // Remove when putting gslx680 back in tree. #include <linux/i2c.h> #include <linux/input.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/errno.h> #include <linux/kernel.h>// gpio base address #define PIO_BASE_ADDRESS (0x01c20800) #define PIO_RANGE_SIZE (0x400) #define GPIO_ENABLE #define SYSCONFIG_GPIO_ENABLE #define PIO_INT_STAT_OFFSET (0x214) #define PIO_INT_CTRL_OFFSET (0x210) #include <linux/module.h> #include <linux/slab.h> #include <linux/init.h> #include <linux/ioport.h> #include <asm/irq.h> #include <asm/io.h> #include <mach/irqs.h> #include <linux/i2c.h> typedef enum { PIO_INT_CFG0_OFFSET = 0x200, PIO_INT_CFG1_OFFSET = 0x204, PIO_INT_CFG2_OFFSET = 0x208, PIO_INT_CFG3_OFFSET = 0x20c, } int_cfg_offset; typedef enum{ POSITIVE_EDGE = 0x0, NEGATIVE_EDGE = 0x1, HIGH_LEVEL = 0x2, LOW_LEVEL = 0x3, DOUBLE_EDGE = 0x4 } ext_int_mode; // gpio base address #define PIO_BASE_ADDRESS (0x01c20800) #define PIO_RANGE_SIZE (0x400) #define GPIO_ENABLE #define SYSCONFIG_GPIO_ENABLE #define PIO_INT_STAT_OFFSET (0x214) #define PIO_INT_CTRL_OFFSET (0x210)
1,249
C
.h
42
27.571429
65
0.704508
jabjoe/sunxi-gslx680
3
46
0
GPL-2.0
9/7/2024, 2:07:07 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,537,895
handle_game.c
tesseract2048_d2gs11/D2GS/handle_game.c
#include <winsock2.h> #include <ws2tcpip.h> #include <mswsock.h> #include <windows.h> #include <stdio.h> #include <stdlib.h> #include "d2gs.h" #include "d2ge.h" #include "eventlog.h" #include "vars.h" #include "net.h" #include "handle_s2s.h" #include "handle_d2game.h" #include "debug.h" #include "d2gamelist.h" #include "d2game_protocol.h" #include "nfd.h" int handle_d2game(char* buf, int len, IOCPClient *Client) { unsigned char type = buf[0]; int i; char eof; char repeat; char msgtype; switch (type) { case D2GAME_WALKTOLOCATION: return sizeof(t_d2game_walktolocation) + 1; break; case D2GAME_WALKTOENTITY: return sizeof(t_d2game_walktoentity) + 1; break; case D2GAME_RUNTOLOCATION: return sizeof(t_d2game_runtolocation) + 1; break; case D2GAME_RUNTOENTITY: return sizeof(t_d2game_runtoentity) + 1; break; case D2GAME_LEFTSKILLONLOCATION: return sizeof(t_d2game_leftskillonlocation) + 1; break; case D2GAME_LEFTSKILLONENTITY: return sizeof(t_d2game_leftskillonentity) + 1; break; case D2GAME_LEFTSKILLONENTITYEX: return sizeof(t_d2game_leftskillonentityex) + 1; break; case D2GAME_LEFTSKILLONLOCATIONEX: return sizeof(t_d2game_leftskillonlocationex) + 1; break; case D2GAME_LEFTSKILLONENTITYEX2: return sizeof(t_d2game_leftskillonentityex2) + 1; break; case D2GAME_LEFTSKILLONENTITYEX3: return sizeof(t_d2game_leftskillonentityex3) + 1; break; case D2GAME_SKILLUNK1: return 1; break; case D2GAME_RIGHTSKILLONLOCATION: return sizeof(t_d2game_rightskillonlocation) + 1; break; case D2GAME_RIGHTSKILLONENTITY: return sizeof(t_d2game_rightskillonentity) + 1; break; case D2GAME_RIGHTSKILLONENTITYEX: return sizeof(t_d2game_rightskillonentityex) + 1; break; case D2GAME_RIGHTSKILLONLOCATIONEX: return sizeof(t_d2game_rightskillonlocationex) + 1; break; case D2GAME_RIGHTSKILLONENTITYEX2: return sizeof(t_d2game_rightskillonentityex2) + 1; break; case D2GAME_RIGHTSKILLONENTITYEX3: return sizeof(t_d2game_rightskillonentityex3) + 1; break; case D2GAME_SKILLUNK2: return 1; break; case D2GAME_INTERACTWITHENTITY: return sizeof(t_d2game_interactwithentity) + 1; break; case D2GAME_OVERHEADMESSAGE: eof = 0; repeat = 0; for(i = 3; i < len; i ++) { if (buf[i] == 0) { repeat ++; if (repeat == 3) { eof = 1; break; } } } if (strcmpi(&buf[3], "bye") == 0) return -1; if (eof == 0) return 0; return (++i); break; case D2GAME_CHATMESSAGE: eof = 0; msgtype = buf[1]; repeat = 0; for(i = 3; i < len; i ++) { if (buf[i] == 0) { break; } } for(i++; i < len; i ++) { if (buf[i] == 0) { repeat ++; if (repeat == 2) { eof = 1; break; } } } if (eof == 0) return 0; return (++i); break; case D2GAME_PICKUPITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_pickupitem) + 1; break; case D2GAME_DROPITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_dropitem) + 1; break; case D2GAME_ITEMTOBUFFER: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_itemtobuffer) + 1; break; case D2GAME_PICKUPBUFFERITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_pickupbufferitem) + 1; break; case D2GAME_ITEMTOBODY: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_itemtobody) + 1; break; case D2GAME_SWAP2HANDEDITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_swap2handeditem) + 1; break; case D2GAME_PICKUPBODYITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_pickupbodyitem) + 1; break; case D2GAME_SWITCHBODYITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_switchbodyitem) + 1; break; case D2GAME_SWITCHBODYITEM2: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_switchbodyitem2) + 1; break; case D2GAME_SWITCHINVENTORYITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_switchinventoryitem) + 1; break; case D2GAME_USEITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_useitem) + 1; break; case D2GAME_STACKITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_stackitem) + 1; break; case D2GAME_REMOVESTACKITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_removestackitem) + 1; break; case D2GAME_ITEMTOBELT: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_itemtobelt) + 1; break; case D2GAME_REMOVEBELTITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_removebeltitem) + 1; break; case D2GAME_SWITCHBELTITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_switchbeltitem) + 1; break; case D2GAME_USEBELTITEM: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_usebeltitem) + 1; break; case D2GAME_IDENTIFYITEM: return sizeof(t_d2game_identifyitem) + 1; break; case D2GAME_INSERTSOCKETITEM: return sizeof(t_d2game_insertsocketitem) + 1; break; case D2GAME_SCROLLTOTOME: return sizeof(t_d2game_scrolltotome) + 1; break; case D2GAME_ITEMTOCUBE: InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_itemtocube) + 1; break; case D2GAME_UNSELECTOBJ: return 1; break; case D2GAME_CHATUNK1: return sizeof(t_d2game_chatunk1) + 1; break; case D2GAME_NPCINIT: return sizeof(t_d2game_npcinit) + 1; break; case D2GAME_NPCCANCEL: return sizeof(t_d2game_npccancel) + 1; break; case D2GAME_QUESTMESSAGE: return sizeof(t_d2game_questmessage) + 1; break; case D2GAME_NPCBUY: return sizeof(t_d2game_npcbuy) + 1; break; case D2GAME_NPCSELL: return sizeof(t_d2game_npcsell) + 1; break; case D2GAME_CAINIDENTIFY: return sizeof(t_d2game_cainidentify) + 1; break; case D2GAME_REPAIR: return sizeof(t_d2game_repair) + 1; break; case D2GAME_HIRE: return sizeof(t_d2game_hire) + 1; break; case D2GAME_GAMBLED: return sizeof(t_d2game_gambled) + 1; break; case D2GAME_NPCTRADE: return sizeof(t_d2game_npctrade) + 1; break; case D2GAME_STATPOINT: return sizeof(t_d2game_statpoint) + 1; break; case D2GAME_SKILLPOINT: return sizeof(t_d2game_skillpoint) + 1; break; case D2GAME_SWITCHSKILL: return sizeof(t_d2game_switchskill) + 1; break; case D2GAME_CLOSEDOOR: return sizeof(t_d2game_closedoor) + 1; break; case D2GAME_UPDATEITEMSTAT: return sizeof(t_d2game_updateitemstat) + 1; break; case D2GAME_CHARACTERPHRASE: return sizeof(t_d2game_characterphrase) + 1; break; case D2GAME_QUESTLOG: return 1; break; case D2GAME_RESPAWN: return 1; break; case D2GAME_UNK2: return 1; break; case D2GAME_PUTSLOT: return sizeof(t_d2game_putslot) + 1; break; case D2GAME_CHANGETP: return sizeof(t_d2game_changetp) + 1; break; case D2GAME_MERCINTER: return sizeof(t_d2game_mercinter) + 1; break; case D2GAME_MOVEMERC: return sizeof(t_d2game_movemerc) + 1; break; case D2GAME_WAYPOINT: return sizeof(t_d2game_waypoint) + 1; break; case D2GAME_REASSIGN: return sizeof(t_d2game_reassign) + 1; break; case D2GAME_UNK1: return sizeof(t_d2game_unk1) + 1; break; case D2GAME_TRADE: //InterlockedIncrement(&Client->RequestRate); return sizeof(t_d2game_trade) + 1; break; case D2GAME_DROPGOLD: return sizeof(t_d2game_dropgold) + 1; break; case D2GAME_ASSIGNMENT: return sizeof(t_d2game_assignment) + 1; break; case D2GAME_STAON: return 1; break; case D2GAME_STAOFF: return 1; break; case D2GAME_CLOSEQUEST: return sizeof(t_d2game_closequest) + 1; break; case D2GAME_TOWNFOLK: return sizeof(t_d2game_townfolk) + 1; break; case D2GAME_RELATION: return sizeof(t_d2game_relation) + 1; break; case D2GAME_PARTY: return sizeof(t_d2game_party) + 1; break; case D2GAME_UPDATEPOSITION: return sizeof(t_d2game_updateposition) + 1; break; case D2GAME_SWITCHEQUIP: return 1; break; case D2GAME_POTIONTOMERCENARY: return sizeof(t_d2game_potiontomercenary) + 1; break; case D2GAME_RESURRECTMERC: return sizeof(t_d2game_resurrectmerc) + 1; break; case D2GAME_INVENTORYTOBELT: return sizeof(t_d2game_inventorytobelt) + 1; break; case D2GAME_GAMEEXIT: return 1; break; case D2GAME_ENTERGAMEENVIRONMENT: return 1; break; case D2GAME_PING: //Client->PingTimer = GetTickCount(); return sizeof(t_d2game_ping) + 1; break; default: D2GSEventLog("HandleGame", "UNKNOWN PACKET %x", type); return -1; } }
9,241
C
.c
351
21.683761
58
0.687704
tesseract2048/d2gs11
3
12
0
GPL-2.0
9/7/2024, 2:07:15 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,537,896
hexdump.c
tesseract2048_d2gs11/D2GS/hexdump.c
#include <stdio.h> #include <stdlib.h> #include "hexdump.h" FILE *hexstrm = NULL; extern void hexdump(void const * data, unsigned int len) { unsigned int i; unsigned int r,c; if (!hexstrm) return; if (!data) return; for (r=0,i=0; r<(len/16+(len%16!=0)); r++,i+=16) { fprintf(hexstrm,"%04X: ",i); /* location of first byte in line */ for (c=i; c<i+8; c++) /* left half of hex dump */ if (c<len) fprintf(hexstrm,"%02X ",((unsigned char const *)data)[c]); else fprintf(hexstrm," "); /* pad if short line */ fprintf(hexstrm," "); for (c=i+8; c<i+16; c++) /* right half of hex dump */ if (c<len) fprintf(hexstrm,"%02X ",((unsigned char const *)data)[c]); else fprintf(hexstrm," "); /* pad if short line */ fprintf(hexstrm," "); for (c=i; c<i+16; c++) /* ASCII dump */ if (c<len) if (((unsigned char const *)data)[c]>=32 && ((unsigned char const *)data)[c]<127) fprintf(hexstrm,"%c",((char const *)data)[c]); else fprintf(hexstrm,"."); /* put this for non-printables */ else fprintf(hexstrm," "); /* pad if short line */ fprintf(hexstrm,"\n"); } fflush(hexstrm); }
1,483
C
.c
40
25.7
76
0.468507
tesseract2048/d2gs11
3
12
0
GPL-2.0
9/7/2024, 2:07:15 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,537,897
charlist.c
tesseract2048_d2gs11/D2GS/charlist.c
#include <windows.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <limits.h> #include "charlist.h" /* variables */ static unsigned int clitbl_len = 0; static D2CHARLIST **clitbl = NULL; unsigned int string_hash(char const *string) { unsigned int i; unsigned int pos; unsigned int hash; unsigned int ch; if (!string) return 0; for (hash=0,pos=0,i=0; i<strlen(string); i++) { if (isascii((int)string[i])) ch = (unsigned int)(unsigned char)tolower((int)string[i]); else ch = (unsigned int)(unsigned char)string[i]; hash ^= ROTL(ch,pos,sizeof(unsigned int)*CHAR_BIT); pos += CHAR_BIT-1; } return hash; } int charlist_init(unsigned int tbllen) { if (!tbllen) return -1; charlist_destroy(); clitbl = (D2CHARLIST**)malloc(tbllen*sizeof(D2CHARLIST**)); if (!clitbl) return -1; memset(clitbl, 0, tbllen*sizeof(D2CHARLIST**)); clitbl_len = tbllen; return 0; } int charlist_destroy(void) { charlist_flush(); if (clitbl) free(clitbl); clitbl = NULL; clitbl_len = 0; return 0; } void charlist_flush(void) { unsigned int i; D2CHARLIST *pcl, *ptmp; if (clitbl) { for(i=0; i<clitbl_len; i++) { pcl = clitbl[i]; while(pcl) { ptmp = pcl; pcl = pcl->next; free(ptmp); } } } return; } void *charlist_getdata(unsigned char const *charname, int type) { D2CHARLIST *pcl; unsigned int hashval; void *ret; if (!charname) return NULL; if (!clitbl_len) return NULL; if (strlen(charname)>=(MAX_CHARNAME_LEN)) return NULL; ret = NULL; hashval = string_hash(charname) % clitbl_len; pcl = clitbl[hashval]; while(pcl) { if (strcmpi(pcl->charname, charname) == 0) { switch(type) { case CHARLIST_GET_CHARINFO: ret = pcl->pCharInfo; break; case CHARLIST_GET_GAMEINFO: ret = pcl->pGameInfo; break; default: ret = NULL; } break; } pcl = pcl->next; } return ret; } int charlist_insert(unsigned char *charname, void *pCharInfo, void *pGameInfo) { D2CHARLIST *pcl, *ptmp; unsigned int hashval; D2CHARLIST *found = NULL; if (!charname) return -1; if (!clitbl_len) return -1; if (strlen(charname)>=(MAX_CHARNAME_LEN)) return -2; hashval = string_hash(charname) % clitbl_len; pcl = clitbl[hashval]; ptmp = NULL; while(pcl) { if (strcmpi(pcl->charname, charname) == 0) { //return -3; found = pcl; break; } ptmp = pcl; pcl = pcl->next; } if (found != NULL) { charlist_delete(found->charname); //free(found); } /* not found, insert one */ pcl = (D2CHARLIST*)malloc(sizeof(D2CHARLIST)); if (!pcl) return -4; /* no free memory available :( */ memset(pcl, 0, sizeof(D2CHARLIST)); strncpy(pcl->charname, charname, MAX_CHARNAME_LEN); pcl->pCharInfo = pCharInfo; pcl->pGameInfo = pGameInfo; /* add to hash table link list */ if (ptmp) ptmp->next = pcl; else clitbl[hashval] = pcl; return 0; } int charlist_delete(unsigned char *charname) { D2CHARLIST *pcl, *ptmp; unsigned int hashval; if (!charname) return -1; if (!clitbl_len) return -1; if (strlen(charname)>=(MAX_CHARNAME_LEN)) return -1; hashval = string_hash(charname) % clitbl_len; pcl = clitbl[hashval]; ptmp = NULL; while(pcl) { if (strcmpi(pcl->charname, charname) == 0) { if (ptmp) ptmp->next = pcl->next; else clitbl[hashval] = pcl->next; free(pcl); return 0; } ptmp = pcl; pcl = pcl->next; } return 0; }
3,601
C
.c
157
19.191083
79
0.642183
tesseract2048/d2gs11
3
12
0
GPL-2.0
9/7/2024, 2:07:15 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,537,898
d2gs_d2ge_protocol.h
tesseract2048_d2gs11/D2GS/d2gs_d2ge_protocol.h
#ifndef INCLUDED_D2GS_D2GE_PROTOCOL_H #define INCLUDED_D2GS_D2GE_PROTOCOL_H #pragma pack(push, pack01, 1) typedef struct { unsigned short type; unsigned int seqno; } t_d2gs_d2ge_header; #define D2GE_D2GS_MAX_GAME 0x70 typedef struct { t_d2gs_d2ge_header h; unsigned short d2ge_id; unsigned int max_game; unsigned short port; } t_d2ge_d2gs_max_game; #define D2GE_D2GS_GREET 0x71 typedef struct { t_d2gs_d2ge_header h; unsigned short d2ge_id; } t_d2ge_d2gs_greet; #define D2GS_D2GE_GREET_REPLY 0x71 typedef struct { t_d2gs_d2ge_header h; D2GSCONFIGS d2gsconfig; u_char acstring[255]; u_char configfile[255]; } t_d2gs_d2ge_greet_reply; #define D2GS_D2GE_NEWEMPTYGAME 0x72 typedef struct { t_d2gs_d2ge_header h; u_char gamename[33]; u_char gamepass[33]; u_char gamedesc[33]; DWORD dwGameFlag; BYTE bTemplate; BYTE bReserved1; BYTE bReserved2; DWORD GameId; } t_d2gs_d2ge_newemptygame; #define D2GE_D2GS_NEWEMPTYGAME_RETURN 0x72 typedef struct { t_d2gs_d2ge_header h; BOOL result; DWORD GameId; } t_d2ge_d2gs_newemptygame_return; #define D2GS_D2GE_SENDCHAR 0x73 typedef struct { t_d2gs_d2ge_header h; DWORD dwClientId; DWORD dwSize; DWORD dwTotalSize; BOOL bLock; DWORD dwReserved1; PLAYERINFO lpPlayerInfo; DWORD dwReserved2; DWORD SaveDataLen; } t_d2gs_d2ge_sendchar; #define D2GE_D2GS_SENDCHAR_RETURN 0x73 typedef struct { t_d2gs_d2ge_header h; BOOL result; } t_d2ge_d2gs_sendchar_return; #define D2GS_D2GE_REMOVECLIENT 0x74 typedef struct { t_d2gs_d2ge_header h; DWORD dwClientId; } t_d2gs_d2ge_removeclient; #define D2GS_D2GE_ENDALLGAMES 0x75 typedef struct { t_d2gs_d2ge_header h; } t_d2gs_d2ge_endallgames; #define D2GS_D2GE_CHATMSG 0x76 typedef struct { t_d2gs_d2ge_header h; DWORD dwClientId; DWORD dwType; DWORD dwColor; u_char name[33]; DWORD TextLen; } t_d2gs_d2ge_chatmsg; #define D2GE_D2GS_CHATMSG_RETURN 0x76 typedef struct { t_d2gs_d2ge_header h; DWORD result; } t_d2ge_d2gs_chatmsg_return; #define D2GE_D2GS_CLOSEGAME 0x80 typedef struct { t_d2gs_d2ge_header h; WORD wGameId; } t_d2ge_d2gs_closegame; #define D2GE_D2GS_LEAVEGAME 0x81 typedef struct { t_d2gs_d2ge_header h; GAMEDATA lpGameData; WORD wGameId; WORD wCharClass; DWORD dwCharLevel; DWORD dwExpLow; DWORD dwExpHigh; WORD wCharStatus; u_char charname[17]; BOOL bUnlock; DWORD dwZero1; DWORD dwZero2; u_char accountname[17]; PLAYERDATA PlayerData; PLAYERMARK PlayerMark; int PortraitLen; } t_d2ge_d2gs_leavegame; #define D2GE_D2GS_GETCHAR 0x82 typedef struct { t_d2gs_d2ge_header h; GAMEDATA lpGameData; u_char charname[17]; DWORD dwClientId; u_char accountname[17]; int d2ge_id; } t_d2ge_d2gs_getchar; #define D2GE_D2GS_SAVECHAR 0x83 typedef struct { t_d2gs_d2ge_header h; GAMEDATA lpGameData; u_char charname[17]; u_char accountname[17]; DWORD dwSize; PLAYERDATA PlayerData; int SaveDataLen; } t_d2ge_d2gs_savechar; #define D2GE_D2GS_ENTERGAME 0x84 typedef struct { t_d2gs_d2ge_header h; WORD wGameId; u_char charname[17]; WORD wCharClass; DWORD dwCharLevel; DWORD dwReserved; } t_d2ge_d2gs_entergame; #define D2GE_D2GS_FINDTOKEN 0x85 typedef struct { t_d2gs_d2ge_header h; u_char charname[17]; DWORD dwToken; WORD wGameId; } t_d2ge_d2gs_findtoken; #define D2GS_D2GE_FINDTOKEN_CALLBACK 0x85 typedef struct { t_d2gs_d2ge_header h; BOOL result; u_char accountname[17]; PLAYERDATA lpPlayerData; } t_d2gs_d2ge_findtoken_callback; #define D2GE_D2GS_UPDATELADDER 0x86 typedef struct { t_d2gs_d2ge_header h; u_char charname[17]; WORD wCharClass; DWORD dwCharLevel; DWORD dwCharExpLow; DWORD dwCharExpHigh; WORD wCharStatus; PLAYERMARK PlayerMark; } t_d2ge_d2gs_updateladder; #define D2GE_D2GS_UPDATEINFO 0x87 typedef struct { t_d2gs_d2ge_header h; WORD wGameId; u_char charname[17]; WORD wCharClass; DWORD dwCharLevel; } t_d2ge_d2gs_updateinfo; #define D2GS_D2GE_INCOMING_CLIENT 0x88 typedef struct { t_d2gs_d2ge_header h; SOCKET s; } t_d2gs_d2ge_incoming_client; #pragma pack(pop, pack01) #endif
4,453
C
.c
198
19.681818
43
0.715782
tesseract2048/d2gs11
3
12
0
GPL-2.0
9/7/2024, 2:07:15 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,537,900
d2cs_d2gs_character.h
tesseract2048_d2gs11/D2GS/d2cs_d2gs_character.h
#ifndef INCLUDED_D2CS_D2GS_CHARACTER_H #define INCLUDED_D2CS_D2GS_CHARACTER_H #ifdef D2CS # include "common/bn_type.h" #endif #ifdef D2GS # include "bn_types.h" #pragma pack(push, pack01, 1) #endif #define D2CHARINFO_MAGICWORD 0x12345678 #define D2CHARINFO_VERSION 0x00010000 #define D2CHARINFO_PORTRAIT_PADSIZE 30 typedef struct { bn_int magicword; /* static for check */ bn_int version; /* charinfo file version */ bn_int create_time; /* character creation time */ bn_int last_time; /* character last access time */ bn_int checksum; bn_int total_play_time; /* total in game play time */ bn_int reserved[6]; unsigned char charname[MAX_CHARNAME_LEN]; unsigned char account[MAX_ACCTNAME_LEN]; unsigned char realmname[MAX_REALMNAME_LEN]; } t_d2charinfo_header; typedef struct { bn_int experience; bn_int charstatus; bn_int charlevel; bn_int charclass; } t_d2charinfo_summary; typedef struct { bn_short header; /* 0x84 0x80 */ bn_byte gfx[11]; bn_byte class; bn_byte color[11]; bn_byte level; bn_byte status; bn_byte u1[3]; bn_byte ladder; /* need not be 0xff and 0 to make character displayed as ladder character */ /* client only check this bit */ bn_byte u2[2]; bn_byte end; /* 0x00 */ } t_d2charinfo_portrait; typedef struct { t_d2charinfo_header header; t_d2charinfo_portrait portrait; bn_byte pad[D2CHARINFO_PORTRAIT_PADSIZE]; t_d2charinfo_summary summary; } t_d2charinfo_file; #ifdef D2GS #pragma pack(pop, pack01) #endif #endif
1,713
C
.c
56
26.553571
136
0.655888
tesseract2048/d2gs11
3
12
0
GPL-2.0
9/7/2024, 2:07:15 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,537,901
connection.h
tesseract2048_d2gs11/D2GS/connection.h
#ifndef INCLUDED_CONNECTION_H #define INCLUDED_CONNECTION_H /* for identifying by bnetd server, send just after connected */ typedef struct { bn_byte bnclass; } t_d2gs_connect; #define CONNECT_CLASS_D2GS_TO_D2CS 0x91 #define CONNECT_CLASS_D2GS_TO_D2DBS 0x88 #endif /* INCLUDED_CONNECTION_H */
313
C
.c
10
28.6
65
0.763514
tesseract2048/d2gs11
3
12
0
GPL-2.0
9/7/2024, 2:07:15 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,537,904
charstat.c
tesseract2048_d2gs11/D2GS/charstat.c
#include <windows.h> #include <stdio.h> #include <stdlib.h> #include "charstat.h" unsigned int charstat_getbit(const char* pos, const int start, const int len){ int result = 0; int i; for(i = start; i < start + len; i ++){ unsigned char* cur = (unsigned char*)pos + (i / 8); result = (result << 1); if((*cur & (1 << (i % 8))) != 0) result ++; } return result; } unsigned int charstat_to_be(const unsigned int len, const unsigned int le){ unsigned int i; unsigned int result = 0; for(i = 0; i < len; i ++){ result = (result << 1); if((le & (1 << i)) != 0) result ++; } return result; } unsigned int get_d2_int(const char* data, int* pos, const int len){ int val = charstat_to_be(len, charstat_getbit(data, *pos, len)); *pos += len; return val; } struct t_charstat get_charstat(char* data, unsigned int datalen){ struct t_charstat r; char* buf = data + 0x2FF +2; int pos = 0; memset(&r, 0, sizeof(struct t_charstat)); r.charclass = data[0x28 + 2]; while(pos < 54*8){ int statid = get_d2_int(buf, &pos, 9); switch(statid){ case 0: r.str = get_d2_int(buf, &pos, 10); break; case 1: r.ene = get_d2_int(buf, &pos, 10); break; case 2: r.dex = get_d2_int(buf, &pos, 10); break; case 3: r.vit = get_d2_int(buf, &pos, 10); break; case 4: r.statpoint = get_d2_int(buf, &pos, 10); break; case 5: r.skillpoint = get_d2_int(buf, &pos, 8); break; case 6: r.currlife = get_d2_int(buf, &pos, 21); r.currlife /= 256; break; case 7: r.maxlife = get_d2_int(buf, &pos, 21); r.maxlife /= 256; break; case 8: r.currmana = get_d2_int(buf, &pos, 21); r.currmana /= 256; break; case 9: r.maxmana = get_d2_int(buf, &pos, 21); r.maxmana /= 256; break; case 10: r.currsta = get_d2_int(buf, &pos, 21); r.currsta /= 256; break; case 11: r.maxsta = get_d2_int(buf, &pos, 21); r.maxsta /= 256; break; case 12: r.level = get_d2_int(buf, &pos, 7); break; case 13: r.experience = get_d2_int(buf, &pos, 32); break; case 14: r.gold1 = get_d2_int(buf, &pos, 25); break; case 15: r.gold2 = get_d2_int(buf, &pos, 25); break; default: goto ok; break; } } ok: return r; }
2,396
C
.c
101
19.09901
79
0.563239
tesseract2048/d2gs11
3
12
0
GPL-2.0
9/7/2024, 2:07:15 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,537,906
utils.c
tesseract2048_d2gs11/D2GS/utils.c
#include <windows.h> #include "d2gelib/colorcode.h" #define SPLIT_STRING_INIT_COUNT 32 #define SPLIT_STRING_INCREASEMENT 32 extern char * * strtoarray(char const * str, char const * delim, int * count) { int i ,n, index_size; int in_delim, match; char * temp, * result; int * pindex; char * pd; char const * ps; char * realloc_tmp; if (!str || !delim || !count) return NULL; temp=malloc(strlen(str)+1); if (!temp) return NULL; n = SPLIT_STRING_INIT_COUNT; pindex=malloc(sizeof(char *) * n); if (!pindex) { free(temp); return NULL; } *count=0; in_delim=1; ps=str; pd=temp; pindex[0]=0; while (*ps!='\0') { match=0; for (i=0; delim[i]!='\0'; i++) { if ( *ps == delim[i]) { match=1; if (!in_delim) { *pd = '\0'; pd++; (*count)++; in_delim=1; } break; } } if (!match) { if (in_delim) { if (*count>=n) { n += SPLIT_STRING_INCREASEMENT; if (!(realloc_tmp=realloc(pindex,n * sizeof(char *)))) { free(pindex); free(temp); return NULL; } pindex=(int *)realloc_tmp; } pindex[*count]= pd-temp; in_delim = 0; } *pd = * ps; pd++; } ps++; } if (!in_delim) { *pd='\0'; pd++; (*count)++; } index_size=*count * sizeof(char *); if (!index_size) { free(temp); free(pindex); return NULL; } result=malloc(pd-temp+index_size); if (!result) { free(temp); free(pindex); return NULL; } memcpy(result+index_size,temp,pd-temp); for (i=0; i< *count; i++) { pindex[i]+=(int)result+index_size; } memcpy(result,pindex,index_size); free(temp); free(pindex); return (char **) result; } extern char * * strtoargv(char const * str, int * count) { unsigned int n, index_size; char * temp; int i, j; int * pindex; char * result; char * realloc_tmp; if (!str || !count) return NULL; temp=malloc(strlen(str)+1); if (!temp) return NULL; n = SPLIT_STRING_INIT_COUNT; pindex=malloc(n * sizeof (char *)); if (!pindex) return NULL; i=j=0; *count=0; while (str[i]) { while (str[i]==' ' || str[i]=='\t') i++; if (!str[i]) break; if ((unsigned int)(*count) >=n ) { n += SPLIT_STRING_INCREASEMENT; if (!(realloc_tmp=realloc(pindex,n * sizeof(char *)))) { free(pindex); free(temp); return NULL; } pindex=(int *)realloc_tmp; } pindex[*count]=j; (*count)++; if (str[i]=='"') { i++; while (str[i]) { if (str[i]=='\\') { i++; if (!str[i]) break; } else if (str[i]=='"') { i++; break; } temp[j++]=str[i++]; } } else { while (str[i] && str[i] != ' ' && str[i] != '\t') { temp[j++]=str[i++]; } } temp[j++]='\0'; } index_size= *count * sizeof(char *); if (!index_size) { free(temp); free(pindex); return NULL; } result=malloc(j+index_size); if (!result) { free(temp); free(pindex); return NULL; } memcpy(result+index_size,temp,j); for (i=0; i< *count; i++) { pindex[i] +=(int)result+index_size; } memcpy(result,pindex,index_size); free(temp); free(pindex); return (char * *)result; } extern char * str_strip_affix(char * str, char const * affix) { unsigned int i, j, n; int match; if (!str) return NULL; if (!affix) return str; for (i=0; str[i]; i++) { match=0; for (n=0; affix[n]; n++) { if (str[i]==affix[n]) { match=1; break; } } if (!match) break; } for (j=strlen(str)-1; j>=i; j--) { match=0; for (n=0; affix[n]; n++) { if (str[j]==affix[n]) { match=1; break; } } if (!match) break; } if (i>j) { str[0]='\0'; } else { memmove(str,str+i,j-i+1); str[j-i+1]='\0'; } return str; } typedef struct { char const * src; char const * dest; } t_replace; static t_replace ColorHackTable[] = { {"%white%", D2COLOR_WHITE}, {"%red%", D2COLOR_RED}, {"%green%", D2COLOR_GREEN}, {"%blue%", D2COLOR_BLUE}, {"%golden%", D2COLOR_GOLDEN}, {"%grey%", D2COLOR_GREY}, {"%black%", D2COLOR_BLACK}, {"%dyellow%", D2COLOR_DARK_YELLOW}, {"%orange%", D2COLOR_ORANGE}, {"%yellow%", D2COLOR_YELLOW}, {"%dgreen%", D2COLOR_DARK_GREEN}, {"%purple%", D2COLOR_PURPLE}, {"%ldgreen%", D2COLOR_LIGHT_DARK_GREEN}, { NULL, NULL} }; extern char *string_color(char *str) { char *src, *dest; t_replace *tr; if (!str) return NULL; src = dest = str; while(*src!='\0') { if (*src!='%') { *dest++ = *src++; continue; } tr = ColorHackTable; while(tr->src!=NULL) { if (strnicmp(src, tr->src, strlen(tr->src))==0) { memcpy(dest, tr->dest, strlen(tr->dest)); src += strlen(tr->src); dest += strlen(tr->dest); continue; } tr++; } *dest++ = *src++; } *dest = '\0'; return str; }
4,912
C
.c
239
16.518828
78
0.542672
tesseract2048/d2gs11
3
12
0
GPL-2.0
9/7/2024, 2:07:15 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true
13,537,910
eventlog.c
tesseract2048_d2gs11/D2GS/eventlog.c
#include <windows.h> #include <stdio.h> #include <stdarg.h> #include <time.h> #include <string.h> #include "d2gs.h" #include "vars.h" #include "eventlog.h" static FILE *eventstrm = NULL; /* general log stream */ static FILE *gestrm = NULL; /* for game engine */ /* the following var used in hexdump.c, for debuging */ extern FILE *hexstrm; /********************************************************************* * Purpose: to initialize the envet log system * Return: TRUE(success) or FALSE(failed) *********************************************************************/ int D2GSEventLogInitialize(void) { eventstrm = fopen("d2gs.log", "a"); /* for debug, used by hexdump.c */ hexstrm = fopen("debug.log", "a"); if (!hexstrm) return FALSE; if (eventstrm) return TRUE; else return FALSE; } /* End of D2GSEventLogInitialize() */ /********************************************************************* * Purpose: to cleanup the envet log system * Return: none *********************************************************************/ void D2GSEventLogCleanup(void) { if (eventstrm) fclose(eventstrm); #ifdef DEBUG if (hexstrm) fclose(hexstrm); #endif eventstrm = NULL; return; } /* End of D2GSEventLogCleanup() */ /********************************************************************* * Purpose: to log the event to the file or the standard output * Return: none *********************************************************************/ void D2GSEventLog(char const * module, char const * fmt, ...) { va_list args; char time_string[EVENT_TIME_MAXLEN]; SYSTEMTIME st; if (!d2gsconf.enablegslog) return; if (!eventstrm) return; GetLocalTime(&st); sprintf(time_string, "%02d/%02d %02d:%02d:%02d.%03d", st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); if (!module) { fprintf(eventstrm, "%s eventlog: got NULL module\n", time_string); fflush(eventstrm); #ifdef DEBUG_ON_CONSOLE fprintf(stdout, "%s eventlog: got NULL module\n", time_string); #endif return; } if (!fmt) { fprintf(eventstrm, "%s eventlog: got NULL fmt\n",time_string); fflush(eventstrm); #ifdef DEBUG_ON_CONSOLE fprintf(stdout, "%s eventlog: got NULL fmt\n",time_string); #endif return; } fprintf(eventstrm,"%s %s: ", time_string, module); #ifdef DEBUG_ON_CONSOLE fprintf(stdout,"%s %s: ", time_string, module); #endif va_start(args, fmt); vfprintf(eventstrm, fmt, args); #ifdef DEBUG_ON_CONSOLE vfprintf(stdout, fmt, args); #endif va_end(args); fprintf(eventstrm, "\n"); fflush(eventstrm); #ifdef DEBUG_ON_CONSOLE fprintf(stdout, "\n"); #endif return; } /* End of D2GSEventLog() */ /********************************************************************* * Purpose: to log the argument * Return: none *********************************************************************/ void LogAP(LPCSTR lpModule, LPCSTR lpFormat, va_list ap) { SYSTEMTIME st; DWORD len; char msg[MAX_LINE_LEN]; char tmp[MAX_LINE_LEN]; if (!d2gsconf.enablegemsg) return; if (!lpModule || !lpFormat) return; GetLocalTime(&st); len = wsprintf(msg, "%02d/%02d %02d:%02d:%02d.%03d", st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); len += vsprintf(tmp, lpFormat, ap); strcat(msg, tmp); strcat(msg, "\n"); len += strlen("\n"); fprintf(gestrm, "%s", msg); fflush(gestrm); #ifdef DEBUG_ON_CONSOLE fprintf(stdout, "%s", msg); #endif return; } /* End of LogAP */ /********************************************************************* * Purpose: to dump the portrait of a char * Return: none *********************************************************************/ void PortraitDump(LPCSTR lpAccountName, LPCSTR lpCharName, LPCSTR lpCharPortrait) { #ifndef DEBUG return; #else FILE *fp; char filename[MAX_PATH]; if (!lpAccountName || !lpCharName) return; sprintf(filename, "portrait\\%s", lpCharName); fp = fopen(filename, "wb"); if (!fp) return; fwrite(lpCharPortrait, 1, strlen(lpCharPortrait)+1, fp); fclose(fp); return; #endif } /* End of PortraitDump() */
4,225
C
.c
131
28.938931
82
0.565207
tesseract2048/d2gs11
3
12
0
GPL-2.0
9/7/2024, 2:07:15 PM (Europe/Amsterdam)
false
false
false
true
false
false
false
true